{"analyzedAt":"2022-07-15T01:57:33.936Z","collected":{"metadata":{"name":"promise-channel","scope":"unscoped","version":"2.0.1","description":"Like Go Channels but using JavaScript Promises.","keywords":["channel","go","promise","scp"],"date":"2017-12-28T03:42:42.650Z","author":{"name":"rangermauve"},"publisher":{"username":"rangermauve","email":"rangermauve@hotmail.com"},"maintainers":[{"username":"rangermauve","email":"rangermauve@hotmail.com"}],"repository":{"type":"git","url":"git+https://github.com/RangerMauve/promise-channel.git"},"links":{"npm":"https://www.npmjs.com/package/promise-channel","homepage":"https://github.com/RangerMauve/promise-channel","repository":"https://github.com/RangerMauve/promise-channel","bugs":"https://github.com/RangerMauve/promise-channel/issues"},"license":"ISC","dependencies":{"promise-defer":"^1.0.0"},"devDependencies":{"assert-rejected":"^1.0.0","blue-tape":"^0.1.10"},"releases":[{"from":"2022-06-15T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":1},{"from":"2022-04-16T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":1},{"from":"2022-01-16T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":1},{"from":"2021-07-15T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":1},{"from":"2020-07-15T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":1}],"hasTestScript":true,"readme":"# promise-channel\r\nLike Go Channels, but using JavaScript Promises.\r\n\r\nSupports [async-await](https://github.com/tc39/ecmascript-asyncawait) and [async-iteration](https://github.com/tc39/proposal-async-iteration).\r\n```\r\nnpm install --save promise-channel\r\n```\r\n\r\n## Example\r\nThis should look pretty familiar if you've used [goroutines](https://gobyexample.com/goroutines) with [go channels](https://tour.golang.org/concurrency/2);\r\n\r\n```JavaScript\r\nimport Channel from \"promise-channel\";\r\n\r\nvar channel = new Channel();\r\n\r\nchannel.onClose.then(function(){\r\n    console.log(\"Closed\");\r\n});\r\n\r\nPromise.all([\r\n    alice(channel),\r\n    bob(channel),\r\n]).then(function() {\r\n    channel.close();\r\n}).catch(function (e) {\r\n    console.error(e.stack);\r\n});\r\n\r\nasync function alice(channel) {\r\n    var name = await channel.read();\r\n    await channel.write(\"Hello, \" + name);\r\n}\r\n\r\nasync function bob(channel) {\r\n    await channel.write(\"World\");\r\n    var greeting = await channel.read();\r\n\r\n    console.log(greeting);\r\n}\r\n```\r\n\r\n## API\r\n### `Channel`\r\nThe module exports the Channel class which should be intstantiated with `new`\r\n\r\n### `channel.read()`\r\nAttempts to read from the channel. Will throw if the channel is closed.\r\n\r\n#### return\r\nA promise which resolves to whatever value is written to the channel next.\r\n\r\n### `channel.write(value)`\r\nWrites data to the channel. Will throw if the channel is closed.\r\n\r\n#### arguments\r\n- `value` : The value to write to the channel\r\n\r\n#### return\r\nA promise which resolves once something has read from the channel.\r\n\r\n### `channel.close(reason)`\r\nCloses the channel so that all pending and subsequent reads/writes will be rejected.\r\n\r\n### arguments\r\n- `reason` : An optional reason for closing the channel, will be passed to the onClose promise\r\n\r\n### `channel.open`\r\nBoolean property which tells you whether the channel is currently open\r\n\r\n### `channel.onClose`\r\nRead-only promise that resolves once the channel is closed"},"npm":{"downloads":[{"from":"2022-07-14T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":0},{"from":"2022-07-08T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":36},{"from":"2022-06-15T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":202},{"from":"2022-04-16T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":719},{"from":"2022-01-16T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":1028},{"from":"2021-07-15T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":2101}],"starsCount":1},"github":{"starsCount":4,"forksCount":0,"subscribersCount":1,"issues":{"count":0,"openCount":0,"distribution":{"3600":0,"10800":0,"32400":0,"97200":0,"291600":0,"874800":0,"2624400":0,"7873200":0,"23619600":0,"70858800":0,"212576400":0},"isDisabled":false},"contributors":[{"username":"RangerMauve","commitsCount":7}],"commits":[{"from":"2022-07-08T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":0},{"from":"2022-06-15T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":0},{"from":"2022-04-16T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":0},{"from":"2022-01-16T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":0},{"from":"2021-07-15T00:00:00.000Z","to":"2022-07-15T00:00:00.000Z","count":0}]},"source":{"files":{"readmeSize":1891,"testsSize":2554,"hasNpmIgnore":true}}},"evaluation":{"quality":{"carefulness":0.7899999999999999,"tests":0.6,"health":1,"branding":0},"popularity":{"communityInterest":7,"downloadsCount":239.66666666666666,"downloadsAcceleration":0.23302891933028924,"dependentsCount":0},"maintenance":{"releasesFrequency":0.9,"commitsFrequency":0.9,"openIssues":0.9,"issuesDistribution":0.9}},"score":{"final":0.6119634902935762,"detail":{"quality":0.8196964067285537,"popularity":0.04598936111378895,"maintenance":0.9998808339576686}}}