{"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":{"integrity":"sha512-f34iQBedYF3XcI93uewZZOnyscDragxgTK/eTvVB74k3fCD0ZorOi5BV9GS4M8rz/JoNi0Kl3qX5Y9MH3S/CLQ==","shasum":"12c57cfb9fe08f77532e8b1357242aca2a02c858","tarball":"http://registry-npm.ywwl.com/function-loop/download/function-loop-4.0.0.tgz","fileCount":13,"unpackedSize":9339,"signatures":[{"keyid":"SHA256:jl3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","size":3297,"noattachment":false,"key":"/function-loop/-/function-loop-4.0.0.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/function-loop_4.0.0_1681081160064_0.8259398733590138"},"_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":1681081160267,"_cnpm_publish_time":1681081160267,"dist-tags":{"latest":"4.0.0"}}