diff --git a/src/index.js b/src/index.js index 99449be..8f10583 100644 --- a/src/index.js +++ b/src/index.js @@ -82,9 +82,10 @@ function throttle, Value>( return result } - async function wrapper(...args: Args): Promise { + function wrapper(...args: Args): Promise { nextArgs = nextArgs ? getNextArgs(nextArgs, args) : args - if (!nextArgs) throw new Error('unexpected error: nextArgs is null') + if (!nextArgs) + return Promise.reject(new Error('unexpected error: nextArgs is null')) if (nextInvocation) return nextInvocation return (nextInvocation = (delay || Promise.resolve()).then(invoke)) }