diff options
author | Alexander Early <alexander.early@gmail.com> | 2016-03-31 11:23:27 -0700 |
---|---|---|
committer | Alexander Early <alexander.early@gmail.com> | 2016-03-31 11:23:27 -0700 |
commit | 162976837e5585d6eb595563fe78c80526f667c2 (patch) | |
tree | d2b7243ca26a3210bfd197dbe1e46f0573d7fbe3 | |
parent | edfef24490369d814cdf71af6438495b291846d7 (diff) | |
download | async-162976837e5585d6eb595563fe78c80526f667c2.tar.gz |
ensure the fn can be GCed in once()
-rw-r--r-- | lib/internal/once.js | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/internal/once.js b/lib/internal/once.js index fabdffd..11678dc 100644 --- a/lib/internal/once.js +++ b/lib/internal/once.js @@ -1,8 +1,7 @@ export default function once(fn) { - var called = false; return function () { - if (called) return; - called = true; + if (fn === null) return; fn.apply(this, arguments); + fn = null; }; } |