Skip to content

Instantly share code, notes, and snippets.

@tanabe
Created November 30, 2011 16:01
Show Gist options
  • Select an option

  • Save tanabe/1409604 to your computer and use it in GitHub Desktop.

Select an option

Save tanabe/1409604 to your computer and use it in GitHub Desktop.
objectId
var ObjectFactory = (function() {
var map = {};
var index = 0;
return {
create: function() {
return this.register({});
},
register: function(object) {
object.__id__ = (new Date()).getTime() + index++;
map[id] = object;
return object;
},
getObjectById: function(id) {
return map[id];
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment