Skip to content

Instantly share code, notes, and snippets.

@binario200
Last active April 8, 2018 21:47
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 binario200/693e21fd0004a1ce6374a6e2ef97731c to your computer and use it in GitHub Desktop.
Save binario200/693e21fd0004a1ce6374a6e2ef97731c to your computer and use it in GitHub Desktop.
Storing a collection of unique functions
var store = {
  nextId: 1,
  cache: {},
  add: function(fn) {
     if (!fn.id) {
        fn.id = this.nextId++;
        this.cache[fn.id] = fn;
        return true;
     }
  }
}

// usage 
// function ninja(){}
// store.add(ninja);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment