{"_id":"@bradleymeck/thenables","_rev":"4-98162558c505779afa5863413a6f5231","name":"@bradleymeck/thenables","description":"some simple utilities for awaiting","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@bradleymeck/thenables","version":"1.0.0","description":"some simple utilities for awaiting","scripts":{"test":"set -e; for x in test/*; do node $x; done"},"keywords":["async","await","thenable"],"author":{"name":"bradleymeck"},"license":"MIT","files":["iter.js"],"gitHead":"025e6e0932f44f218104df7506730f9672992af0","_id":"@bradleymeck/thenables@1.0.0","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"bradleymeck","email":"bradley.meck@gmail.com"},"dist":{"integrity":"sha512-dAWdMPys3M/n33cguoJkMW3uImFtYSieB/Twa5ws9XJ1jRlr62yiT8rJQSkd1mkNwLC8mj0KcxLJ5KKhjYjlFg==","shasum":"94fa7fc42cf3f216360260a7a52c4b87edc27653","tarball":"https://registry.npmjs.org/@bradleymeck/thenables/-/thenables-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICo5woJhL/tvWk1psbDd4QIGJQGNOQExF+mHXgYuTkfeAiEAruWYHv1egttNvunjTjWUpOf+o1XUYDxUVEXQHibpxb4="}]},"maintainers":[{"name":"bradleymeck","email":"bradley.meck@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/thenables-1.0.0.tgz_1507217987894_0.6796229439787567"}},"1.0.1":{"name":"@bradleymeck/thenables","version":"1.0.1","description":"some simple utilities for awaiting","scripts":{"test":"set -e; for x in test/*; do node $x; done"},"keywords":["async","await","thenable"],"repository":{"type":"git","url":"git+https://github.com/bmeck/thenables.git"},"author":{"name":"bradleymeck"},"license":"MIT","files":["iter.js"],"gitHead":"7f829ff7e69e50b741f1701af56da4aeffe5c3f2","bugs":{"url":"https://github.com/bmeck/thenables/issues"},"homepage":"https://github.com/bmeck/thenables#readme","_id":"@bradleymeck/thenables@1.0.1","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"bradleymeck","email":"bradley.meck@gmail.com"},"dist":{"integrity":"sha512-wfEvWEMsV4XSRnaR9bycdBTZacac3TZc8eOKqMQaqfCrSVNrx7SQ6spnGIvCMrZBk/EOxNNXdQhiQx8LTF0kTQ==","shasum":"b335340b85e416c84834a7008cf4315f8eb47ecc","tarball":"https://registry.npmjs.org/@bradleymeck/thenables/-/thenables-1.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHtsr5etg+7k0hqKwNtzBIFcbMMRBLdJoESI1OhuxCbZAiB4GPlyvzLM3Xm+LY5GLLR7fEpj6e6aRTx6BPD2VQJ5Yw=="}]},"maintainers":[{"name":"bradleymeck","email":"bradley.meck@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/thenables-1.0.1.tgz_1507218621462_0.915256300708279"}},"1.1.0":{"name":"@bradleymeck/thenables","version":"1.1.0","description":"some simple utilities for awaiting","scripts":{"test":"set -e; for x in test/*; do node $x; done"},"keywords":["async","await","thenable"],"repository":{"type":"git","url":"git+https://github.com/bmeck/thenables.git"},"author":{"name":"bradleymeck"},"license":"MIT","files":["iter.js"],"gitHead":"0ba540532ed9b76ec4e56ce8b208c24e1cc157e4","bugs":{"url":"https://github.com/bmeck/thenables/issues"},"homepage":"https://github.com/bmeck/thenables#readme","_id":"@bradleymeck/thenables@1.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"bradleymeck","email":"bradley.meck@gmail.com"},"dist":{"integrity":"sha512-JA/e71RAIhbloJDjpvfhEHR3yu7yYeh/nd+7dYCqnKkMRDqltFus9LCEu5CQNcJrXkL3ue3zA0I3+Kez1fU10A==","shasum":"7953f41ed0e33ad9c50d44a3703677470536888e","tarball":"https://registry.npmjs.org/@bradleymeck/thenables/-/thenables-1.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEq9DeaDJ03/J2RWKMleCkUTLLgagOYXuJdoryaa0cxtAiA2NKoGamye7wKGnKt+U+KyQ1DxmRcAPmTtayQhZ49HfA=="}]},"maintainers":[{"name":"bradleymeck","email":"bradley.meck@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/thenables-1.1.0.tgz_1507222272645_0.25815632613375783"}},"1.1.1":{"name":"@bradleymeck/thenables","version":"1.1.1","description":"some simple utilities for awaiting","scripts":{"test":"set -e; for x in test/*; do node $x; done"},"keywords":["async","await","thenable"],"repository":{"type":"git","url":"git+https://github.com/bmeck/thenables.git"},"author":{"name":"bradleymeck"},"license":"MIT","files":["iter.js","semaphore.js"],"gitHead":"4dcf1095dd0d1cba9b776094b99c9bb8334f36ab","bugs":{"url":"https://github.com/bmeck/thenables/issues"},"homepage":"https://github.com/bmeck/thenables#readme","_id":"@bradleymeck/thenables@1.1.1","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"bradleymeck","email":"bradley.meck@gmail.com"},"dist":{"integrity":"sha512-ZyfYmxxkmMmaDTk/gHVORGn/twcIAY85qCJVHFUraow30J1Fyp/4OsKJCyO9dviXmDdrXQldo7V4s/dZrpKRvQ==","shasum":"538365c773f76f1bf0daf51e81d40c40f195d4a3","tarball":"https://registry.npmjs.org/@bradleymeck/thenables/-/thenables-1.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB0ZGH5LQwWnNCnakIIfpbMhCUwa1vurZy7ClmtPGRDTAiA0OQuBh5tAEs7rkOIH3/mkfvwZvJ3TsFhvMCMHptMc+Q=="}]},"maintainers":[{"name":"bradleymeck","email":"bradley.meck@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/thenables-1.1.1.tgz_1507222897398_0.7271212704945356"}}},"readme":"# thenables\n\nThere is no index/main file. Grab the utilities as needed.\n\n**DO NOT** return thenables from async functions as they will be turned into regular Promises.\n\n# iter\n\nA thenable which is inteded to have multiple values and a done condition.\n\n## iter.Iter\n\nA flexible way to generate an iter.\n\n```js\nconst fs = require('fs');\nconst iter = require('./iter');\n;(async () => {\n  const ee = fs.createReadStream(process.argv[2]);\n  const stream = iter.Iter((onvalue, ondone, onerror) => {\n    stream.on('data', onvalue);\n    stream.on('error', (err) => {\n      stream.removeListener('data', onvalue);\n      stream.removeListener('done', ondone);\n      onerror(err);\n    });\n    stream.on('close', (value) => {\n      stream.removeListener('data', onvalue);\n      stream.removeListener('error', onerror);\n      ondone(value);\n    });\n  });\n  let value, done;\n  let buffered = [];\n  while({value, done} = await stream, !done) {\n    buffered.push(value);\n  }\n  const body = require('buffer').Buffer.concat(buffered);\n  console.log(body.toString());\n})();\n```\n\n## iter.fromReadStream\n\nSimplifies read stream consumption.\n\n```js\nconst fs = require('fs');\nconst iter = require('./iter');\n;(async () => {\n  const ee = fs.createReadStream(process.argv[2]);\n  const stream = iter.fromReadStream(ee);\n  let value, done;\n  let buffered = [];\n  while({value, done} = await stream, !done) {\n    buffered.push(value);\n  }\n  const body = require('buffer').Buffer.concat(buffered);\n  console.log(body.toString());\n})();\n```\n\n# semaphore\n\n## semaphore.ExclusiveSemaphore\n\nThe most general use Semaphore, it expects to stay in the same thread.\n\n```js\nconst ExclusiveSemaphore = require('./semaphore').ExclusiveSemaphore;\nconst semaphore = new ExclusiveSemaphore(+process.argv[2] || 1);\n;(async () => {\n  let {unlock} = await semaphore;\n  console.log('start: A');\n  await {\n    then: f => setTimeout(f, 1000)\n  }\n  console.log('close: A');\n  unlock();\n})();\n```","maintainers":[{"name":"bradleymeck","email":"bradley.meck@gmail.com"}],"time":{"modified":"2022-04-04T20:20:09.073Z","created":"2017-10-05T15:39:48.781Z","1.0.0":"2017-10-05T15:39:48.781Z","1.0.1":"2017-10-05T15:50:22.334Z","1.1.0":"2017-10-05T16:51:12.712Z","1.1.1":"2017-10-05T17:01:38.054Z"},"keywords":["async","await","thenable"],"author":{"name":"bradleymeck"},"license":"MIT","readmeFilename":"README.md","homepage":"https://github.com/bmeck/thenables#readme","repository":{"type":"git","url":"git+https://github.com/bmeck/thenables.git"},"bugs":{"url":"https://github.com/bmeck/thenables/issues"}}