Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created February 26, 2013 01:15
Show Gist options
  • Save lyuehh/5034919 to your computer and use it in GitHub Desktop.
Save lyuehh/5034919 to your computer and use it in GitHub Desktop.
function once(fn) {
var called = false;
return function() {
if(called) throw new Error('Callback was already called.');
called = true;
fn.apply(null, arguments);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment