dry-underscore
Advanced tools
Comparing version 0.21.1 to 0.21.2
@@ -828,3 +828,6 @@ "use strict"; | ||
running = true; | ||
return f.apply(this, _.concat(function(){ running = false; }, _.a(arguments))); | ||
var release = function(){ running = false; }; | ||
release.before = function(f){ return(function(){ release(); var ret = f.apply(this, arguments); return(ret); }); }; | ||
release.after = function(f){ return(function(){ var ret = f.apply(this, arguments); release(); return(ret); }); }; | ||
return f.apply(this, _.concat(release, _.a(arguments))); | ||
} | ||
@@ -831,0 +834,0 @@ } |
@@ -249,2 +249,59 @@ "use strict"; | ||
test("lock.before", function(callback){ | ||
var rel = null; | ||
var count = 0; | ||
var before_count = 0; | ||
var unlocked_f = function(release, one, two, three){ rel = release.before(function(){ before_count++; }); count++; eq(one, 1); eq(two, 2); eq(three, 3); return(5); } | ||
var f = _.lock(unlocked_f); | ||
_.nextTick(function(){ | ||
eq(5, f(1,2,3)); | ||
_.nextTick(function(){ | ||
eq(undefined, f()); | ||
_.nextTick(function(){ | ||
eq(undefined, f()); | ||
_.nextTick(function(){ | ||
rel(); | ||
eq(5, f(1,2,3)); | ||
eq(count, 2); | ||
eq(before_count, 1); | ||
callback(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
test("lock.after", function(callback){ | ||
var rel = null; | ||
var count = 0; | ||
var after_count = 0; | ||
var unlocked_f = function(release, one, two, three){ rel = release.after(function(){ after_count++; }); count++; eq(one, 1); eq(two, 2); eq(three, 3); return(5); } | ||
var f = _.lock(unlocked_f); | ||
_.nextTick(function(){ | ||
eq(5, f(1,2,3)); | ||
_.nextTick(function(){ | ||
eq(undefined, f()); | ||
_.nextTick(function(){ | ||
eq(undefined, f()); | ||
_.nextTick(function(){ | ||
rel(); | ||
eq(5, f(1,2,3)); | ||
eq(count, 2); | ||
eq(after_count, 1); | ||
callback(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
test("iso_date", function(){ | ||
@@ -251,0 +308,0 @@ var now = _.date(); |
{ | ||
"name": "dry-underscore", | ||
"version": "0.21.1", | ||
"version": "0.21.2", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "deep-diff": { |
{ | ||
"name": "dry-underscore", | ||
"version": "0.21.1", | ||
"version": "0.21.2", | ||
"main": "./index/node.index.js", | ||
@@ -5,0 +5,0 @@ "description": "The DRY Undescore Library", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1920238
23205