diff options
Diffstat (limited to 'lib/reflect.js')
-rw-r--r-- | lib/reflect.js | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/reflect.js b/lib/reflect.js index f50d817..b1cbdc6 100644 --- a/lib/reflect.js +++ b/lib/reflect.js @@ -1,5 +1,4 @@ import initialParams from './internal/initialParams'; -import slice from './internal/slice'; import wrapAsync from './internal/wrapAsync'; /** @@ -44,18 +43,15 @@ import wrapAsync from './internal/wrapAsync'; export default function reflect(fn) { var _fn = wrapAsync(fn); return initialParams(function reflectOn(args, reflectCallback) { - args.push(function callback(error, cbArg) { + args.push((error, ...cbArgs) => { if (error) { - reflectCallback(null, { error: error }); - } else { - var value; - if (arguments.length <= 2) { - value = cbArg - } else { - value = slice(arguments, 1); - } - reflectCallback(null, { value: value }); + return reflectCallback(null, { error }); } + var value = cbArgs; + if (cbArgs.length <= 1) { + value = cbArgs[0] + } + reflectCallback(null, { value }); }); return _fn.apply(this, args); |