aboutsummaryrefslogtreecommitdiff
path: root/node_modules/use
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/use
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
downloadwallet-core-363723fc84f7b8477592e0105aeb331ec9a017af.tar.xz
node_modules
Diffstat (limited to 'node_modules/use')
-rw-r--r--node_modules/use/LICENSE21
-rw-r--r--node_modules/use/README.md76
-rw-r--r--node_modules/use/index.js121
-rw-r--r--node_modules/use/package.json71
-rw-r--r--node_modules/use/utils.js23
5 files changed, 312 insertions, 0 deletions
diff --git a/node_modules/use/LICENSE b/node_modules/use/LICENSE
new file mode 100644
index 000000000..83b56e709
--- /dev/null
+++ b/node_modules/use/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015-2017, 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
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node_modules/use/README.md b/node_modules/use/README.md
new file mode 100644
index 000000000..4f9067e19
--- /dev/null
+++ b/node_modules/use/README.md
@@ -0,0 +1,76 @@
+# 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.
+
+## Install
+
+Install with [npm](https://www.npmjs.com/):
+
+```sh
+$ npm install --save use
+```
+
+A different take on plugin handling! This is not a middleware system, if you need something that handles async middleware, [ware](https://github.com/segmentio/ware) is great for that.
+
+## Usage
+
+```js
+var use = require('use');
+```
+
+See the [examples folder](./examples) for usage examples.
+
+## About
+
+### Related projects
+
+* [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.")
+
+### Contributing
+
+Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
+
+### Contributors
+
+| **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) |
+
+### Building docs
+
+_(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.)_
+
+To generate the readme, run the following command:
+
+```sh
+$ npm install -g verbose/verb#dev verb-generate-readme && verb
+```
+
+### Running tests
+
+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:
+
+```sh
+$ npm install && npm test
+```
+
+### Author
+
+**Jon Schlinkert**
+
+* [github/jonschlinkert](https://github.com/jonschlinkert)
+* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
+
+### License
+
+Copyright © 2017, [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
diff --git a/node_modules/use/index.js b/node_modules/use/index.js
new file mode 100644
index 000000000..61cae325f
--- /dev/null
+++ b/node_modules/use/index.js
@@ -0,0 +1,121 @@
+/*!
+ * use <https://github.com/jonschlinkert/use>
+ *
+ * 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 = {};
+ }
+
+ var prop = utils.isString(opts.prop) ? opts.prop : 'fns';
+ if (!Array.isArray(app[prop])) {
+ utils.define(app, prop, []);
+ }
+
+ /**
+ * Define a plugin function to be passed to use. The only
+ * parameter exposed to the plugin is `app`, the object or function.
+ * passed to `use(app)`. `app` is also exposed as `this` in plugins.
+ *
+ * Additionally, **if a plugin returns a function, the function will
+ * be pushed onto the `fns` array**, allowing the plugin to be
+ * called at a later point by the `run` method.
+ *
+ * ```js
+ * var use = require('use');
+ *
+ * // define a plugin
+ * function foo(app) {
+ * // do stuff
+ * }
+ *
+ * var app = function(){};
+ * use(app);
+ *
+ * // register plugins
+ * app.use(foo);
+ * app.use(bar);
+ * app.use(baz);
+ * ```
+ * @name .use
+ * @param {Function} `fn` plugin function to call
+ * @api public
+ */
+
+ utils.define(app, 'use', use);
+
+ /**
+ * Run all plugins on `fns`. Any plugin that returns a function
+ * when called by `use` is pushed onto the `fns` array.
+ *
+ * ```js
+ * var config = {};
+ * app.run(config);
+ * ```
+ * @name .run
+ * @param {Object} `value` Object to be modified by plugins.
+ * @return {Object} Returns the object passed to `run`
+ * @api public
+ */
+
+ utils.define(app, 'run', function(val) {
+ if (!utils.isObject(val)) return;
+ decorate(val);
+
+ var self = this || app;
+ var fns = self[prop];
+ var len = fns.length;
+ var idx = -1;
+
+ while (++idx < len) {
+ val.use(fns[idx]);
+ }
+ return val;
+ });
+
+ /**
+ * Call plugin `fn`. If a function is returned push it into the
+ * `fns` array to be called by the `run` method.
+ */
+
+ function use(fn, options) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('.use expects `fn` be a function');
+ }
+
+ var self = this || app;
+ if (typeof opts.fn === 'function') {
+ opts.fn.call(self, self, options);
+ }
+
+ var plugin = fn.call(self, self);
+ if (typeof plugin === 'function') {
+ var fns = self[prop];
+ fns.push(plugin);
+ }
+ return self;
+ }
+
+ /**
+ * Ensure the `.use` method exists on `val`
+ */
+
+ function decorate(val) {
+ if (!val.use || !val.run) {
+ base(val);
+ }
+ }
+
+ return app;
+};
diff --git a/node_modules/use/package.json b/node_modules/use/package.json
new file mode 100644
index 000000000..ffd679c63
--- /dev/null
+++ b/node_modules/use/package.json
@@ -0,0 +1,71 @@
+{
+ "name": "use",
+ "description": "Easily add plugin support to your node.js application.",
+ "version": "2.0.2",
+ "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)"
+ ],
+ "repository": "jonschlinkert/use",
+ "bugs": {
+ "url": "https://github.com/jonschlinkert/use/issues"
+ },
+ "license": "MIT",
+ "files": [
+ "index.js",
+ "utils.js"
+ ],
+ "main": "index.js",
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "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",
+ "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"
+ },
+ "keywords": [
+ "use"
+ ],
+ "verb": {
+ "related": {
+ "list": [
+ "base",
+ "base-plugins",
+ "ware"
+ ]
+ },
+ "reflinks": [
+ "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
new file mode 100644
index 000000000..bea907b63
--- /dev/null
+++ b/node_modules/use/utils.js
@@ -0,0 +1,23 @@
+'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;