aboutsummaryrefslogtreecommitdiff
path: root/node_modules/use
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/use
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
downloadwallet-core-bbff7403fbf46f9ad92240ac213df8d30ef31b64.tar.xz
update packages
Diffstat (limited to 'node_modules/use')
-rw-r--r--node_modules/use/LICENSE2
-rw-r--r--node_modules/use/README.md64
-rw-r--r--node_modules/use/index.js92
-rw-r--r--node_modules/use/package.json49
-rw-r--r--node_modules/use/utils.js23
5 files changed, 125 insertions, 105 deletions
diff --git a/node_modules/use/LICENSE b/node_modules/use/LICENSE
index 83b56e709..7cccaf9e3 100644
--- a/node_modules/use/LICENSE
+++ b/node_modules/use/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2015-2017, Jon Schlinkert
+Copyright (c) 2015-present, Jon Schlinkert.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/node_modules/use/README.md b/node_modules/use/README.md
index 4f9067e19..59b1dbd82 100644
--- a/node_modules/use/README.md
+++ b/node_modules/use/README.md
@@ -1,7 +1,9 @@
-# use [![NPM version](https://img.shields.io/npm/v/use.svg?style=flat)](https://www.npmjs.com/package/use) [![NPM monthly downloads](https://img.shields.io/npm/dm/use.svg?style=flat)](https://npmjs.org/package/use) [![NPM total downloads](https://img.shields.io/npm/dt/use.svg?style=flat)](https://npmjs.org/package/use) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/use.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/use)
+# use [![NPM version](https://img.shields.io/npm/v/use.svg?style=flat)](https://www.npmjs.com/package/use) [![NPM monthly downloads](https://img.shields.io/npm/dm/use.svg?style=flat)](https://npmjs.org/package/use) [![NPM total downloads](https://img.shields.io/npm/dt/use.svg?style=flat)](https://npmjs.org/package/use) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/use.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/use)
> Easily add plugin support to your node.js application.
+Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
+
## Install
Install with [npm](https://www.npmjs.com/):
@@ -15,33 +17,33 @@ A different take on plugin handling! This is not a middleware system, if you nee
## Usage
```js
-var use = require('use');
+const use = require('use');
```
See the [examples folder](./examples) for usage examples.
## About
-### Related projects
+<details>
+<summary><strong>Contributing</strong></summary>
-* [base-plugins](https://www.npmjs.com/package/base-plugins): Upgrade's plugin support in base applications to allow plugins to be called any time after… [more](https://github.com/node-base/base-plugins) | [homepage](https://github.com/node-base/base-plugins "Upgrade's plugin support in base applications to allow plugins to be called any time after init.")
-* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://github.com/node-base/base) | [homepage](https://github.com/node-base/base "base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common methods, like `set`, `get`, `del` and `use`.")
-* [ware](https://www.npmjs.com/package/ware): Easily create your own middleware layer. | [homepage](https://github.com/segmentio/ware "Easily create your own middleware layer.")
+Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
-### Contributing
+</details>
-Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
+<details>
+<summary><strong>Running Tests</strong></summary>
-### Contributors
+Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
-| **Commits** | **Contributor** |
-| --- | --- |
-| 22 | [jonschlinkert](https://github.com/jonschlinkert) |
-| 7 | [tunnckoCore](https://github.com/tunnckoCore) |
-| 2 | [doowb](https://github.com/doowb) |
-| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
+```sh
+$ npm install && npm test
+```
+
+</details>
-### Building docs
+<details>
+<summary><strong>Building docs</strong></summary>
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
@@ -51,26 +53,38 @@ To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
-### Running tests
+</details>
-Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
+### Related projects
-```sh
-$ npm install && npm test
-```
+You might also be interested in these projects:
+
+* [base-plugins](https://www.npmjs.com/package/base-plugins): Adds 'smart plugin' support to your base application. | [homepage](https://github.com/node-base/base-plugins "Adds 'smart plugin' support to your base application.")
+* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks")
+* [ware](https://www.npmjs.com/package/ware): Easily create your own middleware layer. | [homepage](https://github.com/segmentio/ware "Easily create your own middleware layer.")
+
+### Contributors
+
+| **Commits** | **Contributor** |
+| --- | --- |
+| 37 | [jonschlinkert](https://github.com/jonschlinkert) |
+| 7 | [charlike-old](https://github.com/charlike-old) |
+| 2 | [doowb](https://github.com/doowb) |
+| 2 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
### Author
**Jon Schlinkert**
-* [github/jonschlinkert](https://github.com/jonschlinkert)
-* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
+* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
+* [GitHub Profile](https://github.com/jonschlinkert)
+* [Twitter Profile](https://twitter.com/jonschlinkert)
### License
-Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
+Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
-_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 25, 2017._ \ No newline at end of file
+_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 12, 2018._ \ No newline at end of file
diff --git a/node_modules/use/index.js b/node_modules/use/index.js
index 61cae325f..9a1eb4ee9 100644
--- a/node_modules/use/index.js
+++ b/node_modules/use/index.js
@@ -1,26 +1,21 @@
/*!
* use <https://github.com/jonschlinkert/use>
*
- * Copyright (c) 2015, 2017, Jon Schlinkert.
+ * Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
-var utils = require('./utils');
-
-module.exports = function base(app, opts) {
- if (!utils.isObject(app) && typeof app !== 'function') {
- throw new TypeError('use: expect `app` be an object or function');
- }
-
- if (!utils.isObject(opts)) {
- opts = {};
+module.exports = function base(app, options) {
+ if (!isObject(app) && typeof app !== 'function') {
+ throw new TypeError('expected an object or function');
}
- var prop = utils.isString(opts.prop) ? opts.prop : 'fns';
+ var opts = isObject(options) ? options : {};
+ var prop = typeof opts.prop === 'string' ? opts.prop : 'fns';
if (!Array.isArray(app[prop])) {
- utils.define(app, prop, []);
+ define(app, prop, []);
}
/**
@@ -53,7 +48,7 @@ module.exports = function base(app, opts) {
* @api public
*/
- utils.define(app, 'use', use);
+ define(app, 'use', use);
/**
* Run all plugins on `fns`. Any plugin that returns a function
@@ -69,9 +64,17 @@ module.exports = function base(app, opts) {
* @api public
*/
- utils.define(app, 'run', function(val) {
- if (!utils.isObject(val)) return;
- decorate(val);
+ define(app, 'run', function(val) {
+ if (!isObject(val)) return;
+
+ if (!val.use || !val.run) {
+ define(val, prop, val[prop] || []);
+ define(val, 'use', use);
+ }
+
+ if (!val[prop] || val[prop].indexOf(base) === -1) {
+ val.use(base);
+ }
var self = this || app;
var fns = self[prop];
@@ -89,33 +92,64 @@ module.exports = function base(app, opts) {
* `fns` array to be called by the `run` method.
*/
- function use(fn, options) {
+ function use(type, fn, options) {
+ var offset = 1;
+
+ if (typeof type === 'string' || Array.isArray(type)) {
+ fn = wrap(type, fn);
+ offset++;
+ } else {
+ options = fn;
+ fn = type;
+ }
+
if (typeof fn !== 'function') {
- throw new TypeError('.use expects `fn` be a function');
+ throw new TypeError('expected a function');
}
var self = this || app;
- if (typeof opts.fn === 'function') {
- opts.fn.call(self, self, options);
+ var fns = self[prop];
+
+ var args = [].slice.call(arguments, offset);
+ args.unshift(self);
+
+ if (typeof opts.hook === 'function') {
+ opts.hook.apply(self, args);
}
- var plugin = fn.call(self, self);
- if (typeof plugin === 'function') {
- var fns = self[prop];
- fns.push(plugin);
+ var val = fn.apply(self, args);
+ if (typeof val === 'function' && fns.indexOf(val) === -1) {
+ fns.push(val);
}
return self;
}
/**
- * Ensure the `.use` method exists on `val`
+ * Wrap a named plugin function so that it's only called on objects of the
+ * given `type`
+ *
+ * @param {String} `type`
+ * @param {Function} `fn` Plugin function
+ * @return {Function}
*/
- function decorate(val) {
- if (!val.use || !val.run) {
- base(val);
- }
+ function wrap(type, fn) {
+ return function plugin() {
+ return this.type === type ? fn.apply(this, arguments) : plugin;
+ };
}
return app;
};
+
+function isObject(val) {
+ return val && typeof val === 'object' && !Array.isArray(val);
+}
+
+function define(obj, key, val) {
+ Object.defineProperty(obj, key, {
+ configurable: true,
+ writable: true,
+ value: val
+ });
+}
diff --git a/node_modules/use/package.json b/node_modules/use/package.json
index ffd679c63..b7a3f9a1e 100644
--- a/node_modules/use/package.json
+++ b/node_modules/use/package.json
@@ -1,14 +1,14 @@
{
"name": "use",
"description": "Easily add plugin support to your node.js application.",
- "version": "2.0.2",
+ "version": "3.1.1",
"homepage": "https://github.com/jonschlinkert/use",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"contributors": [
- "<wtgtybhertgeghgtwtg@gmail.com> (https://github.com/wtgtybhertgeghgtwtg)",
- "Brian Woodward <brian.woodward@gmail.com> (https://github.com/doowb)",
- "Charlike Mike Reagent (https://i.am.charlike.online)",
- "Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)"
+ "Brian Woodward (https://twitter.com/doowb)",
+ "Jon Schlinkert (http://twitter.com/jonschlinkert)",
+ "Olsten Larck (https://i.am.charlike.online)",
+ "(https://github.com/wtgtybhertgeghgtwtg)"
],
"repository": "jonschlinkert/use",
"bugs": {
@@ -16,8 +16,7 @@
},
"license": "MIT",
"files": [
- "index.js",
- "utils.js"
+ "index.js"
],
"main": "index.js",
"engines": {
@@ -26,25 +25,29 @@
"scripts": {
"test": "mocha"
},
- "dependencies": {
- "define-property": "^0.2.5",
- "isobject": "^3.0.0",
- "lazy-cache": "^2.0.2"
- },
"devDependencies": {
- "base-plugins": "^0.4.13",
- "extend-shallow": "^2.0.1",
+ "base-plugins": "^1.0.0",
+ "define-property": "^2.0.0",
+ "extend-shallow": "^3.0.1",
"gulp": "^3.9.1",
- "gulp-eslint": "^3.0.1",
- "gulp-format-md": "^0.1.11",
- "gulp-istanbul": "^1.1.1",
- "gulp-mocha": "^4.0.1",
- "mocha": "^3.2.0"
+ "gulp-eslint": "^4.0.0",
+ "gulp-format-md": "^1.0.0",
+ "gulp-istanbul": "^1.1.2",
+ "gulp-mocha": "^3.0.1",
+ "mocha": "^4.0.1"
},
"keywords": [
"use"
],
"verb": {
+ "toc": false,
+ "layout": "default",
+ "tasks": [
+ "readme"
+ ],
+ "plugins": [
+ "gulp-format-md"
+ ],
"related": {
"list": [
"base",
@@ -56,14 +59,6 @@
"verb",
"ware"
],
- "toc": false,
- "layout": "default",
- "tasks": [
- "readme"
- ],
- "plugins": [
- "gulp-format-md"
- ],
"lint": {
"reflinks": true
}
diff --git a/node_modules/use/utils.js b/node_modules/use/utils.js
deleted file mode 100644
index bea907b63..000000000
--- a/node_modules/use/utils.js
+++ /dev/null
@@ -1,23 +0,0 @@
-'use strict';
-
-var utils = require('lazy-cache')(require);
-var fn = require;
-require = utils; // eslint-disable-line
-
-/**
- * Lazily required module dependencies
- */
-
-require('define-property', 'define');
-require('isobject', 'isObject');
-require = fn; // eslint-disable-line
-
-utils.isString = function(val) {
- return val && typeof val === 'string';
-};
-
-/**
- * Expose `utils` modules
- */
-
-module.exports = utils;