{"_id":"semaphore","_rev":"2954818","name":"semaphore","description":"semaphore for node","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"abrkn","email":""},{"name":"addaleax","email":"anna@addaleax.net"}],"time":{"modified":"2023-04-27T03:55:09.000Z","created":"2012-05-25T08:24:21.263Z","1.1.0":"2017-08-08T16:22:24.146Z","1.0.5":"2016-02-27T21:29:41.335Z","1.0.4":"2016-02-18T20:03:23.362Z","1.0.3":"2015-06-11T02:29:38.204Z","1.0.2":"2015-04-01T07:58:29.412Z","1.0.1":"2012-11-05T12:43:20.133Z","1.0.0":"2012-05-25T08:24:21.263Z"},"users":{},"repository":{"type":"git","url":"git+ssh://git@github.com/abrkn/semaphore.js.git"},"versions":{"1.1.0":{"name":"semaphore","version":"1.1.0","description":"semaphore for node","engines":{"node":">=0.8.0"},"main":"./lib/semaphore.js","dependencies":{},"devDependencies":{"mocha":"2.x.x","should":"8.x.x"},"homepage":"https://github.com/abrkn/semaphore.js","repository":{"type":"git","url":"git+ssh://git@github.com/abrkn/semaphore.js.git"},"scripts":{"test":"mocha"},"gitHead":"88a33875b168cc7b5943d7fe987c36d08321d252","bugs":{"url":"https://github.com/abrkn/semaphore.js/issues"},"_id":"semaphore@1.1.0","_npmVersion":"5.3.0-canary.0","_nodeVersion":"9.0.0-pre","_npmUser":{"name":"addaleax","email":"anna@addaleax.net"},"dist":{"shasum":"aaad8b86b20fe8e9b32b16dc2ee682a8cd26a8aa","size":2817,"noattachment":false,"key":"/semaphore/-/semaphore-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/semaphore/download/semaphore-1.1.0.tgz"},"maintainers":[{"name":"abrkn","email":""},{"name":"addaleax","email":"anna@addaleax.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/semaphore-1.1.0.tgz_1502209343262_0.5487388467881829"},"directories":{},"publish_time":1502209344146,"_hasShrinkwrap":false,"_cnpm_publish_time":1502209344146,"_cnpmcore_publish_time":"2021-12-16T15:32:41.093Z"},"1.0.5":{"name":"semaphore","version":"1.0.5","description":"semaphore for node","engines":{"node":">=0.8.0"},"main":"./lib/semaphore.js","dependencies":{},"devDependencies":{"mocha":"2.x.x","should":"8.x.x"},"homepage":"https://github.com/abrkn/semaphore.js","repository":{"type":"git","url":"git+ssh://git@github.com/abrkn/semaphore.js.git"},"scripts":{"test":"mocha"},"gitHead":"4b7471c5efc348b3279621e58e0b47b55ac60040","bugs":{"url":"https://github.com/abrkn/semaphore.js/issues"},"_id":"semaphore@1.0.5","_shasum":"b492576e66af193db95d65e25ec53f5f19798d60","_from":".","_npmVersion":"3.3.12","_nodeVersion":"6.0.0-pre","_npmUser":{"name":"sqrt","email":"sqrt@entless.org"},"maintainers":[{"name":"abrkn","email":""},{"name":"addaleax","email":"anna@addaleax.net"}],"dist":{"shasum":"b492576e66af193db95d65e25ec53f5f19798d60","size":2819,"noattachment":false,"key":"/semaphore/-/semaphore-1.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/semaphore/download/semaphore-1.0.5.tgz"},"_npmOperationalInternal":{"host":"packages-9-west.internal.npmjs.com","tmp":"tmp/semaphore-1.0.5.tgz_1456608578363_0.32074872963130474"},"directories":{},"publish_time":1456608581335,"_hasShrinkwrap":true,"_cnpm_publish_time":1456608581335,"_cnpmcore_publish_time":"2021-12-16T15:32:41.287Z"},"1.0.4":{"name":"semaphore","version":"1.0.4","description":"semaphore for node","engines":{"node":">=0.8.0"},"main":"./lib/semaphore.js","dependencies":{},"devDependencies":{"mocha":"2.x.x","should":"8.x.x"},"homepage":"https://github.com/abrkn/semaphore.js","repository":{"type":"git","url":"git+ssh://git@github.com/abrkn/semaphore.js.git"},"scripts":{"test":"mocha"},"gitHead":"bfcf35defab1e0f7040c16a08f0f7f1f32770214","bugs":{"url":"https://github.com/abrkn/semaphore.js/issues"},"_id":"semaphore@1.0.4","_shasum":"1f45e3075b2253d515a960a2a408360a39c267a8","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"abrkn","email":"a@abrkn.com"},"maintainers":[{"name":"abrkn","email":""},{"name":"addaleax","email":"anna@addaleax.net"}],"dist":{"shasum":"1f45e3075b2253d515a960a2a408360a39c267a8","size":2711,"noattachment":false,"key":"/semaphore/-/semaphore-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/semaphore/download/semaphore-1.0.4.tgz"},"_npmOperationalInternal":{"host":"packages-6-west.internal.npmjs.com","tmp":"tmp/semaphore-1.0.4.tgz_1455825800956_0.21430362574756145"},"directories":{},"publish_time":1455825803362,"_hasShrinkwrap":true,"_cnpm_publish_time":1455825803362,"_cnpmcore_publish_time":"2021-12-16T15:32:41.489Z"},"1.0.3":{"name":"semaphore","version":"1.0.3","description":"semaphore for node","engine":"node >= 0.6.0","main":"./lib/semaphore.js","dependencies":{},"devDependencies":{"mocha":"2.2.x","should":"6.0.x"},"homepage":"https://github.com/abrkn/semaphore.js","repository":{"type":"git","url":"git@github.com:abrkn/semaphore.js.git"},"scripts":{"test":"mocha"},"gitHead":"a50de37da48aeafd580b8f283710cdca81d0bae1","bugs":{"url":"https://github.com/abrkn/semaphore.js/issues"},"_id":"semaphore@1.0.3","_shasum":"77dfc0180ebe7074b5176e7d64be5ef75d69736c","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"sqrt","email":"sqrt@entless.org"},"maintainers":[{"name":"abrkn","email":""},{"name":"addaleax","email":"anna@addaleax.net"}],"dist":{"shasum":"77dfc0180ebe7074b5176e7d64be5ef75d69736c","size":2548,"noattachment":false,"key":"/semaphore/-/semaphore-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/semaphore/download/semaphore-1.0.3.tgz"},"directories":{},"publish_time":1433989778204,"_hasShrinkwrap":false,"_cnpm_publish_time":1433989778204,"_cnpmcore_publish_time":"2021-12-16T15:32:41.695Z"},"1.0.2":{"name":"semaphore","version":"1.0.2","description":"semaphore for node","engine":"node >= 0.6.0","main":"./lib/semaphore.js","dependencies":{},"devDependencies":{"mocha":"1.0.x","should":"0.6.x"},"homepage":"https://github.com/abrkn/semaphore.js","repository":{"type":"git","url":"git@github.com:abrkn/semaphore.js.git"},"scripts":{"test":"mocha"},"gitHead":"fe309c4ae083099675cc0013ca83808f347e8ed6","bugs":{"url":"https://github.com/abrkn/semaphore.js/issues"},"_id":"semaphore@1.0.2","_shasum":"5da5e45359acb5268818a3221665b3818e35c5c7","_from":".","_npmVersion":"2.7.1","_nodeVersion":"1.6.2","_npmUser":{"name":"abrkn","email":"a@abrkn.com"},"maintainers":[{"name":"abrkn","email":""},{"name":"addaleax","email":"anna@addaleax.net"}],"dist":{"shasum":"5da5e45359acb5268818a3221665b3818e35c5c7","size":2309,"noattachment":false,"key":"/semaphore/-/semaphore-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/semaphore/download/semaphore-1.0.2.tgz"},"directories":{},"publish_time":1427875109412,"_hasShrinkwrap":false,"_cnpm_publish_time":1427875109412,"_cnpmcore_publish_time":"2021-12-16T15:32:41.908Z"},"1.0.1":{"name":"semaphore","version":"1.0.1","description":"semaphore for node","engine":"node >= 0.6.0","main":"./lib/semaphore.js","dependencies":{},"devDependencies":{"mocha":"1.0.x","should":"0.6.x"},"homepage":"https://github.com/abrkn/semaphore.js","readmeFilename":"README.md","_id":"semaphore@1.0.1","dist":{"shasum":"74e3181df4cba653d20d5b0ab04a78efc2cf83ea","size":2080,"noattachment":false,"key":"/semaphore/-/semaphore-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/semaphore/download/semaphore-1.0.1.tgz"},"_npmVersion":"1.1.65","_npmUser":{"name":"abrkn","email":"a@abrkn.com"},"maintainers":[{"name":"abrkn","email":""},{"name":"addaleax","email":"anna@addaleax.net"}],"directories":{},"publish_time":1352119400133,"_hasShrinkwrap":false,"_cnpm_publish_time":1352119400133,"_cnpmcore_publish_time":"2021-12-16T15:32:42.164Z"},"1.0.0":{"name":"semaphore","version":"1.0.0","description":"semaphore for node","engine":"node >= 0.6.0","main":"./lib/semaphore.js","dependencies":{},"devDependencies":{"mocha":"1.0.x","should":"0.6.x"},"homepage":"https://github.com/abrkn/semaphore.js","_npmUser":{"name":"abrkn","email":"andreas@opuno.com"},"_id":"semaphore@1.0.0","optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.16","_nodeVersion":"v0.6.15","_defaultsLoaded":true,"dist":{"shasum":"a9703f9334f4caf18d97c2874bde0f441bf7bca2","size":2036,"noattachment":false,"key":"/semaphore/-/semaphore-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/semaphore/download/semaphore-1.0.0.tgz"},"maintainers":[{"name":"abrkn","email":""},{"name":"addaleax","email":"anna@addaleax.net"}],"directories":{},"publish_time":1337934261263,"_hasShrinkwrap":false,"_cnpm_publish_time":1337934261263,"_cnpmcore_publish_time":"2021-12-16T15:32:42.425Z"}},"readme":"semaphore.js\n============\n\n[![Build Status](https://travis-ci.org/abrkn/semaphore.js.svg?branch=master)](https://travis-ci.org/abrkn/semaphore.js)\n\nInstall:\nnpm install semaphore\n\nLimit simultaneous access to a resource.\n\n```javascript\n// Create\nvar sem = require('semaphore')(capacity);\n\n// Take\nsem.take(fn[, n=1])\nsem.take(n, fn)\n\n// Leave\nsem.leave([n])\n\n// Available\nsem.available([n])\n```\n\n\n```javascript\n// Limit concurrent db access\nvar sem = require('semaphore')(1);\nvar server = require('http').createServer(req, res) {\n\tsem.take(function() {\n\t\texpensive_database_operation(function(err, res) {\n\t\t\tsem.leave();\n\n\t\t\tif (err) return res.end(\"Error\");\n\n\t\t\treturn res.end(res);\n\t\t});\n\t});\n});\n```\n\n```javascript\n// 2 clients at a time\nvar sem = require('semaphore')(2);\nvar server = require('http').createServer(req, res) {\n\tres.write(\"Then good day, madam!\");\n\n\tsem.take(function() {\n\t\tres.end(\"We hope to see you soon for tea.\");\n\t\tsem.leave();\n\t});\n});\n```\n\n```javascript\n// Rate limit\nvar sem = require('semaphore')(10);\nvar server = require('http').createServer(req, res) {\n\tsem.take(function() {\n\t\tres.end(\".\");\n\t\t\n\t\tsetTimeout(sem.leave, 500)\n\t});\n});\n```\n\nLicense\n===\n\nMIT\n","_attachments":{},"homepage":"https://github.com/abrkn/semaphore.js","bugs":{"url":"https://github.com/abrkn/semaphore.js/issues"}}