class-config-base
Version:
The base class of a configuration class for a interfacial class.
2 lines • 8.04 kB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ClassConfig=e()}}(function(){return function(){return function e(t,n,r){function o(a,c){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){return o(t[a][1][e]||e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}}()({1:[function(e,t,n){"use strict";const r=e("./lib/config"),o=e("./lib/manager");Object.defineProperty(r,"Manager",{enumerable:!0,value:o}),t.exports=r},{"./lib/config":2,"./lib/manager":3}],2:[function(e,t,n){"use strict";const r=e("copy-props"),o=e("default-val"),i=e("instance-stringer");class a{constructor(e,t,{sharePrivate:n}={}){n&&e instanceof a?Object.defineProperty(this,"$private",{value:e.$private}):(Object.defineProperty(this,"$private",{value:{}}),r(t,this.$private),r(e,this.$private,c),this.defineMorePrivates(this.$private));const i=this.defineAccessors(this.$private,this);r(this.$private,this,(e,t)=>{const n=function(e,t,n={}){let r=n[t.keyChain];r||(r={enumerable:!0,get:()=>e.parent[e.key],set(t){e.parent[e.key]=o(t,e.parent[e.key])}});r.set===s&&s(r,t.parent,t.key);return r}(e,t,i);Object.defineProperty(t.parent,t.key,n)})}configure(e,t={}){!function(e){Object.defineProperties(e,{[Symbol.toStringTag]:{get:()=>e.constructor.name,set(){}}})}(e);let n=this.defineInterfaces(this,e);n=function(e,t,n){const r=Object.assign({},e,t);return Object.keys(r).forEach(e=>{const t=r[e];t.set===s&&s(t,n,e)}),r}(n,t,e),Object.defineProperties(e,n)}toString(){return i(this)}defineMorePrivates(){}defineAccessors(){}defineInterfaces(){}static readonly({get:e,enumerable:t=!0}){return{enumerable:t,set(){},get:e}}static writable({get:e,set:t,enumerable:n=!0,configurable:r=!1}){return{enumerable:n,configurable:r,set:t,get:e}}static replaceable({get:e,enumerable:t=!0}){return{enumerable:t,configurable:!0,get:e,set:s}}static method(e){return{enumerable:!0,configurable:!0,writable:!0,value:e}}}function c(e,t){return o(e.value,t.value)}function s(e,t,n){e.set=(r=>{Object.defineProperty(t,n,{enumerable:e.enumerable,configurable:!0,writable:!0,value:r})})}t.exports=a},{"copy-props":6,"default-val":7,"instance-stringer":11}],3:[function(e,t,n){"use strict";const r=e("./config");t.exports=class{constructor(){this._objectConfigMap=new WeakMap}set(e,t){(t instanceof r||e instanceof r)&&(this._objectConfigMap.set(t,e),this._objectConfigMap.set(e,t))}delete(e){const t=this._objectConfigMap.get(e);this._objectConfigMap.delete(e),this._objectConfigMap.delete(t)}getConfig(e){const t=this._objectConfigMap.get(e);if(t instanceof r)return t}getObject(e){if(e instanceof r)return this._objectConfigMap.get(e)}}},{"./config":2}],4:[function(e,t,n){"use strict";t.exports=function(e,t,n){if(null!=e)for(var r=e.length,o=-1;++o<r;){var i=e[o];if(!1===t.call(n,i,o,e))break}}},{}],5:[function(e,t,n){"use strict";function r(e,t,n){return t=null==t?n||0:t<0?Math.max(e+t,0):Math.min(t,e)}t.exports=function(e,t,n){var o=e.length,i=[];for(t=r(o,t),n=r(o,n,o);t<n;)i.push(e[t++]);return i}},{}],6:[function(e,t,n){"use strict";var r=e("each-props"),o=e("is-plain-object");function i(e,t,n){if(!o(e)){var r=n.fromto[t];if(r){delete n.fromto[t],Array.isArray(r)||(r=[r]);for(var i={keyChain:t,value:e,key:n.name,depth:n.depth,parent:n.parent},a=0,c=r.length;a<c;a++)f(n.dest,r[a],function(e,t,o){var c={keyChain:r[a],value:e[t],key:t,depth:o,parent:e};return n.convert(i,c)})}}}function a(e,t,n){if(o(e)){for(var r in e)return;f(n.dest,t,c)}else{var i={keyChain:t,value:e,key:n.name,depth:n.depth,parent:n.parent};f(n.dest,t,function(e,r,o){var a={keyChain:t,value:e[r],key:r,depth:o,parent:e};return n.convert(i,a)})}}function c(){return{}}function s(e){return e.value}function f(e,t,n){!function e(t,n,r,i){var a=n.shift();if(!n.length){var c=i(t,a,r);if(void 0===c)return;if(o(c)&&o(t[a]))return;return void(t[a]=c)}o(t[a])||(t[a]={});e(t[a],n,r+1,i)}(e,t.split("."),1,n)}function u(){}function l(e){return"[object Object]"===Object.prototype.toString.call(e)}t.exports=function(e,t,n,c,p){if(l(e)||(e={}),l(t)||(t={}),o(n)?n=function(e){var t={};for(var n in e){var r=e[n];"string"==typeof r&&(t[n]=r)}return t}(n):Array.isArray(n)?n=function(e){for(var t={},n=0,r=e.length;n<r;n++){var o=e[n];"string"==typeof o&&(t[o]=o)}return t}(n):"boolean"==typeof n?(p=n,c=s,n=null):"function"==typeof n?(p=c,c=n,n=null):n=null,"function"!=typeof c&&("boolean"==typeof c?(p=c,c=s):c=s),"boolean"!=typeof p&&(p=!1),p){var b=e;e=t,t=b,n&&(n=function(e){var t={};for(var n in e){var r=e[n];t[r]||(t[r]=[]),t[r].push(n)}return t}(n))}var y={dest:t,fromto:n,convert:c};return n?(r(e,i,y),function(e,t){for(var n in t){var r=t[n];Array.isArray(r)||(r=[r]);for(var o=0,i=r.length;o<i;o++)f(e,r[o],u)}}(t,n)):r(e,a,y),t}},{"each-props":8,"is-plain-object":12}],7:[function(e,t,n){"use strict";function r(e){return Object.prototype.toString.call(e)}t.exports=function(e,t,n){return null==e?t:"number"==typeof e&&isNaN(e)?t:("string"!=typeof n&&(n=r(t)),r(e)===n||typeof e===n?e:t)}},{}],8:[function(e,t,n){"use strict";var r=e("is-plain-object"),o=e("object.defaults/immutable");t.exports=function(e,t,n){var i;(i=e,"[object Object]"===Object.prototype.toString.call(i))&&("function"==typeof t&&(r(n)||(n={}),function e(t,n,i,a,c){var s=Object.keys(t);if("function"==typeof c.sort){var f=c.sort(s);Array.isArray(f)&&(s=f)}a+=1;for(var u=0,l=s.length;u<l;u++){var p=s[u],b=n+"."+p,y=t[p],v=o(c);v.name=p,v.index=u,v.count=l,v.depth=a,v.parent=t;var h=i(y,b.slice(1),v);!h&&r(y)&&e(y,b,i,a,c)}}(e,"",t,0,n)))}},{"is-plain-object":12,"object.defaults/immutable":14}],9:[function(e,t,n){"use strict";t.exports=function(e,t,n){for(var r in e)if(!1===t.call(n,e[r],r,e))break}},{}],10:[function(e,t,n){"use strict";var r=e("for-in"),o=Object.prototype.hasOwnProperty;t.exports=function(e,t,n){r(e,function(r,i){if(o.call(e,i))return t.call(n,e[i],i,e)})}},{"for-in":9}],11:[function(e,t,n){"use strict";const r=e("each-props"),o=e("is-plain-object");function i(e){const t=c(e);return o(e)?t:`${e.constructor.name} ${t}`}function a(e){return`[${e.map(e=>Array.isArray(e)?a(e):e instanceof Object?i(e):"string"==typeof e?`'${e}'`:e).join(", ")}]`}function c(e){let t="",n=0;return r(e,(e,r,c)=>{if(0===c.index?(t+="{ ",n=c.depth):(n>c.depth&&(t+=" }".repeat(n-c.depth),n=c.depth),t+=", "),Array.isArray(e))t+=`${c.name}: ${a(e)}`;else if(o(e))t+=`${c.name}: `,Object.keys(e).length||(t+="{}");else if(e instanceof Object)t+=`${c.name}: ${i(e)}`;else if("string"==typeof e)t+=`${c.name}: '${e}'`;else try{t+=`${c.name}: ${e}`}catch(e){t+=`${c.name}: {}`}}),(t+=" }".repeat(n)).length||(t="{}"),t}i.propsStringer=c,i.arrayStringer=a,t.exports=i},{"each-props":8,"is-plain-object":12}],12:[function(e,t,n){"use strict";var r=e("isobject");function o(e){return!0===r(e)&&"[object Object]"===Object.prototype.toString.call(e)}t.exports=function(e){var t,n;return!1!==o(e)&&("function"==typeof(t=e.constructor)&&(!1!==o(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")))}},{isobject:13}],13:[function(e,t,n){"use strict";t.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},{}],14:[function(e,t,n){"use strict";var r=e("array-slice"),o=e("./mutable");t.exports=function(){var e=r(arguments);return o.apply(null,[{}].concat(e))}},{"./mutable":15,"array-slice":5}],15:[function(e,t,n){"use strict";var r=e("array-each"),o=e("array-slice"),i=e("for-own"),a=e("isobject");t.exports=function(e,t){return null==e?{}:(r(o(arguments,1),function(t){a(t)&&i(t,function(t,n){null==e[n]&&(e[n]=t)})}),e)}},{"array-each":4,"array-slice":5,"for-own":10,isobject:13}]},{},[1])(1)});
//# sourceMappingURL=i