summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/co
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/co')
-rw-r--r--tools/node_modules/eslint/node_modules/co/LICENSE22
-rw-r--r--tools/node_modules/eslint/node_modules/co/Readme.md212
-rw-r--r--tools/node_modules/eslint/node_modules/co/index.js237
-rw-r--r--tools/node_modules/eslint/node_modules/co/package.json66
4 files changed, 537 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/co/LICENSE b/tools/node_modules/eslint/node_modules/co/LICENSE
new file mode 100644
index 0000000000..92faba5db3
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/co/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
+
+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/co/Readme.md b/tools/node_modules/eslint/node_modules/co/Readme.md
new file mode 100644
index 0000000000..c1d4882a13
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/co/Readme.md
@@ -0,0 +1,212 @@
+# co
+
+[![Gitter][gitter-image]][gitter-url]
+[![NPM version][npm-image]][npm-url]
+[![Build status][travis-image]][travis-url]
+[![Test coverage][coveralls-image]][coveralls-url]
+[![Downloads][downloads-image]][downloads-url]
+
+ Generator based control flow goodness for nodejs and the browser,
+ using promises, letting you write non-blocking code in a nice-ish way.
+
+## Co v4
+
+ `co@4.0.0` has been released, which now relies on promises.
+ It is a stepping stone towards [ES7 async/await](https://github.com/lukehoban/ecmascript-asyncawait).
+ The primary API change is how `co()` is invoked.
+ Before, `co` returned a "thunk", which you then called with a callback and optional arguments.
+ Now, `co()` returns a promise.
+
+```js
+co(function* () {
+ var result = yield Promise.resolve(true);
+ return result;
+}).then(function (value) {
+ console.log(value);
+}, function (err) {
+ console.error(err.stack);
+});
+```
+
+ If you want to convert a `co`-generator-function into a regular function that returns a promise,
+ you now use `co.wrap(fn*)`.
+
+```js
+var fn = co.wrap(function* (val) {
+ return yield Promise.resolve(val);
+});
+
+fn(true).then(function (val) {
+
+});
+```
+
+## Platform Compatibility
+
+ `co@4+` requires a `Promise` implementation.
+ For versions of node `< 0.11` and for many older browsers,
+ you should/must include your own `Promise` polyfill.
+
+ When using node 0.11.x or greater, you must use the `--harmony-generators`
+ flag or just `--harmony` to get access to generators.
+
+ When using node 0.10.x and lower or browsers without generator support,
+ you must use [gnode](https://github.com/TooTallNate/gnode) and/or [regenerator](http://facebook.github.io/regenerator/).
+
+ io.js is supported out of the box, you can use `co` without flags or polyfills.
+
+## Installation
+
+```
+$ npm install co
+```
+
+## Associated libraries
+
+Any library that returns promises work well with `co`.
+
+- [mz](https://github.com/normalize/mz) - wrap all of node's code libraries as promises.
+
+View the [wiki](https://github.com/visionmedia/co/wiki) for more libraries.
+
+## Examples
+
+```js
+var co = require('co');
+
+co(function *(){
+ // yield any promise
+ var result = yield Promise.resolve(true);
+}).catch(onerror);
+
+co(function *(){
+ // resolve multiple promises in parallel
+ var a = Promise.resolve(1);
+ var b = Promise.resolve(2);
+ var c = Promise.resolve(3);
+ var res = yield [a, b, c];
+ console.log(res);
+ // => [1, 2, 3]
+}).catch(onerror);
+
+// errors can be try/catched
+co(function *(){
+ try {
+ yield Promise.reject(new Error('boom'));
+ } catch (err) {
+ console.error(err.message); // "boom"
+ }
+}).catch(onerror);
+
+function onerror(err) {
+ // log any uncaught errors
+ // co will not throw any errors you do not handle!!!
+ // HANDLE ALL YOUR ERRORS!!!
+ console.error(err.stack);
+}
+```
+
+## Yieldables
+
+ The `yieldable` objects currently supported are:
+
+ - promises
+ - thunks (functions)
+ - array (parallel execution)
+ - objects (parallel execution)
+ - generators (delegation)
+ - generator functions (delegation)
+
+Nested `yieldable` objects are supported, meaning you can nest
+promises within objects within arrays, and so on!
+
+### Promises
+
+[Read more on promises!](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
+
+### Thunks
+
+Thunks are functions that only have a single argument, a callback.
+Thunk support only remains for backwards compatibility and may
+be removed in future versions of `co`.
+
+### Arrays
+
+`yield`ing an array will resolve all the `yieldables` in parallel.
+
+```js
+co(function* () {
+ var res = yield [
+ Promise.resolve(1),
+ Promise.resolve(2),
+ Promise.resolve(3),
+ ];
+ console.log(res); // => [1, 2, 3]
+}).catch(onerror);
+```
+
+### Objects
+
+Just like arrays, objects resolve all `yieldable`s in parallel.
+
+```js
+co(function* () {
+ var res = yield {
+ 1: Promise.resolve(1),
+ 2: Promise.resolve(2),
+ };
+ console.log(res); // => { 1: 1, 2: 2 }
+}).catch(onerror);
+```
+
+### Generators and Generator Functions
+
+Any generator or generator function you can pass into `co`
+can be yielded as well. This should generally be avoided
+as we should be moving towards spec-compliant `Promise`s instead.
+
+## API
+
+### co(fn*).then( val => )
+
+Returns a promise that resolves a generator, generator function,
+or any function that returns a generator.
+
+```js
+co(function* () {
+ return yield Promise.resolve(true);
+}).then(function (val) {
+ console.log(val);
+}, function (err) {
+ console.error(err.stack);
+});
+```
+
+### var fn = co.wrap(fn*)
+
+Convert a generator into a regular function that returns a `Promise`.
+
+```js
+var fn = co.wrap(function* (val) {
+ return yield Promise.resolve(val);
+});
+
+fn(true).then(function (val) {
+
+});
+```
+
+## License
+
+ MIT
+
+[npm-image]: https://img.shields.io/npm/v/co.svg?style=flat-square
+[npm-url]: https://npmjs.org/package/co
+[travis-image]: https://img.shields.io/travis/tj/co.svg?style=flat-square
+[travis-url]: https://travis-ci.org/tj/co
+[coveralls-image]: https://img.shields.io/coveralls/tj/co.svg?style=flat-square
+[coveralls-url]: https://coveralls.io/r/tj/co
+[downloads-image]: http://img.shields.io/npm/dm/co.svg?style=flat-square
+[downloads-url]: https://npmjs.org/package/co
+[gitter-image]: https://badges.gitter.im/Join%20Chat.svg
+[gitter-url]: https://gitter.im/tj/co?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
diff --git a/tools/node_modules/eslint/node_modules/co/index.js b/tools/node_modules/eslint/node_modules/co/index.js
new file mode 100644
index 0000000000..87ba8ba8b4
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/co/index.js
@@ -0,0 +1,237 @@
+
+/**
+ * slice() reference.
+ */
+
+var slice = Array.prototype.slice;
+
+/**
+ * Expose `co`.
+ */
+
+module.exports = co['default'] = co.co = co;
+
+/**
+ * Wrap the given generator `fn` into a
+ * function that returns a promise.
+ * This is a separate function so that
+ * every `co()` call doesn't create a new,
+ * unnecessary closure.
+ *
+ * @param {GeneratorFunction} fn
+ * @return {Function}
+ * @api public
+ */
+
+co.wrap = function (fn) {
+ createPromise.__generatorFunction__ = fn;
+ return createPromise;
+ function createPromise() {
+ return co.call(this, fn.apply(this, arguments));
+ }
+};
+
+/**
+ * Execute the generator function or a generator
+ * and return a promise.
+ *
+ * @param {Function} fn
+ * @return {Promise}
+ * @api public
+ */
+
+function co(gen) {
+ var ctx = this;
+ var args = slice.call(arguments, 1)
+
+ // we wrap everything in a promise to avoid promise chaining,
+ // which leads to memory leak errors.
+ // see https://github.com/tj/co/issues/180
+ return new Promise(function(resolve, reject) {
+ if (typeof gen === 'function') gen = gen.apply(ctx, args);
+ if (!gen || typeof gen.next !== 'function') return resolve(gen);
+
+ onFulfilled();
+
+ /**
+ * @param {Mixed} res
+ * @return {Promise}
+ * @api private
+ */
+
+ function onFulfilled(res) {
+ var ret;
+ try {
+ ret = gen.next(res);
+ } catch (e) {
+ return reject(e);
+ }
+ next(ret);
+ }
+
+ /**
+ * @param {Error} err
+ * @return {Promise}
+ * @api private
+ */
+
+ function onRejected(err) {
+ var ret;
+ try {
+ ret = gen.throw(err);
+ } catch (e) {
+ return reject(e);
+ }
+ next(ret);
+ }
+
+ /**
+ * Get the next value in the generator,
+ * return a promise.
+ *
+ * @param {Object} ret
+ * @return {Promise}
+ * @api private
+ */
+
+ function next(ret) {
+ if (ret.done) return resolve(ret.value);
+ var value = toPromise.call(ctx, ret.value);
+ if (value && isPromise(value)) return value.then(onFulfilled, onRejected);
+ return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, '
+ + 'but the following object was passed: "' + String(ret.value) + '"'));
+ }
+ });
+}
+
+/**
+ * Convert a `yield`ed value into a promise.
+ *
+ * @param {Mixed} obj
+ * @return {Promise}
+ * @api private
+ */
+
+function toPromise(obj) {
+ if (!obj) return obj;
+ if (isPromise(obj)) return obj;
+ if (isGeneratorFunction(obj) || isGenerator(obj)) return co.call(this, obj);
+ if ('function' == typeof obj) return thunkToPromise.call(this, obj);
+ if (Array.isArray(obj)) return arrayToPromise.call(this, obj);
+ if (isObject(obj)) return objectToPromise.call(this, obj);
+ return obj;
+}
+
+/**
+ * Convert a thunk to a promise.
+ *
+ * @param {Function}
+ * @return {Promise}
+ * @api private
+ */
+
+function thunkToPromise(fn) {
+ var ctx = this;
+ return new Promise(function (resolve, reject) {
+ fn.call(ctx, function (err, res) {
+ if (err) return reject(err);
+ if (arguments.length > 2) res = slice.call(arguments, 1);
+ resolve(res);
+ });
+ });
+}
+
+/**
+ * Convert an array of "yieldables" to a promise.
+ * Uses `Promise.all()` internally.
+ *
+ * @param {Array} obj
+ * @return {Promise}
+ * @api private
+ */
+
+function arrayToPromise(obj) {
+ return Promise.all(obj.map(toPromise, this));
+}
+
+/**
+ * Convert an object of "yieldables" to a promise.
+ * Uses `Promise.all()` internally.
+ *
+ * @param {Object} obj
+ * @return {Promise}
+ * @api private
+ */
+
+function objectToPromise(obj){
+ var results = new obj.constructor();
+ var keys = Object.keys(obj);
+ var promises = [];
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ var promise = toPromise.call(this, obj[key]);
+ if (promise && isPromise(promise)) defer(promise, key);
+ else results[key] = obj[key];
+ }
+ return Promise.all(promises).then(function () {
+ return results;
+ });
+
+ function defer(promise, key) {
+ // predefine the key in the result
+ results[key] = undefined;
+ promises.push(promise.then(function (res) {
+ results[key] = res;
+ }));
+ }
+}
+
+/**
+ * Check if `obj` is a promise.
+ *
+ * @param {Object} obj
+ * @return {Boolean}
+ * @api private
+ */
+
+function isPromise(obj) {
+ return 'function' == typeof obj.then;
+}
+
+/**
+ * Check if `obj` is a generator.
+ *
+ * @param {Mixed} obj
+ * @return {Boolean}
+ * @api private
+ */
+
+function isGenerator(obj) {
+ return 'function' == typeof obj.next && 'function' == typeof obj.throw;
+}
+
+/**
+ * Check if `obj` is a generator function.
+ *
+ * @param {Mixed} obj
+ * @return {Boolean}
+ * @api private
+ */
+function isGeneratorFunction(obj) {
+ var constructor = obj.constructor;
+ if (!constructor) return false;
+ if ('GeneratorFunction' === constructor.name || 'GeneratorFunction' === constructor.displayName) return true;
+ return isGenerator(constructor.prototype);
+}
+
+/**
+ * Check for plain object.
+ *
+ * @param {Mixed} val
+ * @return {Boolean}
+ * @api private
+ */
+
+function isObject(val) {
+ return Object == val.constructor;
+}
diff --git a/tools/node_modules/eslint/node_modules/co/package.json b/tools/node_modules/eslint/node_modules/co/package.json
new file mode 100644
index 0000000000..e8d592d206
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/co/package.json
@@ -0,0 +1,66 @@
+{
+ "_from": "co@^4.6.0",
+ "_id": "co@4.6.0",
+ "_inBundle": false,
+ "_integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
+ "_location": "/eslint/co",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "co@^4.6.0",
+ "name": "co",
+ "escapedName": "co",
+ "rawSpec": "^4.6.0",
+ "saveSpec": null,
+ "fetchSpec": "^4.6.0"
+ },
+ "_requiredBy": [
+ "/eslint/ajv"
+ ],
+ "_resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
+ "_shasum": "6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184",
+ "_spec": "co@^4.6.0",
+ "_where": "/Users/cjihrig/iojs/node/tools/eslint-tmp/node_modules/eslint/node_modules/ajv",
+ "bugs": {
+ "url": "https://github.com/tj/co/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "generator async control flow goodness",
+ "devDependencies": {
+ "browserify": "^10.0.0",
+ "istanbul-harmony": "0",
+ "mocha": "^2.0.0",
+ "mz": "^1.0.2"
+ },
+ "engines": {
+ "iojs": ">= 1.0.0",
+ "node": ">= 0.12.0"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/tj/co#readme",
+ "keywords": [
+ "async",
+ "flow",
+ "generator",
+ "coro",
+ "coroutine"
+ ],
+ "license": "MIT",
+ "name": "co",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/tj/co.git"
+ },
+ "scripts": {
+ "browserify": "browserify index.js -o ./co-browser.js -s co",
+ "prepublish": "npm run browserify",
+ "test": "mocha --harmony",
+ "test-cov": "node --harmony node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter dot",
+ "test-travis": "node --harmony node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --reporter dot"
+ },
+ "version": "4.6.0"
+}