Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AMD Registry Pattern implementation
/**
* @module Registry pattern implementation
*/
define(function() {
'use strict';
/**
* Constructor
*/
function Registry() {
this._store = {};
}
/**
* Get value from store by key
* @param {string} key
*/
Registry.prototype.get = function get(key) {
return this._store[key];
};
/**
* Add key to store
* @param {string} key
* @param val
*/
Registry.prototype.set = function set(key, val) {
return this._store[key] = val;
};
/**
* Remove key from store
* @param {string} key
*/
Registry.prototype.remove = function remove(key) {
return delete this._store[key];
};
// Return Singleton
return new Registry;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.