summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2016-03-31 11:23:27 -0700
committerAlexander Early <alexander.early@gmail.com>2016-03-31 11:23:27 -0700
commit162976837e5585d6eb595563fe78c80526f667c2 (patch)
treed2b7243ca26a3210bfd197dbe1e46f0573d7fbe3
parentedfef24490369d814cdf71af6438495b291846d7 (diff)
downloadasync-162976837e5585d6eb595563fe78c80526f667c2.tar.gz
ensure the fn can be GCed in once()
-rw-r--r--lib/internal/once.js5
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;
};
}