{"_id":"fw","_rev":"308632","name":"fw","description":"Tiny library for asynchronous control-flow in JavaScript","dist-tags":{"latest":"0.1.2"},"maintainers":[{"name":"h2non","email":"tomas@aparicio.me"}],"time":{"modified":"2021-06-03T19:41:03.000Z","created":"2014-04-19T18:37:47.716Z","0.1.2":"2014-04-22T07:51:57.179Z","0.1.1":"2014-04-20T10:48:04.594Z","0.1.0":"2014-04-19T19:53:54.314Z","0.1.0-rc.0":"2014-04-19T18:37:47.716Z"},"users":{"h2non":true},"author":{"name":"Tomas Aparicio"},"repository":{"type":"git","url":"git://github.com/h2non/fw"},"versions":{"0.1.2":{"name":"fw","version":"0.1.2","description":"Tiny library for asynchronous control-flow in JavaScript","license":"MIT","repository":{"type":"git","url":"git://github.com/h2non/fw"},"author":{"name":"Tomas Aparicio"},"main":"lib/fw","directories":{"lib":"./lib"},"engines":{"node":">= 0.8.0"},"scripts":{"test":"make test"},"keywords":["async","asynchronous","control","flow","parallel","series"],"devDependencies":{"chai":"~1.9.1","semver":"~2.2.1","mocha":"~1.18.2","browserify":"^3.43.0","uglify-js":"^2.4.13","wisp":"^0.9.0-beta3","os-shim":"^0.1.2"},"bugs":{"url":"https://github.com/h2non/fw/issues"},"homepage":"https://github.com/h2non/fw","_id":"fw@0.1.2","dist":{"shasum":"3524f6793d16e83bc0124e945082c13093bd799a","size":4658,"noattachment":false,"key":"/fw/-/fw-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/fw/download/fw-0.1.2.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"h2non","email":"tomas@aparicio.me"},"maintainers":[{"name":"h2non","email":"tomas@aparicio.me"}],"publish_time":1398153117179,"_cnpm_publish_time":1398153117179,"_hasShrinkwrap":false},"0.1.1":{"name":"fw","version":"0.1.1","description":"Tiny library for asynchronous control-flow in JavaScript","license":"MIT","repository":{"type":"git","url":"git://github.com/h2non/fw"},"author":{"name":"Tomas Aparicio"},"main":"lib/fw","directories":{"lib":"./lib"},"engines":{"node":">= 0.8.0"},"scripts":{"test":"make test"},"keywords":["async","asynchronous","control","flow","parallel","series"],"devDependencies":{"chai":"~1.9.1","semver":"~2.2.1","mocha":"~1.18.2","browserify":"^3.43.0","uglify-js":"^2.4.13","wisp":"^0.9.0-beta3"},"bugs":{"url":"https://github.com/h2non/fw/issues"},"homepage":"https://github.com/h2non/fw","_id":"fw@0.1.1","dist":{"shasum":"532fc67d0e41492d1f04ab95f35616dc4c0b4f5b","size":4633,"noattachment":false,"key":"/fw/-/fw-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/fw/download/fw-0.1.1.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"h2non","email":"tomas@aparicio.me"},"maintainers":[{"name":"h2non","email":"tomas@aparicio.me"}],"publish_time":1397990884594,"_cnpm_publish_time":1397990884594,"_hasShrinkwrap":false},"0.1.0":{"name":"fw","version":"0.1.0","description":"Tiny library for asynchronous control-flow in JavaScript","license":"MIT","repository":{"type":"git","url":"git://github.com/h2non/fw"},"author":{"name":"Tomas Aparicio"},"main":"lib/fw","directories":{"lib":"./lib"},"engines":{"node":">= 0.8.0"},"scripts":{"test":"make test"},"keywords":["async","asynchronous","control","flow","parallel","series"],"devDependencies":{"chai":"~1.9.1","semver":"~2.2.1","mocha":"~1.18.2","browserify":"^3.43.0","uglify-js":"^2.4.13","wisp":"^0.9.0-beta3"},"bugs":{"url":"https://github.com/h2non/fw/issues"},"homepage":"https://github.com/h2non/fw","_id":"fw@0.1.0","dist":{"shasum":"014e6b8cdd2efd6ecb84d0ebb6d63984c9e8372e","size":4635,"noattachment":false,"key":"/fw/-/fw-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fw/download/fw-0.1.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"h2non","email":"tomas@aparicio.me"},"maintainers":[{"name":"h2non","email":"tomas@aparicio.me"}],"publish_time":1397937234314,"_cnpm_publish_time":1397937234314,"_hasShrinkwrap":false},"0.1.0-rc.0":{"name":"fw","version":"0.1.0-rc.0","description":"Tiny library for asynchronous control-flow in JavaScript","license":"MIT","repository":{"type":"git","url":"git://github.com/h2non/fw"},"author":{"name":"Tomas Aparicio"},"main":"lib/fw","directories":{"lib":"./lib"},"engines":{"node":">= 0.8.0"},"scripts":{"test":"make test"},"keywords":["async","asynchronous","control","flow","parallel","series"],"devDependencies":{"chai":"~1.9.1","semver":"~2.2.1","mocha":"~1.18.2","browserify":"^3.43.0","uglify-js":"^2.4.13","wisp":"^0.9.0-beta3"},"bugs":{"url":"https://github.com/h2non/fw/issues"},"homepage":"https://github.com/h2non/fw","_id":"fw@0.1.0-rc.0","dist":{"shasum":"ff49856bad519c6bc98c22ee77d7d001b52a0508","size":4124,"noattachment":false,"key":"/fw/-/fw-0.1.0-rc.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fw/download/fw-0.1.0-rc.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"h2non","email":"tomas@aparicio.me"},"maintainers":[{"name":"h2non","email":"tomas@aparicio.me"}],"publish_time":1397932667716,"_cnpm_publish_time":1397932667716,"_hasShrinkwrap":false}},"readme":"# fw [![Build Status](https://travis-ci.org/h2non/fw.svg?branch=master)][travis] [![NPM version](https://badge.fury.io/js/fw.svg)][npm]\n\n## About\n\n**fw** is a tiny library which helps with **asynchronous\ncontrol-flow management** in JavaScript environments\n\nIt exploits **functional-style programming** using higher-order functions and other common patterns.\nYou could use it in conjunction with [hu][hu], for a better approach\n\n## Features\n\n- Support series or parallel control-flow modes\n- Collections iterators (each, map...)\n- Runs in node and browsers\n- Simple and easy-to-use API\n- Tiny (~200 SLOC)\n- Dependency-free\n- Designed to be embedded in libraries or applications\n\n## Installation\n\n#### Node.js\n\n```bash\n$ npm install fw --save\n```\n\n#### Browser\n\nVia Bower package manager\n```bash\n$ bower install fw\n```\n\nOr loading the script remotely (just for testing or development)\n```html\n<script src=\"//rawgithub.com/h2non/fw/master/fw.js\"></script>\n```\n\n## Environments\n\nIt works properly in any ES5 compliant engine\n\n- Node.js\n- Chrome >= 5\n- Firefox >= 3\n- Safari >= 5\n- Opera >= 12\n- IE >= 9\n\n## API\n\n```js\nvar fw = require('fw')\n```\n\n### series(tasks, callback)\n\nRun the functions in the array in series (sequentially).\nEach function will be executed only if its previous function has completed\n\nIf any functions in the series pass an error to its callback,\nno more functions are run and callback is immediately\ncalled with the value of the error\n\n##### Arguments\n\n- **tasks** - An array containing functions to run. Each function is passed a `callback(err, result)`\n- **callback** - Optional callback to run once all the functions have completed.\nThis function gets an array of results containing all the result arguments passed\nto the task callbacks. `undefined` or `null` values will be omitted from results\n\n```js\nfw.series([\n  function (next) {\n    setTimeout(function () {\n      next(null, 1)\n    }, 100)\n  },\n  function (next, result) {\n    setTimeout(function () {\n      next(null, result + 1)\n    }, 100)\n  }\n], function (err, results) {\n  console.log(err) // → undefined\n  console.log(results) // → [1, 2]\n})\n```\n\n### parallel(tasks, callback)\n\nRun the tasks array of functions in parallel, without waiting until the previous function has completed\n\nOnce the `tasks` have completed, the results are passed to the final `callback` as an array\n\n##### arguments\n\n- **tasks** - An array containing functions to run. Each function is passed a `callback(err, result)`\n- **callback** - Optional callback to run once all the functions have completed.\nThis function gets an array of results containing all the result arguments passed\nto the task callbacks. `undefined` or `null` values will be omitted from results\n\n```js\nfw.parallel([\n  function (done) {\n    setTimeout(function () {\n      done(null, 1)\n    }, 100)\n  },\n  function (done) {\n    setTimeout(function () {\n      done(null, 2)\n    }, 150)\n  }\n], function (err, results) {\n  console.log(err) // → undefined\n  console.log(results) // → [1, 2]\n})\n```\n\n### whilst(test, fn, callback)\n\nRepeatedly call a function, while test returns true.\nCalls callback when stopped or an error occurs\n\n##### arguments\n\n- **test()** - synchronous truth test to perform before each execution of fn.\n- **fn(callback)** - A function which is called each time test passes. The function is passed a `callback(err)`, which must be called once it has completed with an optional err argument\n- **callback(err)** - A callback which is called after the test fails and repeated execution of `fn` has stopped\n\n```js\nvar count = 0\n\nfw.whilst(\n  function () {\n    return count < 3\n  },\n  function (callback) {\n    count++\n    setTimeout(callback, 1000)\n  },\n  function (err) {\n    // 3 seconds have passed\n  }\n)\n```\n\n### each(arr, iterator, callback)\n**Alias**: `map, eachParallel, mapParallel`\n\nApplies the function iterator to each item in arr, in parallel.\nThe iterator is called with an item from the list, and a callback for when it has finished\n\nNote that since this function applies iterator to each item in parallel,\nthere is no guarantee that the iterator functions will complete in order\n\n##### arguments\n\n- **arr** - An array to iterate over\n- **iterator(item, callback)** - A function to apply to each item in arr.\nThe iterator is passed a callback(err) which must be called once it has completed.\nIf no error has occured, the callback should be run without arguments or with an explicit null argument\n- **callback(err)** - A callback which is called when all iterator functions have finished, or an error occurs\n\n```js\nvar fs = require('fs')\nvar files = ['package.json', 'bower.json']\n\nfw.each(files, fs.readFile, function (err, results) {\n  console.log(err) // → undefined\n  console.log(results) // → [Buffer, Buffer]\n})\n```\n\n### eachSeries(arr, iterator, callback)\n**Alias**: `mapSeries`\n\nThe same as `each()`, but only iterator is applied to\neach item in the array in series\n\nThe next iterator is only called once the current one has completed (sequentially)\n\n```js\nvar fs = require('fs')\nvar files = ['package.json', 'bower.json']\n\nfw.eachSeries(files, fs.readFile, function (err, results) {\n  console.log(err) // → undefined\n  console.log(results) // → [Buffer, Buffer]\n})\n```\n\n## Contributing\n\nWanna help? Great! It will be really apreciated :)\n\nYou must add new test cases for any new feature or refactor you do,\nalways following the same design/code patterns that already exist\n\n### Development\n\nOnly [node.js](http://nodejs.org) is required for development\n\nClone/fork this repository\n```\n$ git clone https://github.com/h2non/fw.git && cd fw\n```\n\nInstall dependencies\n```\n$ npm install\n```\n\nCompile code\n```\n$ make compile\n```\n\nRun tests\n```\n$ make test\n```\n\nGenerate browser sources\n```\n$ make browser\n```\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT) © Tomas Aparicio\n\n[travis]: http://travis-ci.org/h2non/fw\n[npm]: http://npmjs.org/package/fw\n[hu]: https://github.com/h2non/hu\n","_attachments":{},"homepage":"https://github.com/h2non/fw","bugs":{"url":"https://github.com/h2non/fw/issues"},"license":"MIT"}