package.json 7.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. "_args": [
  3. [
  4. {
  5. "raw": "async-foreach@^0.1.3",
  6. "scope": null,
  7. "escapedName": "async-foreach",
  8. "name": "async-foreach",
  9. "rawSpec": "^0.1.3",
  10. "spec": ">=0.1.3 <0.2.0",
  11. "type": "range"
  12. },
  13. "/mnt/Data/bach/Sites/clameurs.org/sites/all/themes/figureslibres/clameurs/node_modules/node-sass"
  14. ]
  15. ],
  16. "_from": "async-foreach@>=0.1.3 <0.2.0",
  17. "_id": "async-foreach@0.1.3",
  18. "_inCache": true,
  19. "_location": "/async-foreach",
  20. "_npmUser": {
  21. "name": "cowboy",
  22. "email": "cowboy@rj3.net"
  23. },
  24. "_npmVersion": "1.1.70",
  25. "_phantomChildren": {},
  26. "_requested": {
  27. "raw": "async-foreach@^0.1.3",
  28. "scope": null,
  29. "escapedName": "async-foreach",
  30. "name": "async-foreach",
  31. "rawSpec": "^0.1.3",
  32. "spec": ">=0.1.3 <0.2.0",
  33. "type": "range"
  34. },
  35. "_requiredBy": [
  36. "/node-sass"
  37. ],
  38. "_resolved": "https://registry.npmjs.org/async-foreach/-/async-foreach-0.1.3.tgz",
  39. "_shasum": "36121f845c0578172de419a97dbeb1d16ec34542",
  40. "_shrinkwrap": null,
  41. "_spec": "async-foreach@^0.1.3",
  42. "_where": "/mnt/Data/bach/Sites/clameurs.org/sites/all/themes/figureslibres/clameurs/node_modules/node-sass",
  43. "author": {
  44. "name": "\"Cowboy\" Ben Alman",
  45. "url": "http://benalman.com/"
  46. },
  47. "bugs": {
  48. "url": "https://github.com/cowboy/javascript-sync-async-foreach/issues"
  49. },
  50. "dependencies": {},
  51. "description": "An optionally-asynchronous forEach with an interesting interface.",
  52. "devDependencies": {},
  53. "directories": {},
  54. "dist": {
  55. "shasum": "36121f845c0578172de419a97dbeb1d16ec34542",
  56. "tarball": "https://registry.npmjs.org/async-foreach/-/async-foreach-0.1.3.tgz"
  57. },
  58. "engines": {
  59. "node": "*"
  60. },
  61. "homepage": "http://github.com/cowboy/javascript-sync-async-foreach",
  62. "keywords": [
  63. "array",
  64. "loop",
  65. "sync",
  66. "async",
  67. "foreach"
  68. ],
  69. "main": "lib/foreach",
  70. "maintainers": [
  71. {
  72. "name": "cowboy",
  73. "email": "cowboy@rj3.net"
  74. }
  75. ],
  76. "name": "async-foreach",
  77. "optionalDependencies": {},
  78. "readme": "# JavaScript Sync/Async forEach\n\nAn optionally-asynchronous forEach with an interesting interface.\n\n## Getting Started\n\nThis code should work just fine in Node.js:\n\nFirst, install the module with: `npm install async-foreach`\n\n```javascript\nvar forEach = require('async-foreach').forEach;\nforEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n});\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// each c 2 [\"a\", \"b\", \"c\"]\n```\n\nOr in the browser:\n\n```html\n<script src=\"dist/ba-foreach.min.js\"></script>\n<script>\nforEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n});\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// each c 2 [\"a\", \"b\", \"c\"]\n</script>\n```\n\nIn the browser, you can attach the forEach method to any object.\n\n```html\n<script>\nthis.exports = Bocoup.utils;\n</script>\n<script src=\"dist/ba-foreach.min.js\"></script>\n<script>\nBocoup.utils.forEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n});\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// each c 2 [\"a\", \"b\", \"c\"]\n</script>\n```\n\n## The General Idea (Why I thought this was worth sharing)\n\nThe idea is to allow the callback to decide _at runtime_ whether the loop will be synchronous or asynchronous. By using `this` in a creative way (in situations where that value isn't already spoken for), an entire control API can be offered without over-complicating function signatures.\n\n```javascript\nforEach(arr, function(item, index) {\n // Synchronous.\n});\n\nforEach(arr, function(item, index) {\n // Only when `this.async` is called does iteration becomes asynchronous. The\n // loop won't be continued until the `done` function is executed.\n var done = this.async();\n // Continue in one second.\n setTimeout(done, 1000);\n});\n\nforEach(arr, function(item, index) {\n // Break out of synchronous iteration early by returning false.\n return index !== 1;\n});\n\nforEach(arr, function(item, index) {\n // Break out of asynchronous iteration early...\n var done = this.async();\n // ...by passing false to the done function.\n setTimeout(function() {\n done(index !== 1);\n });\n});\n```\n\n## Examples\nSee the unit tests for more examples.\n\n```javascript\n// Generic \"done\" callback.\nfunction allDone(notAborted, arr) {\n console.log(\"done\", notAborted, arr);\n}\n\n// Synchronous.\nforEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n}, allDone);\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// each c 2 [\"a\", \"b\", \"c\"]\n// done true [\"a\", \"b\", \"c\"]\n\n// Synchronous with early abort.\nforEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n if (item === \"b\") { return false; }\n}, allDone);\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// done false [\"a\", \"b\", \"c\"]\n\n// Asynchronous.\nforEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n var done = this.async();\n setTimeout(function() {\n done();\n }, 500);\n}, allDone);\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// each c 2 [\"a\", \"b\", \"c\"]\n// done true [\"a\", \"b\", \"c\"]\n\n// Asynchronous with early abort.\nforEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n var done = this.async();\n setTimeout(function() {\n done(item !== \"b\");\n }, 500);\n}, allDone);\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// done false [\"a\", \"b\", \"c\"]\n\n// Not actually asynchronous.\nforEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n var done = this.async()\n done();\n}, allDone);\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// each c 2 [\"a\", \"b\", \"c\"]\n// done true [\"a\", \"b\", \"c\"]\n\n// Not actually asynchronous with early abort.\nforEach([\"a\", \"b\", \"c\"], function(item, index, arr) {\n console.log(\"each\", item, index, arr);\n var done = this.async();\n done(item !== \"b\");\n}, allDone);\n// logs:\n// each a 0 [\"a\", \"b\", \"c\"]\n// each b 1 [\"a\", \"b\", \"c\"]\n// done false [\"a\", \"b\", \"c\"]\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt).\n\n_Also, please don't edit files in the \"dist\" subdirectory as they are generated via grunt. You'll find source code in the \"lib\" subdirectory!_\n\n## Release History\n\n04/29/2013\nv0.1.3\nRemoved hard Node.js version dependency.\n\n11/17/2011\nv0.1.2\nAdding sparse array support.\nInvalid length properties are now sanitized.\nThis closes issue #1 (like a boss).\n\n11/11/2011\nv0.1.1\nRefactored code to be much simpler. Yay for unit tests!\n\n11/11/2011\nv0.1.0\nInitial Release.\n\n## License\nCopyright (c) 2012 \"Cowboy\" Ben Alman \nLicensed under the MIT license. \n<http://benalman.com/about/license/>\n",
  79. "readmeFilename": "README.md",
  80. "repository": {
  81. "type": "git",
  82. "url": "git://github.com/cowboy/javascript-sync-async-foreach.git"
  83. },
  84. "version": "0.1.3"
  85. }