{"_id":"function-loop","_rev":"287401","name":"function-loop","description":"Run a list of functions in order in a given object context.  The functions can be callback-taking or promise-returning.","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"isaacs","email":""}],"time":{"modified":"2023-10-06T06:14:38.000Z","created":"2017-01-19T01:29:09.390Z","4.0.0":"2023-04-09T22:59:20.267Z","3.0.1":"2023-03-22T18:48:39.035Z","3.0.0":"2022-11-29T05:36:08.172Z","2.0.1":"2021-02-16T06:41:09.231Z","2.0.0":"2021-02-16T06:38:17.455Z","1.0.2":"2019-03-28T00:10:57.797Z","1.0.1":"2017-01-19T01:30:58.021Z","1.0.0":"2017-01-19T01:29:09.390Z"},"users":{},"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"repository":{"type":"git","url":"git+https://github.com/isaacs/function-loop.git"},"versions":{"4.0.0":{"name":"function-loop","version":"4.0.0","main":"dist/cjs/index.js","module":"dist/mjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"scripts":{"snap":"c8 tap","test":"c8 tap","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","format":"prettier --write . --loglevel warn","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts"},"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":{"@types/tap":"^15.0.7","c8":"^7.12.0","prettier":"^2.8.0","tap":"^16.3.2","ts-node":"^10.9.1","typedoc":"^0.23.21","typescript":"^4.9.3"},"description":"Run a list of functions in order in a given object context.  The functions can be callback-taking or promise-returning.","prettier":{"semi":false,"printWidth":60,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--no-warnings","--loader","ts-node/esm"],"ts":false},"types":"./dist/cjs/index.d.ts","gitHead":"77e77c08a8480525994368eeb7ef84e0c8c1d9eb","_id":"function-loop@4.0.0","_nodeVersion":"18.14.0","_npmVersion":"9.6.4","dist":{"shasum":"12c57cfb9fe08f77532e8b1357242aca2a02c858","size":3297,"noattachment":false,"key":"/function-loop/-/function-loop-4.0.0.tgz","tarball":"http://name.csiicloud.com:7001/function-loop/download/function-loop-4.0.0.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/function-loop_4.0.0_1681081160064_0.8259398733590138"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-04-09T22:59:20.267Z","publish_time":1681081160267,"_cnpm_publish_time":1681081160267},"3.0.1":{"name":"function-loop","version":"3.0.1","main":"dist/cjs/index.js","module":"dist/mjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"scripts":{"snap":"c8 tap","test":"c8 tap","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","format":"prettier --write . --loglevel warn","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts"},"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":{"@types/tap":"^15.0.7","c8":"^7.12.0","prettier":"^2.8.0","tap":"^16.3.2","ts-node":"^10.9.1","typedoc":"^0.23.21","typescript":"^4.9.3"},"description":"Run a list of functions in order in a given object context.  The functions can be callback-taking or promise-returning.","prettier":{"semi":false,"printWidth":60,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--no-warnings","--loader","ts-node/esm"],"ts":false},"types":"./dist/cjs/index.d.ts","gitHead":"ed6228e3a4f71f62361c66d03efb8286837d30c8","_id":"function-loop@3.0.1","_nodeVersion":"18.14.0","_npmVersion":"9.5.1","dist":{"shasum":"ada57d969ee5823ffa669005760be03f065884dc","size":3288,"noattachment":false,"key":"/function-loop/-/function-loop-3.0.1.tgz","tarball":"http://name.csiicloud.com:7001/function-loop/download/function-loop-3.0.1.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/function-loop_3.0.1_1679510918876_0.06040281104643741"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-03-22T18:48:39.035Z","publish_time":1679510919035,"_cnpm_publish_time":1679510919035},"3.0.0":{"name":"function-loop","version":"3.0.0","main":"dist/cjs/index.js","module":"dist/mjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"scripts":{"snap":"c8 tap","test":"c8 tap","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","format":"prettier --write . --loglevel warn","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts"},"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":{"@types/tap":"^15.0.7","c8":"^7.12.0","prettier":"^2.8.0","tap":"^16.3.2","ts-node":"^10.9.1","typedoc":"^0.23.21","typescript":"^4.9.3"},"description":"Run a list of functions in order in a given object context.  The functions can be callback-taking or promise-returning.","prettier":{"semi":false,"printWidth":60,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--no-warnings","--loader","ts-node/esm"],"ts":false},"types":"./dist/cjs/index.d.ts","gitHead":"b6f6601885f83bddd1b11c4afd260ccde0b78404","_id":"function-loop@3.0.0","_nodeVersion":"19.1.0","_npmVersion":"9.1.2","dist":{"shasum":"4966d704fad38c89bb80a6ca66d4f0c20e40bb13","size":3016,"noattachment":false,"key":"/function-loop/-/function-loop-3.0.0.tgz","tarball":"http://name.csiicloud.com:7001/function-loop/download/function-loop-3.0.0.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/function-loop_3.0.0_1669700167995_0.6749753376421879"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-11-29T05:36:16.915Z","publish_time":1669700168172,"_cnpm_publish_time":1669700168172},"2.0.1":{"name":"function-loop","version":"2.0.1","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":"133740eb47b70ac6306360d7df303e546b954217","_id":"function-loop@2.0.1","_nodeVersion":"15.3.0","_npmVersion":"7.5.4","dist":{"shasum":"799c56ced01698cf12a1b80e4802e9dafc2ebada","size":1250,"noattachment":false,"key":"/function-loop/-/function-loop-2.0.1.tgz","tarball":"http://name.csiicloud.com:7001/function-loop/download/function-loop-2.0.1.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/function-loop_2.0.1_1613457669060_0.2951134278171881"},"_hasShrinkwrap":false,"publish_time":1613457669231,"_cnpm_publish_time":1613457669231},"2.0.0":{"name":"function-loop","version":"2.0.0","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":"aff453722f20671f8efdff0d2b17d4a3dfbf1980","_id":"function-loop@2.0.0","_nodeVersion":"15.3.0","_npmVersion":"7.5.4","dist":{"shasum":"87fb442ca41124cb58ddb32db4b12c4515fbbfd7","size":15636,"noattachment":false,"key":"/function-loop/-/function-loop-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/function-loop/download/function-loop-2.0.0.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/function-loop_2.0.0_1613457497152_0.8247033509543569"},"_hasShrinkwrap":false,"publish_time":1613457497455,"_cnpm_publish_time":1613457497455},"1.0.2":{"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":{"shasum":"16b93dd757845eacfeca1a8061a6a65c106e0cb2","size":1791,"noattachment":false,"key":"/function-loop/-/function-loop-1.0.2.tgz","tarball":"http://name.csiicloud.com:7001/function-loop/download/function-loop-1.0.2.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_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,"publish_time":1553731857797,"_cnpm_publish_time":1553731857797},"1.0.1":{"name":"function-loop","version":"1.0.1","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":"4e4499cc60ac865f4bf8a83007c9bcf90c02abfa","_id":"function-loop@1.0.1","_shasum":"8076bb305e8e6a3cceee2920765f330d190f340c","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"shasum":"8076bb305e8e6a3cceee2920765f330d190f340c","size":1662,"noattachment":false,"key":"/function-loop/-/function-loop-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/function-loop/download/function-loop-1.0.1.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/function-loop-1.0.1.tgz_1484789456274_0.8021668971050531"},"directories":{},"publish_time":1484789458021,"_cnpm_publish_time":1484789458021,"_hasShrinkwrap":false},"1.0.0":{"name":"function-loop","version":"1.0.0","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","dependencies":{"bluebird":"^3.4.7"},"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":"6a715ea81077965917f572eef65b1b734e1b16a1","_id":"function-loop@1.0.0","_shasum":"604086c5e0e811479128d0749bb5b93996e49225","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"shasum":"604086c5e0e811479128d0749bb5b93996e49225","size":1675,"noattachment":false,"key":"/function-loop/-/function-loop-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/function-loop/download/function-loop-1.0.0.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/function-loop-1.0.0.tgz_1484789347570_0.3647799848113209"},"directories":{},"publish_time":1484789349390,"_cnpm_publish_time":1484789349390,"_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","_attachments":{},"homepage":"https://github.com/isaacs/function-loop#readme","bugs":{"url":"https://github.com/isaacs/function-loop/issues"},"license":"ISC"}