Comparing version 0.8.0 to 0.8.1
@@ -270,3 +270,3 @@ // Load modules | ||
return function (callback) { | ||
return function (next) { | ||
@@ -278,6 +278,6 @@ var result = null; | ||
catch (err) { | ||
return callback(err); | ||
return next(err); | ||
} | ||
return callback(null, result); | ||
return next(null, result); | ||
}; | ||
@@ -453,6 +453,6 @@ })(obj[i]); | ||
exports.toss = function (condition /*, [message], callback */) { | ||
exports.toss = function (condition /*, [message], next */) { | ||
var message = (arguments.length === 3 ? arguments[1] : ''); | ||
var callback = (arguments.length === 3 ? arguments[2] : arguments[1]); | ||
var next = (arguments.length === 3 ? arguments[2] : arguments[1]); | ||
@@ -464,3 +464,3 @@ var err = (message instanceof Error ? message : (message ? new Error(message) : (condition instanceof Error ? condition : new Error()))); | ||
return callback(err); | ||
return next(err); | ||
} | ||
@@ -562,1 +562,14 @@ }; | ||
}; | ||
exports.nextTick = function (callback) { | ||
return function () { | ||
var args = arguments; | ||
process.nextTick(function () { | ||
callback.apply(null, args); | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "hoek", | ||
"description": "General purpose node utilities", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "contributors":[ |
@@ -982,3 +982,31 @@ // Load modules | ||
}); | ||
describe('#nextTick', function () { | ||
it('calls the provided callback on nextTick', function (done) { | ||
var a = 0; | ||
var inc = function (step, next) { | ||
a += step; | ||
next(); | ||
}; | ||
var ticked = Hoek.nextTick(inc); | ||
ticked(5, function () { | ||
expect(a).to.equal(6); | ||
done(); | ||
}); | ||
expect(a).to.equal(0); | ||
inc(1, function () { | ||
expect(a).to.equal(1); | ||
}); | ||
}); | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
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
97033
1257