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

ware

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ware - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

21

lib/ware.js

@@ -36,24 +36,11 @@

/**
* Return a function for input and callback
* Call back a function from the given input.
*/
Ware.prototype.end = function () {
Ware.prototype.end = function (input, callback) {
var fns = this.fns
, errFn = this.errFn;
return function (input, callback) {
iter(fns, errFn, input, callback);
};
};
return next(0, {});
/**
* Iterate over the middleware functions. Uses an object for the default output
* or you can pass your own.
*/
function iter (fns, errFn, input, callback) {
next(0, {});
function next (index, output) {

@@ -68,2 +55,2 @@ var fn = fns[index];

}
}
};

2

package.json
{
"name": "ware",
"version": "0.0.1",
"version": "0.1.0",
"description": "Generic middleware to compose a series of functions",

@@ -5,0 +5,0 @@ "keywords": [

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

var Ware = require('ware');
var ware = require('ware')();
var middleware = new Ware()
.use(function (input, output, next) {
output.x = input.x * 2;
next();
});
ware.use(function (input, output, next) {
output.x = input.x * 2;
next();
});
var composed = middleware.end();
composed({ x : 4 }, function (err, result) {
ware.end({ x : 4 }, function (err, result) {
console.log(result.x); // 8

@@ -43,10 +40,8 @@ });

#### .end()
#### .end(input, fn)
Returns a function which composes all the middleware.
Runs the middleware functions.
```javascript
var composed = ware.end();
composed(input, function (err, result) { /*...*/ });
ware.end(input, function (err, result) { /*...*/ });
```

@@ -53,0 +48,0 @@

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