node-gulp-4.0.2+~cs38.20.35/000077500000000000000000000000001415667007300150405ustar00rootroot00000000000000node-gulp-4.0.2+~cs38.20.35/.editorconfig000066400000000000000000000003261415667007300175160ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf [*.md] trim_trailing_whitespace = false node-gulp-4.0.2+~cs38.20.35/.eslintrc000066400000000000000000000000301415667007300166550ustar00rootroot00000000000000{ "extends": "gulp" } node-gulp-4.0.2+~cs38.20.35/.gitattributes000066400000000000000000000000161415667007300177300ustar00rootroot00000000000000* text eol=lf node-gulp-4.0.2+~cs38.20.35/.jscsrc000066400000000000000000000000271415667007300163270ustar00rootroot00000000000000{ "preset": "gulp" } node-gulp-4.0.2+~cs38.20.35/.travis.yml000066400000000000000000000001711415667007300171500ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '5' - '4' - '0.12' - '0.10' after_script: - npm run coveralls node-gulp-4.0.2+~cs38.20.35/LICENSE000066400000000000000000000021421415667007300160440ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014 Blaine Bublitz, Eric Schoffstall and other contributors 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. node-gulp-4.0.2+~cs38.20.35/README.md000066400000000000000000000211301415667007300163140ustar00rootroot00000000000000

# now-and-later [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] Map over an array or object of values in parallel or series, passing each through the async iterator, with optional lifecycle hooks. ## Usage ```js var nal = require('now-and-later'); function iterator(value, key, cb){ // called with each value in sequence // also passes the key cb(null, value * 2) } function create(value, key){ // called at the beginning of every iteration // return a storage object to be passed to each lifecycle method return { key: key, value: value }; } function before(storage){ // called before the iterator function of every iteration // receives the storage returned from `create` } function after(result, storage){ // called after a success occurs in the iterator function of any iteration // receives the `result` of the iterator and the storage returned from `create` } function error(error, storage){ // called after an error occurs in the iterator function of any iteration // receives the `error` of the iterator and the storage returned from `create` } function done(error, results) { // called after all iterations complete or an error occurs in an iterator // receives an `error` if one occurred and all results (or partial results upon error) of the iterators } /* Calling mapSeries with an object can't guarantee order It uses Object.keys to get an order It is better to use an array if order must be guaranteed */ nal.mapSeries([1, 2, 3], iterator, { create: create, before: before, after: after, error: error }, done); nal.map({ iter1: 1, iter2: 2 }, iterator, { create: create, before: before, after: after, error: error }, done); ``` ## API ### `map(values, iterator[, extensions][, callback])` Takes an object or array of `values` and an `iterator` function to execute with each value. Optionally, takes an `extensions` object and a `callback` function that is called upon completion of the iterations. All iterations run in parallel. #### `values` An array or object of values to iterate over. If `values` is an array, iterations are started in order by index. If `values` is an object, iterations are started in order by the order returned by `Object.keys` (order is not guaranteed). If `values` is an array, the results of each iteration will be mapped to an array. If `values` is an object, the results of each iteration will be mapped to an object with corresponding keys. #### `iterator(value, key, done)` An async function called per iteration. All iterations are run in parallel. The `iterator` function is called once with each `value`, `key` and a function (`done(error, result)`) to call when the async work is complete. If `done` is passed an error as the first argument, the iteration will fail and the sequence will be ended; however, any iterations in progress will still complete. If `done` is passed a `result` value as the second argument, it will be added to the final results array or object. #### `extensions` The `extensions` object is used for specifying functions that give insight into the lifecycle of each iteration. The possible extension points are `create`, `before`, `after` and `error`. If an extension point is not specified, it defaults to a no-op function. ##### `extensions.create(value, key)` Called at the very beginning of each iteration with the `value` being iterated and the `key` from the array or object. If `create` returns a value (`storage`), it is passed to the `before`, `after` and `error` extension points. If a value is not returned, an empty object is used as `storage` for each other extension point. This is useful for tracking information across an iteration. ##### `extensions.before(storage)` Called immediately before each iteration with the `storage` value returned from the `create` extension point. ##### `extensions.after(result, storage)` Called immediately after each iteration with the `result` of the iteration and the `storage` value returned from the `create` extension point. ##### `extensions.error(error, storage)` Called immediately after a failed iteration with the `error` of the iteration and the `storage` value returned from the `create` extension point. #### `callback(error, results)` A function that is called after all iterations have completed or one iteration has errored. If all iterations completed successfully, the `error` argument will be empty and the `results` will be a mapping of the `iterator` results. If an iteration errored, the `error` argument will be passed from that iteration and the `results` will be whatever partial results had completed successfully before the error occurred. ### `mapSeries(values, iterator[, extensions][, callback])` Takes an object or array of `values` and an `iterator` function to execute with each value. Optionally, takes an `extensions` object and a `callback` function that is called upon completion of the iterations. All iterations run in serial. #### `values` An array or object of values to iterate over. If `values` is an array, iterations are started in order by index. If `values` is an object, iterations are started in order by the order returned by `Object.keys` (order is not guaranteed). If `values` is an array, the results of each iteration will be mapped to an array. If `values` is an object, the results of each iteration will be mapped to an object with corresponding keys. #### `iterator(value, key, done)` An async function called per iteration. All iterations are run in serial. The `iterator` function is called once with each `value`, `key` and a function (`done(error, result)`) to call when the async work is complete. If `done` is passed an error as the first argument, the iteration will fail and the sequence will be ended without executing any more iterations. If `done` is passed a `result` value as the second argument, it will be added to the final results array or object. #### `extensions` The `extensions` object is used for specifying functions that give insight into the lifecycle of each iteration. The possible extension points are `create`, `before`, `after` and `error`. If an extension point is not specified, it defaults to a no-op function. ##### `extensions.create(value, key)` Called at the very beginning of each iteration with the `value` being iterated and the `key` from the array or object. If `create` returns a value (`storage`), it is passed to the `before`, `after` and `error` extension points. If a value is not returned, an empty object is used as `storage` for each other extension point. This is useful for tracking information across an iteration. ##### `extensions.before(storage)` Called immediately before each iteration with the `storage` value returned from the `create` extension point. ##### `extensions.after(result, storage)` Called immediately after each iteration with the `result` of the iteration and the `storage` value returned from the `create` extension point. ##### `extensions.error(error, storage)` Called immediately after a failed iteration with the `error` of the iteration and the `storage` value returned from the `create` extension point. #### `callback(error, results)` A function that is called after all iterations have completed or one iteration has errored. If all iterations completed successfully, the `error` argument will be empty and the `results` will be a mapping of the `iterator` results. If an iteration errored, the `error` argument will be passed from that iteration and the `results` will be whatever partial results had completed successfully before the error occurred. ## License MIT [downloads-image]: http://img.shields.io/npm/dm/now-and-later.svg [npm-url]: https://www.npmjs.com/package/now-and-later [npm-image]: http://img.shields.io/npm/v/now-and-later.svg [travis-url]: https://travis-ci.org/gulpjs/now-and-later [travis-image]: http://img.shields.io/travis/gulpjs/now-and-later.svg?label=travis-ci [appveyor-url]: https://ci.appveyor.com/project/gulpjs/now-and-later [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/now-and-later.svg?label=appveyor [coveralls-url]: https://coveralls.io/r/gulpjs/now-and-later [coveralls-image]: http://img.shields.io/coveralls/gulpjs/now-and-later/master.svg [gitter-url]: https://gitter.im/gulpjs/gulp [gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg node-gulp-4.0.2+~cs38.20.35/appveyor.yml000066400000000000000000000007211415667007300174300ustar00rootroot00000000000000# http://www.appveyor.com/docs/appveyor-yml # http://www.appveyor.com/docs/lang/nodejs-iojs environment: matrix: # node.js - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "5" - nodejs_version: "6" install: - ps: Install-Product node $env:nodejs_version - npm install test_script: - node --version - npm --version - cmd: npm test build: off # build version format version: "{build}" node-gulp-4.0.2+~cs38.20.35/index.js000066400000000000000000000001531415667007300165040ustar00rootroot00000000000000'use strict'; module.exports = { map: require('./lib/map'), mapSeries: require('./lib/mapSeries'), }; node-gulp-4.0.2+~cs38.20.35/lib/000077500000000000000000000000001415667007300156065ustar00rootroot00000000000000node-gulp-4.0.2+~cs38.20.35/lib/helpers.js000066400000000000000000000014651415667007300176140ustar00rootroot00000000000000'use strict'; function noop() {} var defaultExts = { create: noop, before: noop, after: noop, error: noop, }; function defaultExtensions(extensions) { extensions = extensions || {}; return { create: extensions.create || defaultExts.create, before: extensions.before || defaultExts.before, after: extensions.after || defaultExts.after, error: extensions.error || defaultExts.error, }; } function initializeResults(values) { var keys = Object.keys(values); var results = Array.isArray(values) ? [] : {}; var idx = 0; var length = keys.length; for (idx = 0; idx < length; idx++) { var key = keys[idx]; results[key] = undefined; } return results; } module.exports = { defaultExtensions: defaultExtensions, noop: noop, initializeResults: initializeResults, }; node-gulp-4.0.2+~cs38.20.35/lib/map.js000066400000000000000000000023621415667007300167240ustar00rootroot00000000000000'use strict'; var once = require('once'); var helpers = require('./helpers'); function map(values, iterator, extensions, done) { // Allow for extensions to not be specified if (typeof extensions === 'function') { done = extensions; extensions = {}; } // Handle no callback case if (typeof done !== 'function') { done = helpers.noop; } done = once(done); // Will throw if non-object var keys = Object.keys(values); var length = keys.length; var count = length; var idx = 0; // Return the same type as passed in var results = helpers.initializeResults(values); var exts = helpers.defaultExtensions(extensions); if (length === 0) { return done(null, results); } for (idx = 0; idx < length; idx++) { var key = keys[idx]; next(key); } function next(key) { var value = values[key]; var storage = exts.create(value, key) || {}; exts.before(storage); iterator(value, key, once(handler)); function handler(err, result) { if (err) { exts.error(err, storage); return done(err, results); } exts.after(result, storage); results[key] = result; if (--count === 0) { done(err, results); } } } } module.exports = map; node-gulp-4.0.2+~cs38.20.35/lib/mapSeries.js000066400000000000000000000023441415667007300200770ustar00rootroot00000000000000'use strict'; var once = require('once'); var helpers = require('./helpers'); function mapSeries(values, iterator, extensions, done) { // Allow for extensions to not be specified if (typeof extensions === 'function') { done = extensions; extensions = {}; } // Handle no callback case if (typeof done !== 'function') { done = helpers.noop; } done = once(done); // Will throw if non-object var keys = Object.keys(values); var length = keys.length; var idx = 0; // Return the same type as passed in var results = helpers.initializeResults(values); var exts = helpers.defaultExtensions(extensions); if (length === 0) { return done(null, results); } var key = keys[idx]; next(key); function next(key) { var value = values[key]; var storage = exts.create(value, key) || {}; exts.before(storage); iterator(value, key, once(handler)); function handler(err, result) { if (err) { exts.error(err, storage); return done(err, results); } exts.after(result, storage); results[key] = result; if (++idx >= length) { done(err, results); } else { next(keys[idx]); } } } } module.exports = mapSeries; node-gulp-4.0.2+~cs38.20.35/package.json000066400000000000000000000023521415667007300173300ustar00rootroot00000000000000{ "name": "now-and-later", "version": "2.0.1", "description": "Map over an array or object of values in parallel or series, passing each through the async iterator, with optional lifecycle hooks.", "author": "Gulp Team (http://gulpjs.com/)", "contributors": [ "Blaine Bublitz " ], "repository": "gulpjs/now-and-later", "license": "MIT", "engines": { "node": ">= 0.10" }, "main": "index.js", "files": [ "index.js", "lib", "LICENSE" ], "scripts": { "lint": "eslint . && jscs index.js lib/ test/", "pretest": "npm run lint", "test": "mocha --async-only", "cover": "istanbul cover _mocha --report lcovonly", "coveralls": "npm run cover && istanbul-coveralls" }, "dependencies": { "once": "^1.3.2" }, "devDependencies": { "eslint": "^1.7.3", "eslint-config-gulp": "^2.0.0", "expect": "^1.19.0", "istanbul": "^0.4.3", "istanbul-coveralls": "^1.0.3", "jscs": "^2.3.5", "jscs-preset-gulp": "^1.0.0", "mocha": "^2.4.5" }, "keywords": [ "async", "async.js", "map", "control", "flow", "extension", "tracing", "debug", "aop", "aspect", "timing", "tracing" ] } node-gulp-4.0.2+~cs38.20.35/test/000077500000000000000000000000001415667007300160175ustar00rootroot00000000000000node-gulp-4.0.2+~cs38.20.35/test/.eslintrc000066400000000000000000000000351415667007300176410ustar00rootroot00000000000000{ "extends": "gulp/test" } node-gulp-4.0.2+~cs38.20.35/test/map.js000066400000000000000000000135501415667007300171360ustar00rootroot00000000000000'use strict'; var expect = require('expect'); var nal = require('../'); describe('map', function() { it('will execute without an extension object', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); } nal.map(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('should execute without a final callback', function(done) { var initial = [1, 2, 3]; var result = []; function iterator(value, key, cb) { result.push(value); if (result.length === initial.length) { expect(initial).toEqual(result); done(); } cb(null, value); } nal.map(initial, iterator); }); it('should execute with array', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); } nal.map(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('executes with an empty array', function(done) { var initial = []; function iterator(value, key, cb) { cb(null, value); } nal.map(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('should execute with an object', function(done) { var initial = { test: 1, test2: 2, test3: 3, }; function iterator(value, key, cb) { cb(null, value); } nal.map(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('executes with an empty object', function(done) { var initial = {}; function iterator(value, key, cb) { cb(null, value); } nal.map(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('should throw if first argument is a non-object', function(done) { function nonObject() { nal.map('nope'); } expect(nonObject).toThrow(Error); done(); }); it('should maintain order', function(done) { var callOrder = []; function iterator(value, key, cb) { setTimeout(function() { callOrder.push(value); cb(null, value * 2); }, value * 25); } nal.map([1, 3, 2], iterator, function(err, result) { expect(callOrder).toEqual([1, 2, 3]); expect(result).toEqual([2, 6, 4]); done(err); }); }); it('should not mutate the original array', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); } nal.map(initial, iterator, function(err, result) { expect(initial === result).toEqual(false); expect(initial).toEqual(result); done(err); }); }); it('should fail when an error occurs', function(done) { function iterator(value, key, cb) { cb(new Error('Boom')); } nal.map([1, 2, 3], iterator, function(err) { expect(err).toBeAn(Error); expect(err.message).toEqual('Boom'); done(); }); }); it('should ignore multiple calls to the callback inside iterator', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); cb(null, value * 2); } nal.map(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('should take extension points and call them for each function', function(done) { var initial = [1, 2, 3]; var create = []; var before = []; var after = []; function iterator(value, key, cb) { cb(null, value); } var extensions = { create: function(value, idx) { expect(initial).toInclude(value); create[idx] = value; return { idx: idx, value: value }; }, before: function(storage) { before[storage.idx] = storage.value; }, after: function(result, storage) { after[storage.idx] = result; }, }; nal.map(initial, iterator, extensions, function(err, result) { expect(initial).toEqual(create); expect(initial).toEqual(before); expect(result).toEqual(after); done(err); }); }); it('should call the error extension point upon error', function(done) { var initial = [1, 2, 3]; var error = []; function iterator(value, key, cb) { cb(new Error('Boom')); } var extensions = { create: function() { return {}; }, error: function(err) { error = err; }, }; nal.map(initial, iterator, extensions, function(err) { expect(err).toEqual(error); done(); }); }); it('should pass an empty object if falsy value is returned from create', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); } var extensions = { create: function() { return null; }, before: function(storage) { expect(storage).toBeAn('object'); expect(storage).toEqual({}); }, }; nal.map(initial, iterator, extensions, done); }); it('passes the key as the second argument to iterator (array)', function(done) { var initial = [1, 2, 3]; var results = []; function iterator(value, key, cb) { results.push(key); cb(null, value); } nal.map(initial, iterator, function(err) { expect(results).toEqual(['0', '1', '2']); done(err); }); }); it('passes the key as the second argument to iterator (object)', function(done) { var initial = { test: 1, test2: 2, test3: 3, }; var results = []; function iterator(value, key, cb) { results.push(key); cb(null, value); } nal.map(initial, iterator, function(err) { expect(results).toEqual(['test', 'test2', 'test3']); done(err); }); }); }); node-gulp-4.0.2+~cs38.20.35/test/mapSeries.js000066400000000000000000000137161415667007300203150ustar00rootroot00000000000000'use strict'; var expect = require('expect'); var nal = require('../'); describe('mapSeries', function() { it('will execute without an extension object', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); } nal.mapSeries(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('should execute without a final callback', function(done) { var initial = [1, 2, 3]; var result = []; function iterator(value, key, cb) { result.push(value); if (result.length === initial.length) { expect(initial).toEqual(result); done(); } cb(null, value); } nal.mapSeries(initial, iterator); }); it('should execute with array', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); } nal.mapSeries(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('executes with an empty array', function(done) { var initial = []; function iterator(value, key, cb) { cb(null, value); } nal.mapSeries(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('should execute with an object', function(done) { var initial = { test: 1, test2: 2, test3: 3, }; function iterator(value, key, cb) { cb(null, value); } nal.mapSeries(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('executes with an empty object', function(done) { var initial = {}; function iterator(value, key, cb) { cb(null, value); } nal.mapSeries(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('should throw if first argument is a non-object', function(done) { function nonObject() { nal.mapSeries('nope'); } expect(nonObject).toThrow(Error); done(); }); it('should maintain order', function(done) { var callOrder = []; function iterator(value, key, cb) { setTimeout(function() { callOrder.push(value); cb(null, value * 2); }, value * 25); } nal.mapSeries([1, 3, 2], iterator, function(err, result) { expect(callOrder).toEqual([1, 3, 2]); expect(result).toEqual([2, 6, 4]); done(err); }); }); it('should not mutate the original array', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); } nal.mapSeries(initial, iterator, function(err, result) { expect(initial === result).toEqual(false); expect(initial).toEqual(result); done(err); }); }); it('should fail when an error occurs', function(done) { function iterator(value, key, cb) { cb(new Error('Boom')); } nal.mapSeries([1, 2, 3], iterator, function(err) { expect(err).toBeAn(Error); expect(err.message).toEqual('Boom'); done(); }); }); it('should ignore multiple calls to the callback inside iterator', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); cb(null, value * 2); } nal.mapSeries(initial, iterator, function(err, result) { expect(initial).toEqual(result); done(err); }); }); it('should take extension points and call them for each function', function(done) { var initial = [1, 2, 3]; var create = []; var before = []; var after = []; function iterator(value, key, cb) { cb(null, value); } var extensions = { create: function(value, idx) { expect(initial).toInclude(value); create[idx] = value; return { idx: idx, value: value }; }, before: function(storage) { before[storage.idx] = storage.value; }, after: function(result, storage) { after[storage.idx] = result; }, }; nal.mapSeries(initial, iterator, extensions, function(err, result) { expect(initial).toEqual(create); expect(initial).toEqual(before); expect(result).toEqual(after); done(err); }); }); it('should call the error extension point upon error', function(done) { var initial = [1, 2, 3]; var error = []; function iterator(value, key, cb) { cb(new Error('Boom')); } var extensions = { create: function() { return {}; }, error: function(err) { error = err; }, }; nal.mapSeries(initial, iterator, extensions, function(err) { expect(err).toEqual(error); done(); }); }); it('should pass an empty object if falsy value is returned from create', function(done) { var initial = [1, 2, 3]; function iterator(value, key, cb) { cb(null, value); } var extensions = { create: function() { return null; }, before: function(storage) { expect(storage).toBeAn('object'); expect(storage).toEqual({}); }, }; nal.mapSeries(initial, iterator, extensions, done); }); it('passes the key as the second argument to iterator (array)', function(done) { var initial = [1, 2, 3]; var results = []; function iterator(value, key, cb) { results.push(key); cb(null, value); } nal.mapSeries(initial, iterator, function(err) { expect(results).toEqual(['0', '1', '2']); done(err); }); }); it('passes the key as the second argument to iterator (object)', function(done) { var initial = { test: 1, test2: 2, test3: 3, }; var results = []; function iterator(value, key, cb) { results.push(key); cb(null, value); } nal.mapSeries(initial, iterator, function(err) { expect(results).toEqual(['test', 'test2', 'test3']); done(err); }); }); });