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

Merge branch 'MONSTER/-/4a988b38-23ad-474d-9de9-a5f6b62f473e' into 'master'

Release 1.17.0

See merge request oss/libraries/javascript/monster!21
parents 2b57ab8d 5a7564fa
Branches
Tags 3.68.4
No related merge requests found
Showing
with 28 additions and 22 deletions
This diff is collapsed.
This diff is collapsed.
......@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
## [1.16.1] - 2021-09-29
## Fixed
- [Uncaught TypeError: (0 , logging_namespace_namespaceObject.assignToNamespace) is not a function](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/59)
## [1.16.0] - 2021-09-27
## Changed
......
......@@ -40,7 +40,7 @@ For some functions you need additional [polyfills](#polyfill).
<script type="module">
import {
Monster
} from 'https://unpkg.com/@schukai/monster@1.16.0/dist/modules/monster.js';
} from 'https://unpkg.com/@schukai/monster@1.16.1/dist/modules/monster.js';
let id = document.getElementById('version');
id.innerHTML = Monster.getVersion();
</script>
......@@ -51,8 +51,8 @@ For some functions you need additional [polyfills](#polyfill).
`nomodule` for backwards compatibility
```
<script type="module" src="https://unpkg.com/@schukai/monster@1.16.0/dist/modules/monster.js"></script>
<script nomodule src="https://unpkg.com/@schukai/monster@1.16.0/dist/monster.js"></script>
<script type="module" src="https://unpkg.com/@schukai/monster@1.16.1/dist/modules/monster.js"></script>
<script nomodule src="https://unpkg.com/@schukai/monster@1.16.1/dist/monster.js"></script>
```
### Polyfill
......
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"./namespace.js";const PROPERTY_KEY_INTERNALDATA="monsterInternalData";export{Monster,PROPERTY_KEY_INTERNALDATA};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";class AbstractConstraint extends Base{constructor(){super()}isValid(s){return Promise.reject(s)}}assignToNamespace("Monster.Constraints",AbstractConstraint);export{Monster,AbstractConstraint};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractConstraint}from"./abstract.js";class AbstractOperator extends AbstractConstraint{constructor(t,r){if(super(),!(t instanceof AbstractConstraint&&r instanceof AbstractConstraint))throw new TypeError("parameters must be from type AbstractConstraint");this.operantA=t,this.operantB=r}}assignToNamespace("Monster.Constraints",AbstractOperator);export{Monster,AbstractOperator};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractOperator}from"./abstractoperator.js";class AndOperator extends AbstractOperator{isValid(r){return Promise.all([this.operantA.isValid(r),this.operantB.isValid(r)])}}assignToNamespace("Monster.Constraints",AndOperator);export{Monster,AndOperator};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractConstraint}from"./abstract.js";class Invalid extends AbstractConstraint{isValid(s){return Promise.reject(s)}}assignToNamespace("Monster.Constraints",Invalid);export{Monster,Invalid};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray}from"../types/is.js";import{AbstractConstraint}from"./abstract.js";class IsArray extends AbstractConstraint{isValid(s){return isArray(s)?Promise.resolve(s):Promise.reject(s)}}assignToNamespace("Monster.Constraints",IsArray);export{Monster,IsArray};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isObject}from"../types/is.js";import{AbstractConstraint}from"./abstract.js";class IsObject extends AbstractConstraint{isValid(s){return isObject(s)?Promise.resolve(s):Promise.reject(s)}}assignToNamespace("Monster.Constraints",IsObject);export{Monster,IsObject};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Constraints";export{namespace};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractOperator}from"./abstractoperator.js";class OrOperator extends AbstractOperator{isValid(s){var o=this;return new Promise(function(t,r){let a,e;o.operantA.isValid(s).then(function(){t()}).catch(function(){(a=!1)===e&&r()}),o.operantB.isValid(s).then(function(){t()}).catch(function(){(e=!1)===a&&r()})})}}assignToNamespace("Monster.Constraints",OrOperator);export{Monster,OrOperator};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractConstraint}from"./abstract.js";class Valid extends AbstractConstraint{isValid(s){return Promise.resolve(s)}}assignToNamespace("Monster.Constraints",Valid);export{Monster,Valid};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isFunction}from"../types/is.js";import{validateString}from"../types/validate.js";import{Pathfinder}from"./pathfinder.js";function buildMap(t,a,i,r,n){validateString(a);const o=new Map;let e=new Pathfinder(t),s=e.getVia(a);return s instanceof Map&&s.forEach((t,a,e)=>{isFunction(n)&&!0!==n.call(e,t,a)||(a=build(t,r,a),t=build(t,i),o.set(a,t))}),o}function build(t,e,a){if(void 0===e)return a||t;validateString(e);const i=[...e.matchAll(/(?<placeholder>\${(?<path>[a-z.\-_0-9]*)})/gm)];let r=new Pathfinder(t);return 0===i.length?r.getVia(e):(i.forEach(t=>{var a=t?.groups,t=a?.placeholder;void 0!==t&&(a=a?.path,a=r.getVia(a),e=e.replaceAll(t,a))}),e)}assignToNamespace("Monster.Data",buildMap);export{Monster,buildMap};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}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
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isObject}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
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Data";export{namespace};
\ No newline at end of file
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isArray,isInteger,isObject,isPrimitive}from"../types/is.js";import{Stack}from"../types/stack.js";import{validateInteger,validateString}from"../types/validate.js";const DELIMITER=".",WILDCARD="*";class Pathfinder extends Base{constructor(t){if(super(),isPrimitive(t))throw new Error("the parameter must not be a simple type");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
/** Monster 1.16.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.16.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateString}from"../types/validate.js";import{Transformer}from"./transformer.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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment