AMD Registry Pattern implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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