Skip to content
Snippets Groups Projects
Verified Commit 516da111 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: commit save point

parent 14152bb2
Branches
Tags
No related merge requests found
Showing
with 43 additions and 373 deletions
import {typeOf} from '@schukai/monster/source/types/typeof.mjs';
typeOf(undefined); // ↦ undefined
typeOf(""); // ↦ string
typeOf(5); // ↦ number
typeOf({}); // ↦ object
typeOf([]); // ↦ array
typeOf(new Map); // ↦ map
typeOf(true); // ↦ boolean
\ No newline at end of file
import {Version} from '@schukai/monster/source/types/version.mjs';
new Version('1.0.0') // ↦ 1.0.0
new Version(1) // ↦ 1.0.0
new Version(1, 0, 0) // ↦ 1.0.0
new Version('1.2.3', 4, 5) // ↦ 1.4.5
import {getMonsterVersion} from '@schukai/monster/source/types/version.mjs';
getMonsterVersion();
\ No newline at end of file
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,19 +5,11 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
export {Base}
/**
* This is the base class from which all monster classes are derived.
*
* ```
* <script type="module">
* import {Base} from '@schukai/monster/source/types/base.mjs';
* new Base()
* </script>
* ```
*
* The class was formerly called Object.
*
* @license AGPLv3
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,11 +5,9 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../constants.mjs";
import {extend} from "../data/extend.mjs";
import {Pathfinder} from "../data/pathfinder.mjs";
import {Base} from "./base.mjs";
import {validateObject} from "./validate.mjs";
......@@ -22,28 +18,10 @@ export {BaseWithOptions}
*
* This class is actually only used as a base class.
*
* ```html
* <script type="module">
* import {BaseWithOptions} from '@schukai/monster/source/types/basewithoptions.mjs';
* new BaseWithOptions()
* </script>
* ```
*
* Classes that require the possibility of options can be derived directly from this class.
* Derived classes almost always override the `defaul` getter with their own values.
*
* ```javascript
* class My extends BaseWithOptions {
* get defaults() {
* return Object.assign({}, super.defaults, {
* mykey: true
* });
* }
* }
* ```
*
* The class was formerly called Object.
*
* @externalExample ../../example/types/basewithoptions.mjs
* @license AGPLv3
* @since 1.13.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -14,13 +12,6 @@ export {toBinary, fromBinary}
/**
* You can call the function via the monster namespace `Monster.Types.toBinary()`.
*
* ```
* <script type="module">
* import {toBinary} from '@schukai/monster/source/types/binary.mjs';
* toBinary()
* </script>
* ```
*
* @param {String} binary
* @return {String}
* @throws {TypeError} value is not a string
......@@ -47,13 +38,6 @@ function toBinary(string) {
/**
* You can call the function via the monster namespace `Monster.Types.fromBinary()`.
*
* ```
* <script type="module">
* import {fromBinary} from '@schukai/monster/source/types/binary.mjs';
* fromBinary()
* </script>
* ```
*
* @param {String} binary
* @return {String}
* @throws {TypeError} value is not a string
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -8,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from "./base.mjs";
import {isString} from "./is.mjs";
import {MediaType, parseMediaType} from "./mediatype.mjs";
......@@ -22,17 +18,9 @@ export {DataUrl, parseDataURL}
*/
const internal = Symbol('internal');
/**
* You can create an object via the monster namespace `new Monster.Types.DataUrl()`.
*
* ```
* <script type="module">
* import {DataUrl} from '@schukai/monster/source/types/dataurl.mjs';
* new DataUrl()
* </script>
* ```
*
* @license AGPLv3
* @since 1.8.0
* @copyright schukai GmbH
......@@ -96,13 +84,6 @@ class DataUrl extends Base {
/**
* You can call the function via the monster namespace `Monster.Types.parseDataURL()`.
*
* ```
* <script type="module">
* import {parseDataURL} from '@schukai/monster/source/types/dataurl.mjs';
* parseDataURL(...)
* </script>
* ```
*
* Specification:
*
* ```
......@@ -158,6 +139,4 @@ function parseDataURL(dataurl) {
}
return new DataUrl(content, mediatype, base64Flag);
}
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from './base.mjs';
import {validateString} from "./validate.mjs";
......@@ -26,13 +23,6 @@ let internalCounter = new Map;
*
* So the ids can also be used for navigation. you just have to take care that the order stays the same.
*
* ```
* <script type="module">
* import {ID} from '@schukai/monster/source/types/id.mjs';
* console.log(new ID())
* </script>
* ```
*
* As of version 1.6.0 there is the new RandomID. this ID class is continuous from now on.
*
* @license AGPLv3
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,10 +5,8 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
export {isIterable, isPrimitive, isSymbol, isBoolean, isString, isObject, isInstance, isArray, isFunction, isInteger}
/**
* With this function you can check if a value is iterable.
*
......@@ -18,15 +14,7 @@ export {isIterable, isPrimitive, isSymbol, isBoolean, isString, isObject, isInst
*
* You can call the method via the monster namespace `Monster.Types.isPrimitive()`.
*
* ```
* <script type="module">
* import {isIterable} from '@schukai/monster/source/types/is.mjs';
* isIterable(null) // ↦ false
* isIterable('hello') // ↦ true
* isIterable([]) // ↦ true
* </script>
* ```
*
* @externalExample ../../example/types/is-1.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......@@ -46,14 +34,7 @@ function isIterable(value) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isPrimitive} from '@schukai/monster/source/types/is.mjs';
* isPrimitive('2')) // ↦ true
* isPrimitive([])) // ↦ false
* </script>
* ```
*
* @externalExample ../../example/types/is-2.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......@@ -82,14 +63,7 @@ function isPrimitive(value) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isSymbol} from '@schukai/monster/source/types/is.mjs';
* isSymbol(Symbol('a'))) // ↦ true
* isSymbol([]) // ↦ false
* </script>
* ```
*
* @externalExample ../../example/types/is-3.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......@@ -106,15 +80,7 @@ function isSymbol(value) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isBoolean} from '@schukai/monster/source/types/is.mjs';
* isBoolean('2')) // ↦ false
* isBoolean([])) // ↦ false
* isBoolean(2>4)) // ↦ true
* </script>
* ```
*
* @externalExample ../../example/types/is-4.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......@@ -136,14 +102,7 @@ function isBoolean(value) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isString} from '@schukai/monster/source/types/is.mjs';
* isString('2')) // ↦ true
* isString([])) // ↦ false
* </script>
* ```
*
* @externalExample ../../example/types/is-5.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......@@ -163,14 +122,7 @@ function isString(value) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isObject} from '@schukai/monster/source/types/is.mjs';
* isObject('2')) // ↦ false
* isObject([])) // ↦ false
* </script>
* ```
*
* @externalExample ../../example/types/is-6.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......@@ -195,14 +147,7 @@ function isObject(value) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isInstance} from '@schukai/monster/source/types/is.mjs';
* isInstance('2')) // ↦ false
* isInstance([])) // ↦ false
* </script>
* ```
*
* @externalExample ../../example/types/is-7.mjs
* @param {*} value
* @param {*} instance
* @returns {boolean}
......@@ -223,14 +168,7 @@ function isInstance(value, instance) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isArray} from '@schukai/monster/source/types/is.mjs';
* isArray('2')) // ↦ false
* isArray([])) // ↦ true
* </script>
* ```
*
* @externalExample ../../example/types/is-8.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......@@ -248,15 +186,7 @@ function isArray(value) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isFunction} from '@schukai/monster/source/types/is.mjs';
* isFunction(()=>{}) // ↦ true
* isFunction('2')) // ↦ false
* isFunction([])) // ↦ false
* </script>
* ```
*
* @externalExample ../../example/types/is-9.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......@@ -281,15 +211,7 @@ function isFunction(value) {
*
* This method is used in the library to have consistent names.
*
* ```
* <script type="module">
* import {isInteger} from '@schukai/monster/source/types/is.mjs';
* isInteger(()=>{}) // ↦ true
* isInteger('2')) // ↦ false
* isInteger(2)) // ↦ true
* </script>
* ```
*
* @externalExample ../../example/types/is-10.mjs
* @param {*} value
* @returns {boolean}
* @license AGPLv3
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -8,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from "./base.mjs";
import {isString} from "./is.mjs";
import {validateArray, validateString} from "./validate.mjs";
......@@ -32,13 +28,6 @@ const internal = Symbol('internal');
/**
* You can create an object via the monster namespace `new Monster.Types.MediaType()`.
*
* ```
* <script type="module">
* import {MediaType} from '@schukai/monster/source/types/mediatype.mjs';
* console.log(new MediaType())
* </script>
* ```
*
* @license AGPLv3
* @since 1.8.0
* @copyright schukai GmbH
......
/**
* Namespace for types.
*
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from './base.mjs';
import {isPrimitive} from "./is.mjs";
import {NodeList} from './nodelist.mjs';
......@@ -31,13 +28,6 @@ const treeStructureSymbol = Symbol('treeStructure');
/**
* You can create the instance via the monster namespace `new Monster.Types.Node()`.
*
* ```
* <script type="module">
* import {Node} from '@schukai/monster/source/types/node.mjs';
* new Node()
* </script>
* ```
*
* @license AGPLv3
* @since 1.26.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {isArray, isInstance} from "./is.mjs";
import {Node} from "./node.mjs";
import {validateInstance} from "./validate.mjs";
......@@ -17,13 +14,6 @@ export {NodeList}
/**
* You can create the instance via the monster namespace `new Monster.Types.NodeList()`.
*
* ```
* <script type="module">
* import {NodeList} from '@schukai/monster/source/types/nodelist.mjs';
* new NodeList()
* </script>
* ```
*
* @license AGPLv3
* @since 1.26.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../constants.mjs";
import {Base} from './base.mjs';
......@@ -27,47 +24,7 @@ const isNodeListSymbol = Symbol('isNodeList');
/**
* You can create the instance via the monster namespace `new Monster.Types.NodeRecursiveIterator()`.
*
* ```
* <script type="module">
* import {NodeRecursiveIterator} from '@schukai/monster/source/types/noderecursiveiterator.mjs';
* new NodeRecursiveIterator()
* </script>
* ```
*
* @example
* import {Node} from '@schukai/monster/source/types/node.mjs';
* import {NodeRecursiveIterator} from '@schukai/monster/source/types/noderecursiveiterator.mjs';
*
* const node =new Node('1')
*
* // 1
* // 2
* // ├ 2.1
* // ├ 2.2
* // └ 2.3
* // 3
* // 4
* // ├ 4.1
* // └ 4.2
* node.appendChild(
* (new Node('2'))
* .appendChild(new Node('2.1'))
* .appendChild(new Node('2.2'))
* .appendChild(new Node('2.3')))
* .appendChild(new Node('3'))
* .appendChild(new Node('4')
* .appendChild(new Node('4.1'))
* .appendChild(new Node('4.2')));
*
* const iterator = new NodeRecursiveIterator(node);
*
* const result = [];
* for (const n of iterator) {
* result.push(n.value);
* }
*
* // ↦ ['1', '2', '2.1', '2.2', '2.3', '3', '4', '4.1', '4.2']
*
* @externalExample ../../example/types/noderecursiveiterator.mjs
* @license AGPLv3
* @since 1.26.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from './base.mjs';
import {isObject} from './is.mjs';
import {TokenList} from './tokenlist.mjs';
......@@ -18,15 +15,10 @@ export {Observer}
/**
* An observer manages a callback function
*
* ```
* import {Observer} from '@schukai/monster/source/types/observer.mjs';
* new Observer()
* ```
*
* The update method is called with the subject object as this pointer. For this reason the callback should not
* be an arrow function, because it gets the this pointer of its own context.
* be an arrow function, because it gets this pointer of its own context.
*
* ```
* ```js
* new Observer(()=>{
* // this is not subject
* })
......@@ -38,7 +30,7 @@ export {Observer}
*
* Additional arguments can be passed to the callback. To do this, simply specify them.
*
* ```
* ```js
* Observer(function(a, b, c) {
* console.log(a, b, c); // ↦ "a", 2, true
* }, "a", 2, true)
......@@ -46,17 +38,7 @@ export {Observer}
*
* The callback function must have as many parameters as arguments are given.
*
* @example
*
* import {Observer} from '@schukai/monster/source/types/observer.mjs';
*
* const observer = new Observer(function(a, b, c) {
* console.log(this, a, b, c); // ↦ "a", 2, true
* }, "a", 2, true);
*
* observer.update({value:true}).then(()=>{});
* // ↦ {value: true} "a" 2 true
*
* @externalExample ../../example/types/observer.mjs
* @license AGPLv3
* @since 1.0.0
* @copyright schukai GmbH
......
......@@ -17,14 +17,6 @@ export {ObserverList}
/**
* With the help of the ObserverList class, observer can be managed.
*
* ```
* <script type="module">
* import {ObserverList} from '@schukai/monster/source/types/observerlist.mjs';
* console.log(ObserverList())
* console.log(ObserverList())
* </script>
* ```
*
* @license AGPLv3
* @since 1.0.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from './base.mjs';
import {isArray, isObject, isPrimitive} from "./is.mjs";
import {Observer} from "./observer.mjs";
......@@ -20,45 +17,12 @@ export {ProxyObserver}
/**
* An observer manages a callback function
*
* ```
* <script type="module">
* import {ProxyObserver} from '@schukai/monster/source/types/proxyobserver.mjs';
* new ProxyObserver()
* </script>
* ```
*
* With the ProxyObserver you can attach observer for observation. with each change at the object to be observed an update takes place.
*
* this also applies to nested objects.
*
* @example
*
* import {ProxyObserver} from '@schukai/monster/source/types/proxyobserver.mjs';
* import {Observer} from '@schukai/monster/source/types/observer.mjs';
* import {isObject} from '@schukai/monster/source/types/is.mjs';
*
* const o = new Observer(function () {
* if (isObject(this) && this instanceof ProxyObserver) {
* // do something (this ist ProxyObserver)
* const subject = this.getSubject();
* console.log(subject);
* }
* });
*
* let realSubject = {
* a: {
* b: {
* c: true
* },
* d: 9
* }
* }
* With the ProxyObserver you can attach observer for observation.
* With each change at the object to be observed an update takes place.
*
* const p = new ProxyObserver(realSubject);
* p.attachObserver(o);
* const s = p.getSubject();
* s.a.b.c = false;
* This also applies to nested objects.
*
* @externalExample ../../example/types/proxyobserver.mjs
* @license AGPLv3
* @since 1.0.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from './base.mjs';
export {Queue}
......@@ -15,36 +12,7 @@ export {Queue}
/**
* You can create the instance via the monster namespace `new Monster.Types.Queue()`.
*
* ```
* <script type="module">
* import {Queue} from '@schukai/monster/source/types/queue.mjs';
* new Queue()
* </script>
* ```
*
* @example
*
* import {Queue} from '@schukai/monster/source/types/queue.mjs';
*
* const queue = new Queue;
*
* queue.add(2);
* queue.add(true);
* queue.add("Hello");
* queue.add(4.5);
*
* console.log(queue.poll());
* // ↦ 2
* console.log(queue.poll());
* // ↦ true
* console.log(queue.poll());
* // ↦ "Hello"
* console.log(queue.poll());
* // ↦ 4.5
* console.log(queue.poll());
* // ↦ undefined
*
*
* @externalExample ../../example/types/queue.mjs
* @license AGPLv3
* @since 1.4.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -8,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {random} from "../math/random.mjs";
import {getGlobal} from "./global.mjs";
import {ID} from "./id.mjs";
......@@ -24,13 +20,6 @@ let internalCounter = 0;
/**
* The `RandomID` class provides a unique ID for an item.
*
* ```
* <script type="module">
* import {RandomID} from '@schukai/monster/source/types/randomid.mjs';
* console.log(new RandomID())
* </script>
* ```
*
* @license AGPLv3
* @since 1.6.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {validateString} from "./validate.mjs";
export {escapeString}
......@@ -15,13 +12,6 @@ export {escapeString}
/**
* This function prefixes all special characters that may appear in a regex with a slash.
*
* ```
* <script type="module">
* import {escapeString} from '@schukai/monster/source/types/validate.mjs';
* escapeString()
* </script>
* ```
*
* @param {string} value
* @return {string}
* @license AGPLv3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment