diff --git a/lib/internal/awaitify.js b/lib/internal/awaitify.js index 9c548ceb5..811ff61a7 100644 --- a/lib/internal/awaitify.js +++ b/lib/internal/awaitify.js @@ -1,6 +1,7 @@ // conditionally promisify a function. // only return a promise if a callback is omitted -export default function awaitify (asyncFn, arity = asyncFn.length) { +export default function awaitify (asyncFn, arity) { + if (!arity) arity = asyncFn.length; if (!arity) throw new Error('arity is undefined') function awaitable (...args) { if (typeof args[arity - 1] === 'function') {