{"name":"function-loop","version":"1.0.2","main":"index.js","scripts":{"test":"tap test.js --100"},"repository":{"type":"git","url":"git+https://github.com/isaacs/function-loop.git"},"keywords":[],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","bugs":{"url":"https://github.com/isaacs/function-loop/issues"},"homepage":"https://github.com/isaacs/function-loop#readme","devDependencies":{"tap":"^9.0.3"},"description":"Run a list of functions in order in a given object context.  The functions can be callback-taking or promise-returning.","gitHead":"e8e5e49d2e350a6decf7c70c26fc265f40145d1e","_id":"function-loop@1.0.2","_nodeVersion":"11.11.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-Iw4MzMfS3udk/rqxTiDDCllhGwlOrsr50zViTOO/W6lS/9y6B1J0BD2VZzrnWUYBJsl3aeqjgR5v7bWWhZSYbA==","shasum":"16b93dd757845eacfeca1a8061a6a65c106e0cb2","tarball":"http://registry-npm.ywwl.com/function-loop/download/function-loop-1.0.2.tgz","fileCount":5,"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcnBESCRA9TVsSAnZWagAAt0IQAJAYvbGdAIyZymVdHZsU\nEI/WOk/5Jy98Tizb1LNJXHM+024ue95Du+TV499z2IejeTxLZoNF2bKyZF1v\nf2MuBYm4AnCCr5zurtPh+VkOXPw5XhUAvKyFYe8l4QKDhnqh5kXpij6N1/7W\n0oQaZmJh/i12Phg1eji3UFfg+wAEhyn0MC383hkMv3BOZbMRqx8wVFPgylUd\ndTMKLYfwBXby5byefqBcORqF4kqTAfKc1396jDCM8LMKcjInBra0sB7fYjHU\nszBRAeB2z2x/mHs54NaG+sDHanDLDQtv0sukZARizb9Twc2aJC+cFjxDs+AU\nczsdFaYJ8VJ1Bx1SzrPaaWNuEkf2H0+P/lmIYS6tbYj6I1m+BC4X93B+J3yx\nqsQFQ/NqkK2E0Dbc/2QAQYIraTIBohBmp56TnpfUxOVPb7iZflvQ/915aFa8\njeT1xB5FRts7agpSovupd3iJNgUZGtMF6YI0aVoC0K747KybmksS8mCfRx1r\n3lAR6RStl2YgkJzv3SSeEystL53Gcbk8XE7rUvAp244nK1gsyZgwgpSdIM7i\nXQPE9Tyyl30FZE1OQTDUxqIHqI6n9j69YULUKAsFOQUrFEHZQcxuZZoT5yjx\nhyBSbFqhqzw3nZS626+2bZX6i/vexpwEgWL2S7EG02ngjLFX2cj35sOQ9lsz\npbcl\r\n=c/jV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyunjXMWpaxlwLuOlQPTiPic0kqGWxFxFzGJWiVCP15QIhAIEW1kP53+3m5q9T3QmqDSdCBGGgfeCnb3rxmVhqiraF"}],"size":1791,"noattachment":false,"key":"/function-loop/-/function-loop-1.0.2.tgz"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/function-loop_1.0.2_1553731857608_0.5546842471363855"},"_hasShrinkwrap":false,"readme":"# function-loop\n\nRun a list of synchronous or asynchronous functions, and call a\nfunction at the end.\n\n## USAGE\n\n```ts\nimport { loop } from 'function-loop'\n// or `const { loop } = require('function-loop')\n\nconst loop = require('./dist/cjs/index.js').default\n\n// synchronous usage\nconst list = [\n  () => console.log(1),\n  () => console.log(2),\n  () => console.log(3),\n]\nconst result = loop(list, () => {\n  console.log('done')\n  return true\n}, (er) => {\n  console.error('threw somehow', er)\n})\n\nconsole.log('result:', result)\n// logs:\n// 1\n// 2\n// 3\n// done\n// result: true\n\n// asynchronous usage\nconst plist = [\n  async () => console.log(1),\n  async () => new Promise(resolve => setTimeout(resolve, 100)).then(() =>\n    console.log(2)\n  ),\n  async () => console.log(3),\n]\nconst presult = loop(plist, () => {\n  console.log('done')\n  return true\n}, (er) => {\n  console.error('threw somehow', er)\n})\n\nconsole.log('result:', presult)\npresult.then(() => console.log('resolved'))\n// logs:\n// 1\n// result: Promise { <pending> }\n// 3\n// 2\n// resolved\n```\n\n## Zalgo Preserving\n\nThis module is\n[\"zalgo-preserving\"](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony),\nmeaning that synchronous returns will result in a sync call to\nthe supplied cb, and async calls will result in the done callback\nbeing called asynchronously.  The loop will return a Promise\nindicating when it is finished, if any async functions are\nencountered.  It does not artificially defer if functions are\ncalled synchronously.\n\n## API\n\n`loop(functionList, doneCallback, errorCallback)`\n\nRun all the functions and then call the `doneCallback` or call\nthe `errorCallback` if there are any errors.\n\nFunctions are called without being bound to any object as `this`.\n\nFunctions can return a Promise to do async operations, or not if\nthey are done synchronously.  Throws and Promise rejection are\nreported to the `errorCallback` provided.\n\nReturn value is the return value of the callback, or a `Promise`\nresolving to the callback's return value if any of the functions\nin the list return promises.\n","publish_time":1553731857797,"_cnpm_publish_time":1553731857797,"dist-tags":{"latest":"4.0.0"}}