diff --git a/index.js b/index.js index 8c875a5..05e3407 100644 --- a/index.js +++ b/index.js @@ -150,12 +150,14 @@ Kareem.prototype.wrap = function(name, fn, context, args) { fn.apply(context, args.slice(0, end).concat(function() { if (arguments[0]) { + // Assume error return typeof lastArg === 'function' ? lastArg(arguments[0]) : undefined; } - _this.execPost(name, context, args.slice(0, end), function() { + var argsWithoutError = Array.prototype.slice.call(arguments, 1); + _this.execPost(name, context, argsWithoutError, function() { if (arguments[0]) { return typeof lastArg === 'function' ? lastArg(arguments[0]) : diff --git a/test/examples.test.js b/test/examples.test.js index 152cd3d..323e585 100644 --- a/test/examples.test.js +++ b/test/examples.test.js @@ -208,7 +208,7 @@ describe('wrap()', function() { assert.equal(4, obj.eggs); assert.equal(false, obj.waffles); assert.equal(undefined, obj.tofu); - callback(); + callback(null, o); }, obj, args);