@girders-elements/core
Version:
Girders Elements is an architectural framework that assists with building data-driven apps with React or React Native.
51 lines (35 loc) • 1.95 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var
AbstractRegistry=function(){function AbstractRegistry(){_classCallCheck(this,AbstractRegistry);}_createClass(AbstractRegistry,[{key:'register',value:function register(
key,value){
throw new Error('Must be implemented');
}},{key:'get',value:function get(
key){
var resolvedKey=this._adaptKey(key);
return this._getBySpecificity(resolvedKey,true);
}},{key:'isEmpty',value:function isEmpty()
{
return true;
}},{key:'reset',value:function reset()
{
throw new Error('Must be implemented');
}},{key:'_getInternal',value:function _getInternal(
key){
throw new Error('Must be implemented');
}},{key:'_getBySpecificity',value:function _getBySpecificity(
key){var useSpecificity=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;
var val=this._getInternal(key);
if(val){
return val;
}
if(!val&&useSpecificity){
var newKey=this._lessSpecificKey(key);
if(newKey)return this._getBySpecificity(newKey,useSpecificity);
}
return undefined;
}},{key:'_lessSpecificKey',value:function _lessSpecificKey(
key){
throw new Error('Must be implemented');
}},{key:'_adaptKey',value:function _adaptKey(
key){
throw new Error('Must be implemented');
}}]);return AbstractRegistry;}();exports.default=AbstractRegistry;