Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

piton-pipe

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

piton-pipe - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

18

lib/pipe.js

@@ -15,3 +15,16 @@ module.exports.createPipe = function() {

function remove(processor) {
delete pipe[pipe.indexOf(processor)];
var processorIndex = pipe.indexOf(processor);
if (processorIndex === -1) {
throw new RangeError('processor function not found in pipe');
}
delete pipe[processorIndex];
pipe = pipe.filter(function(value) {
return value !== undefined;
});
return self;
}

@@ -21,2 +34,3 @@

pipe = [];
return self;
}

@@ -49,2 +63,2 @@

return self;
};
};

17

package.json
{
"name": "piton-pipe",
"description": "Build and run an Async pipeline of functions",
"version": "0.0.2",
"author": "Paul Serby <paul.serby@clock.co.uk>",
"version": "0.0.3",
"author": "Paul Serby <paul@serby.net>",
"contributors": [
{ "name": "Paul Serby", "email": "paul.serby@clock.co.uk" }
{ "name": "Paul Serby", "email": "paul@serby.net" }
],

@@ -12,7 +12,8 @@ "dependencies": {

"devDependencies": {
"expresso": "0.7.2"
"mocha": "0.3.6",
"should": "0.3.2"
},
"keywords": ["pipe"],
"repository": "git://github.com/PabloSerbo/piton-pipe",
"main": "index",
"repository": "git://github.com/serby/piton-pipe",
"main": "index",
"scripts": {

@@ -22,3 +23,3 @@ "test": "cake test",

},
"engines": { "node": ">= 0.4.6 < 0.5.0" }
}
"engines": { "node": ">= 0.4.6 < 0.7.0" }
}
# piton-pipe - Build and run an Async pipeline of functions.
Input is given then passed though the functions in the pipe via callbacks.
An input value is given to the pipe and passed each function in turn.
This allows async operations to process the value.

@@ -12,10 +13,10 @@

var pipe = require('piton-pipe').createPipe(['onCreate']);
pipe.add('onCreate', function(value, callback) {
pipe.add(function(value, callback) {
callback(null, value + 2;
});
pipe.add('onCreate', function(value, callback) {
pipe.add(function(value, callback) {
callback(null, value / 3);
});
var value = 7;
pipe.run(value, 'onCreate', function(error, newValue) {
pipe.run(value, function(error, newValue) {
console.log(newValue);

@@ -25,5 +26,5 @@ });

## Credits
* [Paul Serby](https://github.com/PabloSerbo/)
* [Paul Serby](https://github.com/serby/)
## Licence
Licenced under the [New BSD License](http://opensource.org/licenses/bsd-license.php)

@@ -9,39 +9,103 @@ var

module.exports = {
'add without a function fails': function() {
var pipe = Pipe.createPipe();
assert.throws(function() {
pipe.add();
}, /TypeError/);
},
'add is chainable': function() {
var pipe = Pipe.createPipe();
assert.strictEqual(pipe.add(additionProcess), pipe);
},
'run does nothing with an empty pipe': function() {
var pipe = Pipe.createPipe();
pipe.run(1, function(error, value) {
assert.eql(value, 1);
describe('pipe', function() {
describe('#add()', function() {
it('without a function as a parameter fails', function() {
var pipe = Pipe.createPipe();
assert.throws(function() {
pipe.add();
}, /TypeError/);
});
},
'run processes correctly': function() {
var pipe = Pipe.createPipe()
.add(additionProcess)
.add(additionProcess);
it('is chainable', function() {
var pipe = Pipe.createPipe();
pipe.add(additionProcess).should.equal(pipe);
});
});
pipe.run(1, function(error, value) {
assert.eql(value, 3);
describe('#run()', function() {
it('does nothing with an empty pipe', function(done) {
var pipe = Pipe.createPipe();
pipe.run(1, function(error, value) {
value.should.equal(1);
done();
});
});
},
'remove is successful': function() {
var pipe = Pipe.createPipe()
.add(additionProcess)
.add(additionProcess);
it('run processes correctly', function(done) {
pipe.run(1, function(error, value) {
assert.eql(value, 3);
var pipe = Pipe.createPipe()
.add(additionProcess)
.add(additionProcess);
pipe.run(1, function(error, value) {
value.should.equal(3);
done();
});
});
}
};
});
describe('#remove()', function() {
it('is successful', function(done) {
var functionToRemove = function(value, callback) {
callback(null, value + 10);
};
var pipe = Pipe.createPipe()
.add(additionProcess)
.add(functionToRemove);
pipe.remove(functionToRemove);
pipe.run(1, function(error, value) {
value.should.equal(2);
done();
});
});
it('throws error if process function not found', function() {
var pipe = Pipe.createPipe();
assert.throws(function() {
pipe.remove(additionProcess);
}, /RangeError: processor function not found in pipe/ );
});
it('is chainable', function() {
var pipe = Pipe.createPipe();
pipe
.add(additionProcess)
.remove(additionProcess).should.equal(pipe);
});
});
describe('#clear()', function() {
it('does not error with empty pipe', function() {
var pipe = Pipe.createPipe();
pipe.clear();
});
it('is chainable', function() {
var pipe = Pipe.createPipe();
pipe
.clear();
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc