summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/trough
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/trough')
-rw-r--r--tools/node_modules/eslint/node_modules/trough/LICENSE21
-rw-r--r--tools/node_modules/eslint/node_modules/trough/index.js133
-rw-r--r--tools/node_modules/eslint/node_modules/trough/package.json100
-rw-r--r--tools/node_modules/eslint/node_modules/trough/readme.md305
4 files changed, 559 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/trough/LICENSE b/tools/node_modules/eslint/node_modules/trough/LICENSE
new file mode 100644
index 0000000000..3f0166f62b
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/trough/LICENSE
@@ -0,0 +1,21 @@
+(The MIT License)
+
+Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
+
+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/tools/node_modules/eslint/node_modules/trough/index.js b/tools/node_modules/eslint/node_modules/trough/index.js
new file mode 100644
index 0000000000..a041e8c257
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/trough/index.js
@@ -0,0 +1,133 @@
+'use strict';
+
+/* Expose. */
+module.exports = trough;
+
+/* Methods. */
+var slice = [].slice;
+
+/* Create new middleware. */
+function trough() {
+ var fns = [];
+ var middleware = {};
+
+ middleware.run = run;
+ middleware.use = use;
+
+ return middleware;
+
+ /* Run `fns`. Last argument must be
+ * a completion handler. */
+ function run() {
+ var index = -1;
+ var input = slice.call(arguments, 0, -1);
+ var done = arguments[arguments.length - 1];
+
+ if (typeof done !== 'function') {
+ throw new Error('Expected function as last argument, not ' + done);
+ }
+
+ next.apply(null, [null].concat(input));
+
+ /* Run the next `fn`, if any. */
+ function next(err) {
+ var fn = fns[++index];
+ var params = slice.call(arguments, 0);
+ var values = params.slice(1);
+ var length = input.length;
+ var pos = -1;
+
+ if (err) {
+ done(err);
+ return;
+ }
+
+ /* Copy non-nully input into values. */
+ while (++pos < length) {
+ if (values[pos] === null || values[pos] === undefined) {
+ values[pos] = input[pos];
+ }
+ }
+
+ input = values;
+
+ /* Next or done. */
+ if (fn) {
+ wrap(fn, next).apply(null, input);
+ } else {
+ done.apply(null, [null].concat(input));
+ }
+ }
+ }
+
+ /* Add `fn` to the list. */
+ function use(fn) {
+ if (typeof fn !== 'function') {
+ throw new Error('Expected `fn` to be a function, not ' + fn);
+ }
+
+ fns.push(fn);
+
+ return middleware;
+ }
+}
+
+/* Wrap `fn`. Can be sync or async; return a promise,
+ * receive a completion handler, return new values and
+ * errors. */
+function wrap(fn, next) {
+ var invoked;
+
+ return wrapped;
+
+ function wrapped() {
+ var params = slice.call(arguments, 0);
+ var callback = fn.length > params.length;
+ var result;
+
+ if (callback) {
+ params.push(done);
+ }
+
+ try {
+ result = fn.apply(null, params);
+ } catch (err) {
+ /* Well, this is quite the pickle. `fn` received
+ * a callback and invoked it (thus continuing the
+ * pipeline), but later also threw an error.
+ * We’re not about to restart the pipeline again,
+ * so the only thing left to do is to throw the
+ * thing instea. */
+ if (callback && invoked) {
+ throw err;
+ }
+
+ return done(err);
+ }
+
+ if (!callback) {
+ if (result && typeof result.then === 'function') {
+ result.then(then, done);
+ } else if (result instanceof Error) {
+ done(result);
+ } else {
+ then(result);
+ }
+ }
+ }
+
+ /* Invoke `next`, only once. */
+ function done() {
+ if (!invoked) {
+ invoked = true;
+
+ next.apply(null, arguments);
+ }
+ }
+
+ /* Invoke `done` with one value.
+ * Tracks if an error is passed, too. */
+ function then(value) {
+ done(null, value);
+ }
+}
diff --git a/tools/node_modules/eslint/node_modules/trough/package.json b/tools/node_modules/eslint/node_modules/trough/package.json
new file mode 100644
index 0000000000..7e0478f36a
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/trough/package.json
@@ -0,0 +1,100 @@
+{
+ "_from": "trough@^1.0.0",
+ "_id": "trough@1.0.1",
+ "_inBundle": false,
+ "_integrity": "sha1-qf2LA5Swro//guBjOgo2zK1bX4Y=",
+ "_location": "/trough",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "trough@^1.0.0",
+ "name": "trough",
+ "escapedName": "trough",
+ "rawSpec": "^1.0.0",
+ "saveSpec": null,
+ "fetchSpec": "^1.0.0"
+ },
+ "_requiredBy": [
+ "/unified"
+ ],
+ "_resolved": "https://registry.npmjs.org/trough/-/trough-1.0.1.tgz",
+ "_shasum": "a9fd8b0394b0ae8fff82e0633a0a36ccad5b5f86",
+ "_spec": "trough@^1.0.0",
+ "_where": "/Users/cjihrig/iojs/node/tools/eslint-tmp/node_modules/eslint/node_modules/unified",
+ "author": {
+ "name": "Titus Wormer",
+ "email": "tituswormer@gmail.com",
+ "url": "http://wooorm.com"
+ },
+ "bugs": {
+ "url": "https://github.com/wooorm/trough/issues"
+ },
+ "bundleDependencies": false,
+ "contributors": [
+ {
+ "name": "Titus Wormer",
+ "email": "tituswormer@gmail.com",
+ "url": "http://wooorm.com"
+ }
+ ],
+ "dependencies": {},
+ "deprecated": false,
+ "description": "Middleware: a channel used to convey a liquid",
+ "devDependencies": {
+ "browserify": "^14.1.0",
+ "esmangle": "^1.0.0",
+ "nyc": "^11.0.0",
+ "remark-cli": "^3.0.0",
+ "remark-preset-wooorm": "^3.0.0",
+ "tape": "^4.4.0",
+ "xo": "^0.18.0"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/wooorm/trough#readme",
+ "keywords": [
+ "middleware",
+ "ware"
+ ],
+ "license": "MIT",
+ "name": "trough",
+ "nyc": {
+ "check-coverage": true,
+ "lines": 100,
+ "functions": 100,
+ "branches": 100
+ },
+ "remarkConfig": {
+ "plugins": [
+ "preset-wooorm"
+ ]
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/wooorm/trough.git"
+ },
+ "scripts": {
+ "build": "npm run build-md && npm run build-bundle && npm run build-mangle",
+ "build-bundle": "browserify index.js -s trough > trough.js",
+ "build-mangle": "esmangle trough.js > trough.min.js",
+ "build-md": "remark . -qfo",
+ "lint": "xo",
+ "test": "npm run build && npm run lint && npm run test-coverage",
+ "test-api": "node test",
+ "test-coverage": "nyc --reporter lcov tape test.js"
+ },
+ "version": "1.0.1",
+ "xo": {
+ "space": true,
+ "esnext": false,
+ "rules": {
+ "guard-for-in": "off",
+ "unicorn/prefer-type-error": "off"
+ },
+ "ignores": [
+ "trough.js"
+ ]
+ }
+}
diff --git a/tools/node_modules/eslint/node_modules/trough/readme.md b/tools/node_modules/eslint/node_modules/trough/readme.md
new file mode 100644
index 0000000000..3dc62650e9
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/trough/readme.md
@@ -0,0 +1,305 @@
+# trough [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
+
+> **trough** /trôf/ — a channel used to convey a liquid.
+
+`trough` is like [`ware`][ware] with less sugar, and middleware
+functions can change the input of the next.
+
+## Installation
+
+[npm][]:
+
+```bash
+npm install trough
+```
+
+## Usage
+
+```js
+var fs = require('fs');
+var path = require('path');
+var trough = require('trough');
+
+var pipeline = trough()
+ .use(function (fileName) {
+ console.log('Checking... ' + fileName);
+ })
+ .use(function (fileName) {
+ return path.join(process.cwd(), fileName);
+ })
+ .use(function (filePath, next) {
+ fs.stat(filePath, function (err, stats) {
+ next(err, {filePath: filePath, stats: stats});
+ });
+ })
+ .use(function (ctx, next) {
+ if (ctx.stats.isFile()) {
+ fs.readFile(ctx.filePath, next);
+ } else {
+ next(new Error('Expected file'));
+ }
+ });
+
+pipeline.run('readme.md', console.log);
+pipeline.run('node_modules', console.log);
+```
+
+Yields:
+
+```txt
+Checking... readme.md
+Checking... node_modules
+Error: Expected file
+ at ~/example.js:21:12
+ at wrapped (~/node_modules/trough/index.js:93:19)
+ at next (~/node_modules/trough/index.js:56:24)
+ at done (~/node_modules/trough/index.js:124:12)
+ at ~/node_modules/example.js:14:7
+ at FSReqWrap.oncomplete (fs.js:153:5)
+null <Buffer 23 20 74 72 6f 75 67 68 20 5b 21 5b 42 75 69 6c 64 20 53 74 61 74 75 73 5d 5b 74 72 61 76 69 73 2d 62 61 64 67 65 5d 5d 5b 74 72 61 76 69 73 5d 20 5b ... >
+```
+
+## API
+
+### `trough()`
+
+Create a new [`Trough`][trough].
+
+### `Trough`
+
+A pipeline.
+
+### `Trough#run([input..., ]done)`
+
+Run the pipeline (all [`use()`][use]d middleware). Invokes [`done`][done]
+on completion with either an error or the output of the last middleware
+
+> Note! as the length of input defines whether [async][] function
+> get a `next` function, it’s recommended to keep `input` at one
+> value normally.
+
+#### `function done(err?, [output...])`
+
+The final handler passed to [`run()`][run], invoked with an error
+if a [middleware function][fn] rejected, passed, or threw one, or
+the output of the last middleware function.
+
+### `Trough#use(fn)`
+
+Add `fn`, a [middleware function][fn], to the pipeline.
+
+#### `function fn([input..., ][next])`
+
+A middleware function invoked with the output of its predecessor.
+
+##### Synchronous
+
+If `fn` returns or throws an error, the pipeline fails and `done` is
+invoked with that error.
+
+If `fn` returns a value (neither `null` nor `undefined`), the first
+`input` of the next function is set to that value (all other `input`
+is passed through).
+
+###### Example
+
+The following example shows how returning an error stops the pipeline:
+
+```js
+var trough = require('trough');
+
+trough()
+ .use(function (val) {
+ return new Error('Got: ' + val);
+ })
+ .run('some value', console.log);
+```
+
+Yields:
+
+```txt
+Error: Got: some value
+ at ~/example.js:5:12
+ ...
+```
+
+The following example shows how throwing an error stops the pipeline:
+
+```js
+var trough = require('trough');
+
+trough()
+ .use(function (val) {
+ throw new Error('Got: ' + val);
+ })
+ .run('more value', console.log);
+```
+
+Yields:
+
+```txt
+Error: Got: more value
+ at ~/example.js:5:11
+ ...
+```
+
+The following example shows how the first output can be modified:
+
+```js
+var trough = require('trough');
+
+trough()
+ .use(function (val) {
+ return 'even ' + val;
+ })
+ .run('more value', 'untouched', console.log);
+```
+
+Yields:
+
+```txt
+null 'even more value' 'untouched'
+```
+
+##### Promise
+
+If `fn` returns a promise, and that promise rejects, the pipeline fails
+and `done` is invoked with the rejected value.
+
+If `fn` returns a promise, and that promise resolves with a value
+(neither `null` nor `undefined`), the first `input` of the next function
+is set to that value (all other `input` is passed through).
+
+###### Example
+
+The following example shows how rejecting a promise stops the pipeline:
+
+```js
+var trough = require('trough');
+
+trough()
+ .use(function (val) {
+ return new Promise(function (resolve, reject) {
+ reject('Got: ' + val);
+ });
+ })
+ .run('val', console.log);
+```
+
+Yields:
+
+```txt
+Got: val
+```
+
+The following example shows how the input isn’t touched by resolving
+to `null`.
+
+```js
+var trough = require('trough');
+
+trough()
+ .use(function () {
+ return new Promise(function (resolve) {
+ setTimeout(function () {
+ resolve(null);
+ }, 100);
+ });
+ })
+ .run('Input', console.log);
+```
+
+Yields:
+
+```txt
+null 'Input'
+```
+
+##### Asynchronous
+
+If `fn` accepts one more argument than the given `input`, a `next`
+function is given (after the input). `next` must be called, but doesn’t
+have to be called async.
+
+If `next` is given a value (neither `null` nor `undefined`) as its first
+argument, the pipeline fails and `done` is invoked with that value.
+
+If `next` is given no value (either `null` or `undefined`) as the first
+argument, all following non-nully values change the input of the following
+function, and all nully values default to the `input`.
+
+###### Example
+
+The following example shows how passing a first argument stops the
+pipeline:
+
+```js
+var trough = require('trough');
+
+trough()
+ .use(function (val, next) {
+ next(new Error('Got: ' + val));
+ })
+ .run('val', console.log);
+```
+
+Yields:
+
+```txt
+Error: Got: val
+ at ~/example.js:5:10
+```
+
+The following example shows how more values than the input are passed.
+
+```js
+var trough = require('trough');
+
+trough()
+ .use(function (val, next) {
+ setTimeout(function () {
+ next(null, null, 'values');
+ }, 100);
+ })
+ .run('some', console.log);
+```
+
+Yields:
+
+```txt
+null 'some' 'values'
+```
+
+## License
+
+[MIT][license] © [Titus Wormer][author]
+
+<!-- Definitions -->
+
+[travis-badge]: https://img.shields.io/travis/wooorm/trough.svg
+
+[travis]: https://travis-ci.org/wooorm/trough
+
+[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/trough.svg
+
+[codecov]: https://codecov.io/github/wooorm/trough
+
+[npm]: https://docs.npmjs.com/cli/install
+
+[license]: LICENSE
+
+[author]: http://wooorm.com
+
+[ware]: https://github.com/segmentio/ware
+
+[trough]: #trough-1
+
+[use]: #troughusefn
+
+[run]: #troughruninput-done
+
+[fn]: #function-fninput-next
+
+[done]: #function-doneerr-output
+
+[async]: #asynchronous