Permalink
Browse files

no need for optional callback in async() now that there is fn()

  • Loading branch information...
1 parent bb62aca commit 929028d240bcfcd3e2fc9b3ea551a398d1e37769 @jmar777 committed Dec 9, 2013
Showing with 4 additions and 6 deletions.
  1. +1 −2 lib/suspend.js
  2. +3 −4 test/suspend.async.js
View
@@ -14,8 +14,7 @@ var suspend = module.exports = function async(generator) {
var callback = arguments[arguments.length - 1],
args = Array.prototype.slice.call(arguments, 0, -1);
- // callback is only optional if there are no args
- if (arguments.length && typeof callback !== 'function') {
+ if (typeof callback !== 'function') {
throw new Error('Last argument must be a callback function.');
}
View
@@ -33,8 +33,8 @@ describe('suspend.async(fn*)()', function() {
async(function*() {})(done);
});
- it('should let callback be optional when no arguments are provided', function(done) {
- assert.doesNotThrow(async(function*() {}));
+ it('should throw if callback argument is missing', function(done) {
+ assert.throws(async(function*() {}), /must be a callback/);
done();
});
@@ -49,8 +49,7 @@ describe('suspend.async(fn*)()', function() {
it('should preserve `this` binding', function(done) {
async(function*() {
assert.strictEqual('bar', this.foo);
- done();
- }).call({ foo: 'bar' });
+ }).call({ foo: 'bar' }, done);
});
it('should support input parameters', function(done) {

0 comments on commit 929028d

Please sign in to comment.