Comparing version 1.0.1 to 1.0.2
@@ -1,2 +0,2 @@ | ||
var util = require('util'); | ||
'use strict'; | ||
@@ -6,3 +6,3 @@ module.exports = function(capacity) { | ||
capacity: capacity || 1, | ||
current: 0, | ||
current: 0, | ||
queue: [], | ||
@@ -13,4 +13,7 @@ | ||
if (typeof arguments[0] == 'function') item.task = arguments[0]; | ||
else item.n = arguments[0]; | ||
if (typeof arguments[0] == 'function') { | ||
item.task = arguments[0]; | ||
} else { | ||
item.n = arguments[0]; | ||
} | ||
@@ -52,3 +55,3 @@ if (arguments.length >= 2) { | ||
semaphore.queue = semaphore.queue.splice(1); | ||
semaphore.queue.shift(); | ||
semaphore.current += item.n; | ||
@@ -60,3 +63,3 @@ | ||
return semaphore | ||
return semaphore; | ||
}; |
{ | ||
"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" | ||
} | ||
"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" | ||
} | ||
} |
semaphore.js | ||
============ | ||
[![Build Status](https://travis-ci.org/abrkn/semaphore.js.svg?branch=master)](https://travis-ci.org/abrkn/semaphore.js) | ||
Install: | ||
@@ -61,2 +63,7 @@ npm install semaphore | ||
}); | ||
``` | ||
``` | ||
License | ||
=== | ||
MIT |
@@ -144,3 +144,3 @@ var should = require('should'); | ||
describe("should respect number", function() { | ||
it(function(done) { | ||
it("should fail when taking more than the capacity allows", function(done) { | ||
var s = semaphore(1); | ||
@@ -155,3 +155,3 @@ | ||
it(function(done) { | ||
it("should work fine with correct input values", function(done) { | ||
var s = semaphore(10); // 10 | ||
@@ -163,6 +163,8 @@ | ||
s.take(5, done); // 0 | ||
s.take(5, function() { | ||
return done() | ||
}); // 0 | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
6598
6
178
69
0