Skip to content
Snippets Groups Projects
Commit 15d04f4d authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

Release 1.15.0

parent be7eb9c1
No related branches found
No related tags found
No related merge requests found
Showing
with 37 additions and 37 deletions
/** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.15.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,isArray,isObject}from"../types/is.js";function Diff(e,t){return doDiff(e,t)}function getKeys(e,t,n){if(isArray(n)){const o=e.length>t.length?new Array(e.length):new Array(t.length);return o.fill(0),new Set(o.map((e,t)=>t))}return new Set(Object.keys(e).concat(Object.keys(t)))}function doDiff(t,n,e,o){var r=typeof t,s=typeof n;const i=e||[],a=o||[];return r==s&&"object"==r?getKeys(t,n,r).forEach(e=>{Object.prototype.hasOwnProperty.call(t,e)?Object.prototype.hasOwnProperty.call(n,e)?doDiff(t[e],n[e],i.concat(e),a):a.push(buildResult(t[e],n[e],"delete",i.concat(e))):a.push(buildResult(t[e],n[e],"add",i.concat(e)))}):void 0!==(s=getOperator(t,n,r,s))&&a.push(buildResult(t,n,s,e)),a}function buildResult(e,t,n,o){const r={operator:n,path:o};return"add"!==n&&(r.first={value:e,type:typeof e},!isObject(e)||void 0!==(e=Object.getPrototypeOf(e)?.constructor?.name)&&(r.first.instance=e)),"add"!==n&&"update"!==n||(r.second={value:t,type:typeof t},!isObject(t)||void 0!==(t=Object.getPrototypeOf(t)?.constructor?.name)&&(r.second.instance=t)),r}function isNotEqual(e,t){return typeof e!=typeof t||(e instanceof Date&&t instanceof Date?e.getTime()!==t.getTime():e!==t)}function getOperator(e,t){let n;var o=typeof e,r=typeof t;return"undefined"==o&&"undefined"!=r?n="add":"undefined"!=o&&"undefined"==r?n="delete":isNotEqual(e,t)&&(n="update"),n}Monster.assignToNamespace("Monster.Data",Diff);export{Monster,Diff}; "use strict";import{Monster,assignToNamespace}from"../namespace.js";import{isArray,isObject}from"../types/is.js";function Diff(e,t){return doDiff(e,t)}function getKeys(e,t,n){if(isArray(n)){const o=e.length>t.length?new Array(e.length):new Array(t.length);return o.fill(0),new Set(o.map((e,t)=>t))}return new Set(Object.keys(e).concat(Object.keys(t)))}function doDiff(t,n,e,o){var r=typeof t,s=typeof n;const a=e||[],i=o||[];return r==s&&"object"==r?getKeys(t,n,r).forEach(e=>{Object.prototype.hasOwnProperty.call(t,e)?Object.prototype.hasOwnProperty.call(n,e)?doDiff(t[e],n[e],a.concat(e),i):i.push(buildResult(t[e],n[e],"delete",a.concat(e))):i.push(buildResult(t[e],n[e],"add",a.concat(e)))}):void 0!==(s=getOperator(t,n,r,s))&&i.push(buildResult(t,n,s,e)),i}function buildResult(e,t,n,o){const r={operator:n,path:o};return"add"!==n&&(r.first={value:e,type:typeof e},!isObject(e)||void 0!==(e=Object.getPrototypeOf(e)?.constructor?.name)&&(r.first.instance=e)),"add"!==n&&"update"!==n||(r.second={value:t,type:typeof t},!isObject(t)||void 0!==(t=Object.getPrototypeOf(t)?.constructor?.name)&&(r.second.instance=t)),r}function isNotEqual(e,t){return typeof e!=typeof t||(e instanceof Date&&t instanceof Date?e.getTime()!==t.getTime():e!==t)}function getOperator(e,t){let n;var o=typeof e,r=typeof t;return"undefined"==o&&"undefined"!=r?n="add":"undefined"!=o&&"undefined"==r?n="delete":isNotEqual(e,t)&&(n="update"),n}assignToNamespace("Monster.Data",Diff);export{Monster,Diff};
\ No newline at end of file \ No newline at end of file
/** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.15.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,isObject}from"../types/is.js";function extend(){for(var e={},t=0;t<arguments.length;t++)if(isObject(e))for(var r in arguments[t])arguments[t].hasOwnProperty(r)&&(e[r]=isObject(arguments[t][r])?extend(e[r]||{},arguments[t][r]):arguments[t][r]);return e}Monster.assignToNamespace("Monster.Data",extend);export{Monster,extend}; "use strict";import{Monster,assignToNamespace}from"../namespace.js";import{isObject,isArray}from"../types/is.js";import{typeOf}from"../types/typeof.js";function extend(){let e,r;for(r=0;r<arguments.length;r++){var t=arguments[r];if(!isObject(t)&&!isArray(t))throw new Error("unsuported argument "+JSON.stringify(t));if(void 0!==e)for(var s in t){var i=t?.[s];if(i!==e?.[s])if(isObject(i)||isArray(i)){if(void 0===e[s]&&(isArray(i)?e[s]=[]:e[s]={}),typeOf(e[s])!==typeOf(i))throw new Error("type mismatch: "+JSON.stringify(e[s])+" != "+JSON.stringify(i));e[s]=extend(e[s],i)}else e[s]=i}else e=t}return e}assignToNamespace("Monster.Data",extend);export{Monster,extend};
\ No newline at end of file \ No newline at end of file
/** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.15.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Data"; "use strict";const namespace="Monster.Data";
\ No newline at end of file
/** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.15.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../namespace.js";import{isObject,isArray,isInteger}from"../types/is.js";import{validateString,validateInteger}from"../types/validate.js";import{Base}from"../types/base.js";import{Stack}from"../types/stack.js";const DELIMITER=".",WILDCARD="*";class Pathfinder extends Base{constructor(t){super(),this.object=t,this.wildCard=WILDCARD}setWildCard(t){return validateString(t),this.wildCard=t,this}getVia(t){return getValueViaPath.call(this,this.object,validateString(t))}setVia(t,e){return validateString(t),setValueViaPath.call(this,this.object,t,e),this}deleteVia(t){return validateString(t),deleteValueViaPath.call(this,this.object,t),this}exists(t){validateString(t);try{return getValueViaPath.call(this,this.object,t,!0),!0}catch(t){}return!1}}function iterate(t,e,a){const i=new Map;if(isObject(t)||isArray(t))for(var[r,s]of Object.entries(t))i.set(r,getValueViaPath.call(this,s,e,a));else{var n=e.split(DELIMITER).shift();i.set(n,getValueViaPath.call(this,t,e,a))}return i}function getValueViaPath(e,t,a){if(""===t)return e;let i=t.split(DELIMITER),r=i.shift();if(r===this.wildCard)return iterate.call(this,e,i.join(DELIMITER),a);if(isObject(e)||isArray(e)){let t;if(e instanceof Map||e instanceof WeakMap)t=e.get(r);else if(e instanceof Set||e instanceof WeakSet)r=parseInt(r),validateInteger(r),t=[...e][r];else{if("function"==typeof WeakRef&&e instanceof WeakRef)throw Error("unsupported action for this data type");t=(isArray(e)&&(r=parseInt(r),validateInteger(r)),e?.[r])}if(isObject(t)||isArray(t))return getValueViaPath.call(this,t,i.join(DELIMITER),a);if(0<i.length)throw Error("the journey is not at its end ("+i.join(DELIMITER)+")");if(!0===a&&!e.hasOwnProperty(r))throw Error("unknown value");return t}throw TypeError("unsupported type "+typeof e)}function setValueViaPath(e,t,a){validateString(t);let i=t.split(DELIMITER),r=i.pop();var s,t=i.join(DELIMITER);let n=new Stack,o=t;for(;;){try{getValueViaPath.call(this,e,o,!0);break}catch(t){}if(n.push(o),i.pop(),o=i.join(DELIMITER),""===o)break}for(;!n.isEmpty();){o=n.pop();let t={};n.isEmpty()||(s=n.peek().split(DELIMITER).pop(),isInteger(parseInt(s))&&(t=[])),setValueViaPath.call(this,e,o,t)}let l=getValueViaPath.call(this,e,t);if(!isObject(e)&&!isArray(e))throw TypeError("unsupported type: "+typeof e);if(l instanceof Map||l instanceof WeakMap)l.set(r,a);else if(l instanceof Set||l instanceof WeakSet)l.append(a);else{if("function"==typeof WeakRef&&l instanceof WeakRef)throw Error("unsupported action for this data type");isArray(l)&&(r=parseInt(r),validateInteger(r)),assignProperty(l,r,a)}}function assignProperty(t,e,a){t.hasOwnProperty(e)&&void 0===a&&delete t[e],t[e]=a}function deleteValueViaPath(t,e){const a=e.split(DELIMITER);let i=a.pop();e=a.join(DELIMITER);const r=getValueViaPath.call(this,t,e);if(r instanceof Map)r.delete(i);else{if(r instanceof Set||r instanceof WeakMap||r instanceof WeakSet||"function"==typeof WeakRef&&r instanceof WeakRef)throw Error("unsupported action for this data type");isArray(r)&&(i=parseInt(i),validateInteger(i)),delete r[i]}}Monster.assignToNamespace("Monster.Data",Pathfinder);export{Monster,Pathfinder}; "use strict";import{Monster,assignToNamespace}from"../namespace.js";import{isObject,isArray,isInteger}from"../types/is.js";import{validateString,validateInteger}from"../types/validate.js";import{Base}from"../types/base.js";import{Stack}from"../types/stack.js";const DELIMITER=".",WILDCARD="*";class Pathfinder extends Base{constructor(t){super(),this.object=t,this.wildCard=WILDCARD}setWildCard(t){return validateString(t),this.wildCard=t,this}getVia(t){return getValueViaPath.call(this,this.object,validateString(t))}setVia(t,e){return validateString(t),setValueViaPath.call(this,this.object,t,e),this}deleteVia(t){return validateString(t),deleteValueViaPath.call(this,this.object,t),this}exists(t){validateString(t);try{return getValueViaPath.call(this,this.object,t,!0),!0}catch(t){}return!1}}function iterate(t,e,a){const i=new Map;if(isObject(t)||isArray(t))for(var[r,s]of Object.entries(t))i.set(r,getValueViaPath.call(this,s,e,a));else{var n=e.split(DELIMITER).shift();i.set(n,getValueViaPath.call(this,t,e,a))}return i}function getValueViaPath(e,t,a){if(""===t)return e;let i=t.split(DELIMITER),r=i.shift();if(r===this.wildCard)return iterate.call(this,e,i.join(DELIMITER),a);if(isObject(e)||isArray(e)){let t;if(e instanceof Map||e instanceof WeakMap)t=e.get(r);else if(e instanceof Set||e instanceof WeakSet)r=parseInt(r),validateInteger(r),t=[...e][r];else{if("function"==typeof WeakRef&&e instanceof WeakRef)throw Error("unsupported action for this data type");t=(isArray(e)&&(r=parseInt(r),validateInteger(r)),e?.[r])}if(isObject(t)||isArray(t))return getValueViaPath.call(this,t,i.join(DELIMITER),a);if(0<i.length)throw Error("the journey is not at its end ("+i.join(DELIMITER)+")");if(!0===a&&!e.hasOwnProperty(r))throw Error("unknown value");return t}throw TypeError("unsupported type "+typeof e)}function setValueViaPath(e,t,a){validateString(t);let i=t.split(DELIMITER),r=i.pop();var s,t=i.join(DELIMITER);let n=new Stack,o=t;for(;;){try{getValueViaPath.call(this,e,o,!0);break}catch(t){}if(n.push(o),i.pop(),o=i.join(DELIMITER),""===o)break}for(;!n.isEmpty();){o=n.pop();let t={};n.isEmpty()||(s=n.peek().split(DELIMITER).pop(),isInteger(parseInt(s))&&(t=[])),setValueViaPath.call(this,e,o,t)}let l=getValueViaPath.call(this,e,t);if(!isObject(e)&&!isArray(e))throw TypeError("unsupported type: "+typeof e);if(l instanceof Map||l instanceof WeakMap)l.set(r,a);else if(l instanceof Set||l instanceof WeakSet)l.append(a);else{if("function"==typeof WeakRef&&l instanceof WeakRef)throw Error("unsupported action for this data type");isArray(l)&&(r=parseInt(r),validateInteger(r)),assignProperty(l,r,a)}}function assignProperty(t,e,a){t.hasOwnProperty(e)&&void 0===a&&delete t[e],t[e]=a}function deleteValueViaPath(t,e){const a=e.split(DELIMITER);let i=a.pop();e=a.join(DELIMITER);const r=getValueViaPath.call(this,t,e);if(r instanceof Map)r.delete(i);else{if(r instanceof Set||r instanceof WeakMap||r instanceof WeakSet||"function"==typeof WeakRef&&r instanceof WeakRef)throw Error("unsupported action for this data type");isArray(r)&&(i=parseInt(i),validateInteger(i)),delete r[i]}}assignToNamespace("Monster.Data",Pathfinder);export{Monster,Pathfinder};
\ No newline at end of file \ No newline at end of file
/** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.15.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../namespace.js";import{Transformer}from"./transformer.js";import{Base}from"../types/base.js";import{validateFunction,validateString}from"../types/validate.js";const DELIMITER="|";class Pipe extends Base{constructor(e){super(),validateString(e),this.pipe=e.split(DELIMITER).map(e=>new Transformer(e))}setCallback(e,r,t){for(var[,s]of Object.entries(this.pipe))s.setCallback(e,r,t);return this}run(e){return this.pipe.reduce((e,r,t,s)=>r.run(e),e)}}Monster.assignToNamespace("Monster.Data",Pipe);export{Monster,Pipe}; "use strict";import{Monster,assignToNamespace}from"../namespace.js";import{Transformer}from"./transformer.js";import{Base}from"../types/base.js";import{validateFunction,validateString}from"../types/validate.js";const DELIMITER="|";class Pipe extends Base{constructor(e){super(),validateString(e),this.pipe=e.split(DELIMITER).map(e=>new Transformer(e))}setCallback(e,s,r){for(var[,t]of Object.entries(this.pipe))t.setCallback(e,s,r);return this}run(e){return this.pipe.reduce((e,s,r,t)=>s.run(e),e)}}assignToNamespace("Monster.Data",Pipe);export{Monster,Pipe};
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
/** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.15.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,Base}from"../types/base.js";import{validateInstance,validateString}from"../types/validate.js";import{getGlobalFunction}from"../types/global.js";import{ProxyObserver}from"../types/proxyobserver.js";const ATTRIBUTEPREFIX="data-monster-";class Assembler extends Base{constructor(e){super(),this.attributePrefix=ATTRIBUTEPREFIX,validateInstance(e,getGlobalFunction("DocumentFragment")),this.fragment=e}setAttributePrefix(e){return validateString(e),this.attributePrefix=e,this}getAttributePrefix(){return this.attributePrefix}createDocumentFragment(e){return void 0===e&&(e=new ProxyObserver({})),validateInstance(e,ProxyObserver),this.fragment.cloneNode(!0)}}Monster.assignToNamespace("Monster.DOM",Assembler);export{Monster,ATTRIBUTEPREFIX,Assembler}; "use strict";import{Monster,assignToNamespace}from"../namespace.js";import{Base}from"../types/base.js";import{validateInstance,validateString}from"../types/validate.js";import{getGlobalFunction}from"../types/global.js";import{ProxyObserver}from"../types/proxyobserver.js";const ATTRIBUTEPREFIX="data-monster-";class Assembler extends Base{constructor(e){super(),this.attributePrefix=ATTRIBUTEPREFIX,validateInstance(e,getGlobalFunction("DocumentFragment")),this.fragment=e}setAttributePrefix(e){return validateString(e),this.attributePrefix=e,this}getAttributePrefix(){return this.attributePrefix}createDocumentFragment(e){return void 0===e&&(e=new ProxyObserver({})),validateInstance(e,ProxyObserver),this.fragment.cloneNode(!0)}}assignToNamespace("Monster.DOM",Assembler);export{Monster,ATTRIBUTEPREFIX,Assembler};
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.15.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,parseLocale}from"../i18n/locale.js";import{getDocument}from"./util.js";const DEFAULT_LANGUAGE="en";function getLocaleOfDocument(){const e=getDocument();let t=e.querySelector("html");if(t instanceof HTMLElement&&t.hasAttribute("lang")){var o=t.getAttribute("lang");if(o)return new parseLocale(o)}return parseLocale(DEFAULT_LANGUAGE)}Monster.assignToNamespace("Monster.DOM",getLocaleOfDocument);export{Monster,getLocaleOfDocument}; "use strict";import{Monster,assignToNamespace}from"../namespace.js";import{parseLocale}from"../i18n/locale.js";import{getDocument}from"./util.js";const DEFAULT_LANGUAGE="en";function getLocaleOfDocument(){const e=getDocument();let t=e.querySelector("html");if(t instanceof HTMLElement&&t.hasAttribute("lang")){var o=t.getAttribute("lang");if(o)return new parseLocale(o)}return parseLocale(DEFAULT_LANGUAGE)}assignToNamespace("Monster.DOM",getLocaleOfDocument);export{Monster,getLocaleOfDocument};
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.15.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.I18n"; "use strict";const namespace="Monster.I18n";
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment