{"_id":"asyncjs","_rev":"161090","name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","dist-tags":{"latest":"0.0.13"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"time":{"modified":"2021-06-03T11:40:17.000Z","created":"2011-01-22T15:16:21.700Z","0.0.13":"2019-05-15T09:53:05.892Z","0.0.12":"2018-02-20T11:34:12.656Z","0.0.11":"2017-10-11T09:24:06.158Z","0.0.10":"2015-10-27T15:15:54.909Z","0.0.9":"2012-06-11T23:10:07.531Z","0.0.8":"2012-06-11T17:39:00.677Z","0.0.7":"2012-04-16T14:05:36.565Z","0.0.6":"2012-03-07T10:12:16.074Z","0.0.5":"2011-04-14T12:12:16.676Z","0.0.4":"2011-04-04T16:08:30.993Z","0.0.2":"2011-01-22T15:16:25.358Z","0.0.1":"2011-01-22T15:16:21.700Z"},"users":{"tunnckocore":true,"gtopia":true},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"repository":{"type":"git","url":"git+ssh://git@github.com/fjakobs/async.js.git"},"versions":{"0.0.13":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.13","homepage":"http://github.com/fjakobs/async.js","author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"git+ssh://git@github.com/fjakobs/async.js.git"},"license":"MIT","gitHead":"f34fd13043f1c513ad0a81c4aaf81e537a64cd1a","bugs":{"url":"https://github.com/fjakobs/async.js/issues"},"_id":"asyncjs@0.0.13","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"fjakobs","email":"fabian.jakobs@web.de"},"dist":{"shasum":"9a39605cdbcab1283737039d4da14310b6d91c6f","size":16390,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.13.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.13.tgz"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/asyncjs_0.0.13_1557913985424_0.9806800260993831"},"_hasShrinkwrap":false,"publish_time":1557913985892,"_cnpm_publish_time":1557913985892},"0.0.12":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.12","homepage":"http://github.com/fjakobs/async.js","author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"git+ssh://git@github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"gitHead":"2bb179dd066ff710d3fa6b4b851f9fa3735eefdd","bugs":{"url":"https://github.com/fjakobs/async.js/issues"},"_id":"asyncjs@0.0.12","_npmVersion":"5.3.0","_nodeVersion":"8.6.0","_npmUser":{"name":"fjakobs","email":"fabian.jakobs@web.de"},"dist":{"shasum":"a720f5ecf8b0f79118062221c1ccc2477694fd9c","size":16516,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.12.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.12.tgz"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/asyncjs_0.0.12_1519126452593_0.09331229055429091"},"_hasShrinkwrap":false,"publish_time":1519126452656,"_cnpm_publish_time":1519126452656},"0.0.11":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.11","homepage":"http://github.com/fjakobs/async.js","author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"git+ssh://git@github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"gitHead":"be2c5b9195312c9c4aa8c3e29932b0b9784bcae7","bugs":{"url":"https://github.com/fjakobs/async.js/issues"},"_id":"asyncjs@0.0.11","_npmVersion":"5.3.0","_nodeVersion":"8.6.0","_npmUser":{"name":"fjakobs","email":"fabian.jakobs@web.de"},"dist":{"shasum":"32591af2a0cde9c4691ecc81c79689430077ea46","size":936502,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.11.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.11.tgz"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/asyncjs-0.0.11.tgz_1507713844665_0.9091193091589957"},"directories":{},"publish_time":1507713846158,"_cnpm_publish_time":1507713846158,"_hasShrinkwrap":false},"0.0.10":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.10","homepage":"http://github.com/fjakobs/async.js","engines":{"node":">= 0.6.0"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"git+ssh://git@github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"gitHead":"07ff6d5caaa5474e98e4d484064ef786d7b0c7de","bugs":{"url":"https://github.com/fjakobs/async.js/issues"},"_id":"asyncjs@0.0.10","_shasum":"50dbbfefb8b2df2ffa9c9e9e8bd58887bc3c1518","_from":".","_npmVersion":"2.14.4","_nodeVersion":"4.1.1","_npmUser":{"name":"fjakobs","email":"fabian.jakobs@web.de"},"dist":{"shasum":"50dbbfefb8b2df2ffa9c9e9e8bd58887bc3c1518","size":17286,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.10.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.10.tgz"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"directories":{},"publish_time":1445958954909,"_cnpm_publish_time":1445958954909,"_hasShrinkwrap":false},"0.0.9":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.9","homepage":"http://github.com/fjakobs/async.js","engines":{"node":">= 0.4.0"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"git://github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"_npmUser":{"name":"fjakobs","email":"fabian.jakobs@web.de"},"_id":"asyncjs@0.0.9","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.19","_nodeVersion":"v0.6.16","_defaultsLoaded":true,"dist":{"shasum":"6c25c81fa83fbee9674248f508456b43fc14e65c","size":18471,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.9.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.9.tgz"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"directories":{},"publish_time":1339456207531,"_hasShrinkwrap":false,"_cnpm_publish_time":1339456207531},"0.0.8":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.8","homepage":"http://github.com/fjakobs/async.js","engines":{"node":">= 0.4.0"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"git://github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"_npmUser":{"name":"fjakobs","email":"fabian.jakobs@web.de"},"_id":"asyncjs@0.0.8","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.19","_nodeVersion":"v0.6.16","_defaultsLoaded":true,"dist":{"shasum":"b639d2aa3521c81831dc8ddc67967186c3b3bb43","size":17681,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.8.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.8.tgz"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"directories":{},"publish_time":1339436340677,"_hasShrinkwrap":false,"_cnpm_publish_time":1339436340677},"0.0.7":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.7","homepage":"http://github.com/fjakobs/async.js","engines":{"node":">= 0.4.0"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"git://github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"_npmUser":{"name":"fjakobs","email":"fabian.jakobs@web.de"},"_id":"asyncjs@0.0.7","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.4","_nodeVersion":"v0.6.12","_defaultsLoaded":true,"dist":{"shasum":"2bc3517bc84ef7ba6d363ca9bdd91c7280c2c284","size":16591,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.7.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.7.tgz"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"directories":{},"publish_time":1334585136565,"_hasShrinkwrap":false,"_cnpm_publish_time":1334585136565},"0.0.6":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.6","homepage":"http://github.com/fjakobs/async.js","engines":{"node":">= 0.4.0"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"git://github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"_npmUser":{"name":"fjakobs","email":"fabian.jakobs@web.de"},"_id":"asyncjs@0.0.6","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.4","_nodeVersion":"v0.6.12","_defaultsLoaded":true,"dist":{"shasum":"318463b63ed8a1695d1342b1d733e6a3502dc455","size":16577,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.6.tgz"},"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"directories":{},"publish_time":1331115136074,"_hasShrinkwrap":false,"_cnpm_publish_time":1331115136074},"0.0.5":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.5","homepage":"http://github.com/fjakobs/async.js","engines":{"node":">= 0.4.0"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"index","repository":{"type":"git","url":"http://github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"_id":"asyncjs@0.0.5","_nodeSupported":true,"_npmVersion":"0.2.12-1","_nodeVersion":"v0.4.1","dist":{"shasum":"cfb12d44833b35999ccc9d3a85c15b9c278ce674","size":18018,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.5.tgz"},"directories":{},"publish_time":1302783136676,"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1302783136676},"0.0.4":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.4","homepage":"http://github.com/fjakobs/async.js","engines":{"node":">= 0.2.0"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"directories":{"lib":"lib/async"},"repository":{"type":"git","url":"http://github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"_id":"asyncjs@0.0.4","_nodeSupported":true,"_npmVersion":"0.2.12-1","_nodeVersion":"v0.4.1","dist":{"shasum":"55b1f66c239a9700c661c3eeaa0b9a9704d1603f","size":17795,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.4.tgz"},"publish_time":1301933310993,"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1301933310993},"0.0.2":{"name":"asyncjs","description":"async.js it for the node fs module, what jQuery is for the DOM","version":"0.0.2","homepage":"http://github.com/fjakobs/async.js","engines":{"node":">= 0.2.0"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"directories":{"lib":"lib/async"},"repository":{"type":"git","url":"http://github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"_id":"asyncjs@0.0.2","_nodeSupported":true,"_npmVersion":"0.2.12-1","_nodeVersion":"v0.2.6","dist":{"shasum":"4fd072a42f658d080adac7706dced1f362610de7","size":18152,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.2.tgz"},"publish_time":1295709385358,"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1295709385358},"0.0.1":{"name":"asyncjs","version":"0.0.1","homepage":"http://github.com/fjakobs/async.js.git","engines":{"node":">= 0.1.102"},"author":{"name":"Fabian Jakobs","email":"fabian.jakobs@web.de"},"scripts":{"test":"node test/all.js"},"main":"lib/async","repository":{"type":"git","url":"http://github.com/fjakobs/async.js.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"_id":"asyncjs@0.0.1","_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"shasum":"e13538a9fd05f2231396759f9b7eff43205e44a5","size":18199,"noattachment":false,"key":"/asyncjs/-/asyncjs-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/asyncjs/download/asyncjs-0.0.1.tgz"},"directories":{},"publish_time":1295709381700,"maintainers":[{"name":"fjakobs","email":"fabian.jakobs@web.de"}],"_hasShrinkwrap":false,"_cnpm_publish_time":1295709381700}},"readme":"async.js\n========\n\n**A clean, composable way to manipulate sequences of values with asynchronous functions\n**\n\nDealing with control flow in heavily asynchronous code can be a big challenge. Without any helper functions the code can easily degenerate into a christmas tree shape because of the callback of a callback of a callback syndrome.\n\n```javascript\nasncFunction1(function(err, result) {\n  asncFunction2(function(err, result) {\n    asncFunction3(function(err, result) {\n      asncFunction4(function(err, result) {\n        asncFunction5(function(err, result) {\n          // do something useful\n        })\n      })\n    })\n  })\n})\n```    \n\nWith async.js this can be written as\n```javascript\nasync.list([\n  asncFunction1,\n  asncFunction2,\n  asncFunction3,\n  asncFunction4,\n  asncFunction5,\n]).call().end(function(err, result) {\n  // do something useful\n});\n```\nIt gets even worse if an asynchronous function has to be applied to a sequence of values. There is a nice example of this in the  howtonode.org article [Control Flow in Node Part III](http://howtonode.org/control-flow-part-iii):\n```javascript\n// Here is the async version without helpers\nfunction loaddir(path, callback) {\n  fs.readdir(path, function (err, filenames) {\n    if (err) { callback(err); return; }\n    var realfiles = [];\n    var count = filenames.length;\n    filenames.forEach(function (filename) {\n      fs.stat(filename, function (err, stat) {\n        if (err) { callback(err); return; }\n        if (stat.isFile()) {\n          realfiles.push(filename);\n        }\n        count--;\n        if (count === 0) {\n          var results = [];\n          realfiles.forEach(function (filename) {\n            fs.readFile(filename, function (err, data) {\n              if (err) { callback(err); return; }\n              results.push(data);\n              if (results.length === realfiles.length) {\n                callback(null, results);\n              };\n            });\n          });\n        }\n      });\n    });\n  });\n}\n```    \nThis code reads the contents of a directory, filters out all directory and returns the contens of all files as an array. Without any helpers the whole control flow management totally obscures the intent of the code. With async.js it is possible to move the control flow aspects of the code out of the function and rewrite it like this:\n```javascript\nfunction loaddir(path, callback) {\n  async.readdir(\".\")\n    .stat()\n    .filter(function(file) {\n      return file.stat.isFile()\n    })\n    .readFile(\"utf8\")\n    .filter(function(file) {\n      return file.data\n    })\n    .toString(callback)\n}\n```    \n\nFeatures\n========\n\nCore\n----\n\nJavaScript Array like abstraction, which supports almost all JavaScript array functions with asynchronous versions of\n\n- filter\n- map\n- reduce\n- forEach\n- some\n- every\n\nAll functions are chainable.\n\nnode.js file system plugin\n--------------------------\n\nMost of the functions from the `fs` module in node.js are exposed as chainable filters.\n\n- `stat` (lstat, fstat)\n- `unlink`\n- `mkdir`/`rmdir`\n- `realpath`\n- `open`/`close`\n- `exists` (from `fs.exists`)\n- `chmod`\n- `readFile`/`writeFile`\n\nConstructors\n\n- `files`: convert a list of files into a file sequence\n- `readdir`: create a file sequence from the files in a directory\n- `walkfiles`: recursive file walker\n- `glob`: Unix style file matching. Creates a file sequence of all matching files.\n\nUtility functions to work with the file system\n\n- `abspath`: convert a relative to an absolute path\n- `copyfile`: copy a single file\n- `copytree`: copy whole diroctory tree\n- `rmtree`: remove whole direcory tree (like `rm -rf`)\n\nUtils plugin\n------------\n\nGeneric filters:\n\n- `delay`: wait a given time before returning the next value\n- `timeout`: If the source doesn't respond in a given time an error is returned.\n- `inspect`: print the source value as JSON\n- `print`: print the source value as string\n\nHow does it work?\n=================\n\n## Constructors\n\nConstructors are the sources of async streams. They return an `async.Generator` instance which generates a sequence of values.\n\n## Filters\n\nFilters work on the sequence generated by a source generator. They can remove, add and modify values in the sequence. Filters return themselves generator instances.\n\n## Drivers\n\nDriver methods drive the actual execution of the iteration. The hole system is based on the principle of pulling the values from the end. Until any of the drivers is called no value will be generated.\n\n\nTODO\n====\n\n- Add documentation about the fs plugin\n- Add documentation about the unit testing framework\n- improve test coverage of the core functionality\n- create browser version\n\nContinuous Integration status\n-----------------------------\n\nThis project is tested with [Travis CI](http://travis-ci.org)\n[![Build Status](https://secure.travis-ci.org/fjakobs/async.js.png)](http://travis-ci.org/fjakobs/async.js)\n\nCore API\n========\n\n## Constructors\n\n### async.range([start=0], [stop], [step=1], [construct=async.Generator])\n\nCreates a generator generating an arithmetic progression of integers.\n`range(i, j)` returns [i, i+1, i+2, ..., j-1] and `start` defaults to 0.\nWhen step is given, it specifies the increment (or decrement). If `stop` is not given an infinite number of values if generated. This generates all positive odd numbers:\n```javascript\nasync.range(1, null, 2)\n```\nThe optional `construct` argument must be a sub class of `async.Generator` and can be used to tell the function to return instances of the class.\n\n\n### async.list(arr, [construct=async.Generator])\n\nCreates a generator, which returns the elements of the given array. This generates e.g. the values `1`, `2` and `3`:\n```javascript\nasync.list([1, 2, 3])\n```\nThe optional `construct` argument must be a sub class of `async.Generator` and can be used to tell the function to return instances of the class.\n\n\n## async.Generator(source)\n\nGenerators are implementing the 'Iterator' design pattern in an asynchronous way. It has a `next(callback)` method, which passes on each call the next generated value to the given callback. Generators can be chained and all construcors and filters return new `Generator` instances.\n\nThe `source` is either another `async.Generator` or a generator function. All filters in the generator operate on the values generated by the source.\n```javascript\nvar i=0;\nvar gen = new async.Generator(function(callback) {\n  if (i>4)\n    callback(async.STOP)\n  else\n    callback(null, i++) // no error\n})\n```    \n`gen` in this example generates the sequence [0, 1, 2, 3, 4]. The first argument of the callback can be used to indicate an error the the end of the iteration, whicle the second argument is the generated value.\n\n### Constant: async.STOP\n\nSpecial error value, which indicates the end of the iteration.\n\n### Method: next(callback)\n\nCalls the callback with the next generated value:\n```javascript\ngen.next(function(err, value) {\n  //\n})\n```    \nThe generated value is passed in the `value` argument. If an error occured while computing the value the `err` argument is set. In this case value the meaning of value is undefined. `async.STOP` can be passed as special error value to indicate the end of the iteration.\n\nUsually this method is only needed to write custom filters.\n\n### Filter: map(mapper)\n\nApplies the `mapper` function to all values of the generator's source and generates the result of the mapping.\n```javascript\nasync.range(0, 3)\n  .map(function(item, next) {\n    next(null, item + 1)\n  })\n```    \nThis will add one to each incoming item and thus generate the sequence [1, 2, 3].\n\nThe mapper can also be synchronous and simply return the result. In this case the mapper must not have the `next` argument.\n\n\n### Filter: filter(filter)\n\nCalls filter for each of the generator's source values. If the `filter` returns `false` for a passed value, the value is dropped from the sequence, otherwise the value is forwarded.\n```javascript\nasync.list([1, 2, 3, 4])\n  .filter(function(item, next) {\n    next(null, item % 2 == 0)\n  })\n```        \nThis will filter out all odd values and generate the sequence [2, 4].\n\n\n### Filter: slice(begin, end)\n\nCounts the generator's source values starting with 0 and skips all values with an index smaller then `begin`. If the index is >= `end` the sequence is stopped.\n```javascript\nasync.range(0)\n  .slice(1, 4)\n```        \nThe `async.range` call generates an infinite sequence of all integers and the `slice` call transforms this into the sequence [1, 2, 3] by dropping the first value and stopping the sequence after the 4th value.\n\n### Filter: reduce(reduce, [initialValue])\n\nSum up the number from 1 to 5:\n```javascript\nasync.range(1, 5)\n  .reduce(function(previousValue, currentValue) {        \n    return previousValue + currentValue;\n  })\n```        \nSum up the number from 1 to 5 but with a first 'initialValue' of 10:\n```javascript\nasync.range(1, 5)\n  .reduce(function(previousValue, currentValue, index, next) {\n    next(null, previousValue + currentValue);\n  }, 10)\n```\n\n### Filter: forEach(fn)\n\nAlias for `each`.\n\n### Filter: each(fn)\n\nCalls `fn` for each of the source generator's values. The returned generator passes on the source values.\n```javascript\nasync.range(1, 10)\n  .each(function(item, next) {\n    console.log(item);\n  })\n```        \nPrints the numbers from 1 to 9. Otherwise the source sequence is not changed.\n\n### Filter: some(condition)\n\nCheck if any of the values in the source sequence match the condition (i.e. the `condition` callback returns true). The returned generator generates a one elmement sequence, which contains the boolean value of the result.\n\nCheck if the source generates an even number:\n```javascript\nasync.list([1, 8, 3, 5])\n  .some(function odd(item) {\n    return item % 2 == 0\n  })\n```\nThis generates [true].\n\n### Filter: every(condition)\n\nCheck if all of the values in the source sequence match the condition (i.e. the `condition` callback returns true). The returned generator generates a one elmement sequence, which contains the boolean value of the result.\n\nCheck if the source generates only even numbers:\n```javascript\nasync.list([1, 8, 3, 5])\n  .every(function odd(item) {\n    return item % 2 == 0\n  })\n```\nThis returns [false]\n\n### Filter: call([context])\n\nCalls each of source values in sequence, which have to be functions. The functions can either be synchronous and return a value of be asynchronous and call the passed callback on completion. The generated sequence are the function's return values. The optional `context` argument defines the `this` context of the called functions.\n```javascript\nasync.list([\n  function sync() {\n    return \"juhu\"\n  },    \n  function async(next) {\n    next(null, \"kinners\")\n  }\n]).call()\n```    \nThis calls the two functions in sequence and generates the sequence [\"juhu\", \"kinners\"].\n\n### Filter: concat(...)\n\nConcatenates a variable number of generators with this generator. \n```javascript\nasync.range(1, 4)\n  .concat(async.range(10, 13))\n```        \nThis returns a generator, which generates the values of the first `range` followed by the values of the second `range`: [1, 2, 3, 10, 11, 12]\n\n\n### Filter: zip(...)\n\nReturns a generator, which generates on each `next()` an arroy of the next values of this generator and each of the passed arguments. The length of the generated sequence is truncated to the lenght of the shortest input sequence. This function expects a variable list of generators as arguments.\n```javascript\nasync.range(1, 4)\n  .zip(async.range(10, 14))\n```        \nThis will generate [[1, 10], [2, 11], [3, 13]]\n\n### Filter: sort([compare])\n\nPerforms an Array.prototype.sort on the source values and returns a generator, which generates the result as one element sequence. Since this requires reading all source elements, the source must not generate an infinite number of values. Generates the read values in sorted order.\n```javascript\nasync.list([4, 2, 3, 9])\n  .sort()\n```\nThis generates the sequence [2, 3, 4, 9]\n\n### Filter: join([separator])\n\nPerforms an Array.prototype.join on the source values and returns a generator, which generates the result as one element sequence. Since this requires reading all source elements, the source must not generate an infinite number of values.\n```javascript\nasync.list([1, 4, 5])\n  .join(\" - \")\n```\nThis will generate [\"1 - 4 - 5\"]\n\n### Filter: reverse()\n\nReverses the elements generated by the generator's source. Since this requires reading all source elements, the source must not generate an infinite number of values.\n```javascript\nasync.list([1, 4, 5])\n  .revers()\n```\nThis will generate [5, 4, 1]\n\n\n### Driver: end([callback])\n\nPerform the iteration until the generator's source either returns `async.STOP` or indicates an error. The value of the last generated value is passed to the callback.\n\n```javascript\nasync.list([1, 8, 3, 5])\n  .every(function odd(item) {\n    return item % 2 == 0\n  })\n  .end(function(err, allEven) {\n    console.log(\"All values are even: \" + allEven)\n  }) \n```\nThis will print the last generated value (the result of `very`) on the console.\n\n### Driver: toArray([breakOnError=true], callback)\n\nPerform the iteration until the generator's source either returns `async.STOP`. If `breakOnError` is true the iteration is stopped on the first error. Otherwise the iteration continues and all errors are collected in an error array. An array of all generated values is passed to the callback.\n```javascript\nasync.list([1, 8, 3, 5])\n  .map(function odd(item, next) {\n    next(err, item * 10)\n  })\n  .toArray(function(err, values) {\n    console.log(values)\n  }) \n```\nThe last callback will be called with arr set to [10, 80, 30, 50].\n","_attachments":{},"homepage":"http://github.com/fjakobs/async.js","bugs":{"url":"https://github.com/fjakobs/async.js/issues"},"license":"MIT"}