Ensure after n parameter is coerced from NaN to 0 (#4430)

* Enable after tests

* Ensure after n parameter is coerced from NaN to 0
This commit is contained in:
Luiz Américo
2019-08-22 11:46:46 -03:00
committed by John-David Dalton
parent 8b441a506b
commit 2cf08be625
3 changed files with 32 additions and 31 deletions

View File

@@ -19,6 +19,7 @@ function after(n, func) {
if (typeof func != 'function') {
throw new TypeError('Expected a function')
}
n = n || 0
return function(...args) {
if (--n < 1) {
return func.apply(this, args)