Last active
August 4, 2019 07:43
-
-
Save michaelficarra/e43d7d205613a6910936bc5408577ff0 to your computer and use it in GitHub Desktop.
a loose approximation of a potential Function.prototype.once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.once = function () { | |
let fn = this; | |
let called = false; | |
return function() { | |
if (!called) { | |
called = true; | |
return fn.apply(this, arguments); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment