Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Last active August 4, 2019 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelficarra/e43d7d205613a6910936bc5408577ff0 to your computer and use it in GitHub Desktop.
Save michaelficarra/e43d7d205613a6910936bc5408577ff0 to your computer and use it in GitHub Desktop.
a loose approximation of a potential Function.prototype.once
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