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

attach-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

attach-ware - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

29

index.js

@@ -1,27 +0,11 @@

/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module attach-ware
* @fileoverview Middleware with configuration.
*/
'use strict';
/* Dependencies. */
var unherit = require('unherit');
/* Expose. */
module.exports = patch;
/* Methods. */
var slice = [].slice;
/**
* Clone `Ware` without affecting the super-class and
* turn it into configurable middleware.
*
* @param {Function} Ware - Ware-like constructor.
* @return {Function} AttachWare - Configurable middleware.
*/
/* Clone `Ware` without affecting the super-class and
* turn it into configurable middleware. */
function patch(Ware) {

@@ -37,10 +21,3 @@ var AttachWare = unherit(Ware);

/**
* Attach configurable middleware.
*
* @memberof {AttachWare}
* @this {AttachWare}
* @param {Function} attach - Attacher.
* @return {AttachWare} - `this`.
*/
/* Attach configurable middleware. */
function use(attach) {

@@ -47,0 +24,0 @@ var self = this;

47

package.json
{
"name": "attach-ware",
"version": "2.0.1",
"version": "2.0.2",
"description": "Middleware with configuration",

@@ -13,5 +13,2 @@ "license": "MIT",

],
"dependencies": {
"unherit": "^1.0.0"
},
"repository": "https://github.com/wooorm/attach-ware",

@@ -23,23 +20,20 @@ "bugs": "https://github.com/wooorm/attach-ware/issues",

],
"engines": {
"node": ">=0.11.0"
},
"files": [
"index.js"
],
"dependencies": {
"unherit": "^1.0.0"
},
"devDependencies": {
"browserify": "^13.0.0",
"browserify": "^14.0.0",
"esmangle": "^1.0.0",
"nyc": "^7.1.0",
"remark-cli": "^1.0.0",
"remark-comment-config": "^4.0.0",
"remark-github": "^5.0.0",
"remark-lint": "^4.0.0",
"remark-validate-links": "^4.0.0",
"nyc": "^11.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^3.0.0",
"tape": "^4.4.0",
"ware": "^1.3.0",
"xo": "^0.16.0"
"xo": "^0.18.0"
},
"scripts": {
"build-md": "remark . --quiet --frail",
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js -s AttachWare > attach-ware.js",

@@ -61,23 +55,12 @@ "build-mangle": "esmangle attach-ware.js > attach-ware.min.js",

"space": true,
"rules": {},
"esnext": false,
"ignores": [
"attach-ware.js",
"attach-ware.min.js"
"attach-ware.js"
]
},
"remarkConfig": {
"output": true,
"plugins": {
"comment-config": null,
"lint": {
"heading-increment": false,
"list-item-spacing": false
},
"github": null,
"validate-links": null
},
"settings": {
"bullet": "*"
}
"plugins": [
"preset-wooorm"
]
}
}

@@ -19,8 +19,8 @@ # attach-ware [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

module.exports = function (ctx, options) {
if (!options.condition) return;
return options.condition ? transform : null;
return function (req, res, next) {
res.x = 'hello';
next();
};
function transform(req, res, next) {
res.x = 'hello';
next();
}
}

@@ -33,8 +33,8 @@ ```

module.exports = function (ctx, options) {
if (!options.condition) return;
return options.condition ? transform : null;
return function (req, res, next) {
res.y = 'world';
next();
};
function transform(req, res, next) {
res.y = 'world';
next();
}
}

@@ -47,12 +47,13 @@ ```

var ware = require('attach-ware')(require('ware'));
var x = require('./x.js');
var y = require('./y.js');
var x = require('./x');
var y = require('./y');
var middleware = attachWare()
.use(x, {'condition': true})
.use(y, {'condition': false})
.run({}, {}, function (err, req, res) {
console.log(res.x); // "hello"
console.log(res.y); // undefined
});
.use(x, {condition: true})
.use(y, {condition: false});
middleware.run({}, {}, function (err, req, res) {
console.log(res.x); // "hello"
console.log(res.y); // undefined
});
```

@@ -66,8 +67,10 @@

**Parameters**:
###### Parameters
* `Ware` ([`Ware`][ware]).
* `Ware` ([`Ware`][ware])
**Returns**: `Function`.
###### Returns
`Function`.
### `AttachWare()`

@@ -82,17 +85,17 @@

* `attachWare.use(attacher[, input...])`;
* `attachWare.use(attachers[, input...])`;
* `attachWare.use(list)`;
* `attachWare.use(matrix)`.
* `attachWare.use(attacher[, input...])`
* `attachWare.use(attachers[, input...])`
* `attachWare.use(list)`
* `attachWare.use(matrix)`
###### Parameters
* `attacher` (`Function`) — One attacher.
* `attacher` (`Function`) — One attacher
* `attachers` (`Array.<Function>`)
— List where each value is an `attacher`;
— List where each value is an `attacher`
* `list` (`Array`)
— List where the first value is an `attacher`, and further values
are `input`;
are `input`
* `matrix` (`Array`)
— Matrix where each entry is a `list`.
— Matrix where each entry is a `list`

@@ -108,3 +111,3 @@ Invokes `attacher` with [`context`][context] and all `input`.

The first argument for `attach`ers. When this is falsey, the instance
The first argument for `attach`ers. When this is falsey, the instance
itself is used.

@@ -111,0 +114,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