diff options
author | Alex Early <alexander.early@gmail.com> | 2019-03-09 21:56:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-09 21:56:58 -0800 |
commit | cc7a84ffedba2c326668f604384d730cc09fd8e6 (patch) | |
tree | fdb2bd2987cb93ac43e4e76a1e5417dc48694298 /lib/reflect.js | |
parent | b418cb788f1a57bd34e43ac2a72768e0f3561d36 (diff) | |
download | async-cc7a84ffedba2c326668f604384d730cc09fd8e6.tar.gz |
fix: Reflect passes value on error (#1633)
* Reflects any values passed even if function has error
* fix async function tests
Diffstat (limited to 'lib/reflect.js')
-rw-r--r-- | lib/reflect.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/reflect.js b/lib/reflect.js index acd3043..d2930a0 100644 --- a/lib/reflect.js +++ b/lib/reflect.js @@ -44,14 +44,18 @@ export default function reflect(fn) { var _fn = wrapAsync(fn); return initialParams(function reflectOn(args, reflectCallback) { args.push((error, ...cbArgs) => { + let retVal = {}; if (error) { - return reflectCallback(null, { error }); + retVal.error = error; } - var value = cbArgs; - if (cbArgs.length <= 1) { - [value] = cbArgs + if (cbArgs.length > 0){ + var value = cbArgs; + if (cbArgs.length <= 1) { + [value] = cbArgs; + } + retVal.value = value; } - reflectCallback(null, { value }); + reflectCallback(null, retVal); }); return _fn.apply(this, args); |