@schukai/monster 1.31.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +11 -0
- package/README.md +55 -58
- package/example/constraints/andoperator.mjs +17 -0
- package/example/constraints/invalid.mjs +6 -0
- package/example/constraints/isarray.mjs +11 -0
- package/example/constraints/isobject.mjs +12 -0
- package/example/constraints/oroperator.mjs +15 -0
- package/example/constraints/valid.mjs +6 -0
- package/example/data/buildmap.mjs +67 -0
- package/example/data/datasource.mjs +7 -0
- package/example/data/diff.mjs +39 -0
- package/example/data/pathfinder-1.mjs +23 -0
- package/example/data/pathfinder-2.mjs +19 -0
- package/example/data/pipe.mjs +14 -0
- package/example/data/storage/restapi.mjs +11 -0
- package/example/data/transformer.mjs +9 -0
- package/example/dom/customelement.mjs +13 -0
- package/example/dom/theme.mjs +5 -0
- package/example/dom/updater.mjs +23 -0
- package/example/i18n/formatter.mjs +10 -0
- package/example/i18n/providers/fetch.mjs +5 -0
- package/example/i18n/translations.mjs +20 -0
- package/example/types/basewithoptions.mjs +10 -0
- package/example/types/is-1.mjs +5 -0
- package/example/types/is-10.mjs +6 -0
- package/example/types/is-2.mjs +4 -0
- package/example/types/is-3.mjs +4 -0
- package/example/types/is-4.mjs +5 -0
- package/example/types/is-5.mjs +4 -0
- package/example/types/is-6.mjs +4 -0
- package/example/types/is-7.mjs +4 -0
- package/example/types/is-8.mjs +4 -0
- package/example/types/is-9.mjs +6 -0
- package/example/types/noderecursiveiterator.mjs +32 -0
- package/example/types/observer.mjs +9 -0
- package/example/types/proxyobserver.mjs +25 -0
- package/example/types/queue.mjs +20 -0
- package/example/types/tokenlist-1.mjs +4 -0
- package/example/types/tokenlist-2.mjs +7 -0
- package/example/types/tokenlist-3.mjs +5 -0
- package/example/types/tokenlist-4.mjs +5 -0
- package/example/types/tokenlist-5.mjs +5 -0
- package/example/types/typeof.mjs +9 -0
- package/example/types/version-1.mjs +6 -0
- package/example/types/version-2.mjs +3 -0
- package/example/util/comparator.mjs +10 -0
- package/example/util/deadmansswitch.mjs +9 -0
- package/example/util/processing.mjs +17 -0
- package/package.json +5 -59
- package/source/{constants.js → constants.mjs} +7 -10
- package/source/constraints/{abstract.js → abstract.mjs} +8 -9
- package/source/constraints/{abstractoperator.js → abstractoperator.mjs} +11 -8
- package/source/constraints/andoperator.mjs +38 -0
- package/source/constraints/invalid.mjs +38 -0
- package/source/constraints/isarray.mjs +41 -0
- package/source/constraints/isobject.mjs +41 -0
- package/source/constraints/{namespace.js → namespace.mjs} +3 -8
- package/source/constraints/{oroperator.js → oroperator.mjs} +10 -42
- package/source/constraints/valid.mjs +38 -0
- package/source/data/{buildmap.js → buildmap.mjs} +18 -104
- package/source/data/{buildtree.js → buildtree.mjs} +11 -31
- package/source/data/datasource/{namespace.js → namespace.mjs} +1 -9
- package/source/data/datasource/restapi/namespace.mjs +8 -0
- package/source/data/datasource/restapi/{writeerror.js → writeerror.mjs} +8 -9
- package/source/data/datasource/{restapi.js → restapi.mjs} +15 -45
- package/source/data/datasource/storage/localstorage.mjs +45 -0
- package/source/data/datasource/storage/{namespace.js → namespace.mjs} +1 -9
- package/source/data/datasource/storage/sessionstorage.mjs +45 -0
- package/source/data/datasource/{storage.js → storage.mjs} +12 -35
- package/source/data/{datasource.js → datasource.mjs} +17 -45
- package/source/data/{diff.js → diff.mjs} +10 -69
- package/source/data/{extend.js → extend.mjs} +10 -28
- package/source/data/{namespace.js → namespace.mjs} +2 -8
- package/source/data/{pathfinder.js → pathfinder.mjs} +18 -77
- package/source/data/{pipe.js → pipe.mjs} +14 -46
- package/source/data/{transformer.js → transformer.mjs} +18 -43
- package/source/dom/{assembler.js → assembler.mjs} +12 -28
- package/source/dom/{attributes.js → attributes.mjs} +42 -253
- package/source/dom/{constants.js → constants.mjs} +110 -61
- package/source/dom/{customcontrol.js → customcontrol.mjs} +10 -17
- package/source/dom/{customelement.js → customelement.mjs} +28 -52
- package/source/dom/{events.js → events.mjs} +15 -64
- package/source/dom/{focusmanager.js → focusmanager.mjs} +13 -34
- package/source/dom/{locale.js → locale.mjs} +11 -26
- package/source/dom/{namespace.js → namespace.mjs} +1 -8
- package/source/dom/{ready.js → ready.mjs} +12 -30
- package/source/dom/resource/{data.js → data.mjs} +11 -31
- package/source/dom/resource/link/namespace.mjs +10 -0
- package/source/dom/resource/link/stylesheet.mjs +35 -0
- package/source/dom/resource/{link.js → link.mjs} +9 -29
- package/source/dom/resource/namespace.mjs +8 -0
- package/source/dom/resource/{script.js → script.mjs} +9 -29
- package/source/dom/{resource.js → resource.mjs} +19 -39
- package/source/dom/{resourcemanager.js → resourcemanager.mjs} +17 -35
- package/source/dom/{template.js → template.mjs} +18 -43
- package/source/dom/{theme.js → theme.mjs} +14 -36
- package/source/dom/{updater.js → updater.mjs} +34 -68
- package/source/dom/{util.js → util.mjs} +17 -66
- package/source/dom/worker/{factory.js → factory.mjs} +13 -34
- package/source/dom/worker/namespace.mjs +8 -0
- package/source/i18n/{formatter.js → formatter.mjs} +14 -45
- package/source/i18n/{locale.js → locale.mjs} +15 -30
- package/source/i18n/{namespace.js → namespace.mjs} +1 -9
- package/source/i18n/provider.mjs +40 -0
- package/source/i18n/providers/{fetch.js → fetch.mjs} +18 -43
- package/source/i18n/providers/namespace.mjs +8 -0
- package/source/i18n/{translations.js → translations.mjs} +12 -52
- package/source/logging/handler/console.mjs +50 -0
- package/source/logging/handler/namespace.mjs +6 -0
- package/source/logging/{handler.js → handler.mjs} +13 -30
- package/source/logging/logentry.mjs +51 -0
- package/source/logging/{logger.js → logger.mjs} +12 -28
- package/source/logging/{namespace.js → namespace.mjs} +1 -9
- package/source/math/{namespace.js → namespace.mjs} +1 -9
- package/source/math/{random.js → random.mjs} +8 -34
- package/source/monster.mjs +114 -0
- package/source/text/{formatter.js → formatter.mjs} +17 -33
- package/source/text/{namespace.js → namespace.mjs} +1 -9
- package/source/types/base.mjs +31 -0
- package/source/types/{basewithoptions.js → basewithoptions.mjs} +17 -46
- package/source/types/{binary.js → binary.mjs} +10 -42
- package/source/types/{dataurl.js → dataurl.mjs} +12 -46
- package/source/types/{global.js → global.mjs} +20 -12
- package/source/types/{id.js → id.mjs} +10 -27
- package/source/types/is.mjs +225 -0
- package/source/types/{mediatype.js → mediatype.mjs} +13 -29
- package/source/types/{namespace.js → namespace.mjs} +1 -8
- package/source/types/{node.js → node.mjs} +11 -28
- package/source/types/{nodelist.js → nodelist.mjs} +17 -32
- package/source/types/{noderecursiveiterator.js → noderecursiveiterator.mjs} +14 -65
- package/source/types/{observer.js → observer.mjs} +15 -42
- package/source/types/{observerlist.js → observerlist.mjs} +12 -29
- package/source/types/{proxyobserver.js → proxyobserver.mjs} +19 -62
- package/source/types/{queue.js → queue.mjs} +10 -47
- package/source/types/randomid.mjs +45 -0
- package/source/types/regex.mjs +27 -0
- package/source/types/{stack.js → stack.mjs} +8 -24
- package/source/types/{tokenlist.js → tokenlist.mjs} +20 -64
- package/source/types/typeof.mjs +37 -0
- package/source/types/{uniquequeue.js → uniquequeue.mjs} +11 -27
- package/source/types/{uuid.js → uuid.mjs} +15 -33
- package/source/types/{validate.js → validate.mjs} +38 -155
- package/source/types/{version.js → version.mjs} +19 -62
- package/source/util/{clone.js → clone.mjs} +10 -28
- package/source/util/{comparator.js → comparator.mjs} +13 -43
- package/source/util/{deadmansswitch.js → deadmansswitch.mjs} +15 -40
- package/source/util/freeze.mjs +39 -0
- package/source/util/{namespace.js → namespace.mjs} +1 -9
- package/source/util/{processing.js → processing.mjs} +13 -51
- package/source/util/{trimspaces.js → trimspaces.mjs} +14 -21
- package/test/cases/constraint/{andoperator.js → andoperator.mjs} +3 -3
- package/test/cases/constraint/{invalid.js → invalid.mjs} +1 -1
- package/test/cases/constraint/{isarray.js → isarray.mjs} +1 -1
- package/test/cases/constraint/{isobject.js → isobject.mjs} +1 -1
- package/test/cases/constraint/{oroperator.js → oroperator.mjs} +3 -3
- package/test/cases/constraint/{valid.js → valid.mjs} +1 -1
- package/test/cases/data/{buildmap.js → buildmap.mjs} +1 -1
- package/test/cases/data/{buildtree.js → buildtree.mjs} +2 -2
- package/test/cases/data/datasource/{restapi.js → restapi.mjs} +5 -5
- package/test/cases/data/datasource/storage/{localstorage.js → localstorage.mjs} +5 -5
- package/test/cases/data/datasource/storage/{sessionstorage.js → sessionstorage.mjs} +5 -5
- package/test/cases/data/{datasource.js → datasource.mjs} +1 -1
- package/test/cases/data/{diff.js → diff.mjs} +2 -2
- package/test/cases/data/{extend.js → extend.mjs} +1 -1
- package/test/cases/data/{pathfinder.js → pathfinder.mjs} +1 -1
- package/test/cases/data/{pipe.js → pipe.mjs} +19 -5
- package/test/cases/data/{transformer.js → transformer.mjs} +14 -10
- package/test/cases/dom/{assembler.js → assembler.mjs} +2 -2
- package/test/cases/dom/{attributes.js → attributes.mjs} +2 -2
- package/test/cases/dom/{customcontrol.js → customcontrol.mjs} +6 -6
- package/test/cases/dom/{customelement.js → customelement.mjs} +6 -6
- package/test/cases/dom/{events.js → events.mjs} +2 -2
- package/test/cases/dom/{focusmanager.js → focusmanager.mjs} +3 -3
- package/test/cases/dom/{locale.js → locale.mjs} +2 -2
- package/test/cases/dom/{ready.js → ready.mjs} +2 -2
- package/test/cases/dom/resource/{data.js → data.mjs} +9 -9
- package/test/cases/dom/resource/link/{stylesheet.js → stylesheet.mjs} +6 -6
- package/test/cases/dom/resource/{link.js → link.mjs} +6 -6
- package/test/cases/dom/resource/{script.js → script.mjs} +6 -6
- package/test/cases/dom/{resourcemanager.js → resourcemanager.mjs} +6 -6
- package/test/cases/dom/{template.js → template.mjs} +3 -3
- package/test/cases/dom/{theme.js → theme.mjs} +3 -3
- package/test/cases/dom/{updater.js → updater.mjs} +6 -6
- package/test/cases/dom/{util.js → util.mjs} +2 -2
- package/test/cases/dom/worker/{factory.js → factory.mjs} +4 -4
- package/test/cases/i18n/{formatter.js → formatter.mjs} +2 -2
- package/test/cases/i18n/{locale.js → locale.mjs} +1 -1
- package/test/cases/i18n/{provider.js → provider.mjs} +1 -1
- package/test/cases/i18n/providers/{fetch.js → fetch.mjs} +3 -3
- package/test/cases/i18n/{translations.js → translations.mjs} +2 -2
- package/test/cases/logging/handler/{console.js → console.mjs} +3 -3
- package/test/cases/logging/{handler.js → handler.mjs} +3 -3
- package/test/cases/logging/{logentry.js → logentry.mjs} +1 -1
- package/test/cases/logging/{logger.js → logger.mjs} +1 -1
- package/test/cases/math/random.mjs +101 -0
- package/test/cases/monster.mjs +20 -0
- package/test/cases/text/{formatter.js → formatter.mjs} +1 -1
- package/test/cases/types/{base.js → base.mjs} +1 -1
- package/test/cases/types/{basewithoptions.js → basewithoptions.mjs} +1 -1
- package/test/cases/types/{binary.js → binary.mjs} +1 -1
- package/test/cases/types/{dataurl.js → dataurl.mjs} +1 -1
- package/test/cases/types/{global.js → global.mjs} +1 -1
- package/test/cases/types/{id.js → id.mjs} +17 -6
- package/test/cases/types/{is.js → is.mjs} +20 -8
- package/test/cases/types/{mediatype.js → mediatype.mjs} +1 -1
- package/test/cases/types/{node.js → node.mjs} +3 -3
- package/test/cases/types/{nodelist.js → nodelist.mjs} +2 -2
- package/test/cases/types/{noderecursiveiterator.js → noderecursiveiterator.mjs} +3 -3
- package/test/cases/types/{observer.js → observer.mjs} +1 -1
- package/test/cases/types/{observerlist.js → observerlist.mjs} +2 -2
- package/test/cases/types/{proxyobserver.js → proxyobserver.mjs} +4 -4
- package/test/cases/types/{queue.js → queue.mjs} +1 -1
- package/test/cases/types/randomid.mjs +39 -0
- package/test/cases/types/regex.mjs +46 -0
- package/test/cases/types/{stack.js → stack.mjs} +1 -1
- package/test/cases/types/{tokenlist.js → tokenlist.mjs} +1 -1
- package/test/cases/types/{typeof.js → typeof.mjs} +3 -4
- package/test/cases/types/{uniquequeue.js → uniquequeue.mjs} +1 -1
- package/test/cases/types/{uuid.js → uuid.mjs} +30 -10
- package/test/cases/types/{validate.js → validate.mjs} +3 -4
- package/test/cases/types/{version.js → version.mjs} +1 -2
- package/test/cases/util/{clone.js → clone.mjs} +1 -1
- package/test/cases/util/{comparator.js → comparator.mjs} +1 -1
- package/test/cases/util/{deadmansswitch.js → deadmansswitch.mjs} +1 -1
- package/test/cases/util/{freeze.js → freeze.mjs} +1 -1
- package/test/cases/util/{processing.js → processing.mjs} +1 -1
- package/test/cases/util/{trimspaces.js → trimspaces.mjs} +1 -1
- package/test/util/{chai-dom.js → chai-dom.mjs} +0 -0
- package/test/util/{cleanupdom.js → cleanupdom.mjs} +0 -0
- package/test/util/{jsdom.js → jsdom.mjs} +2 -2
- package/test/util/{localstorage.js → localstorage.mjs} +0 -0
- package/test/web/import.js +77 -78
- package/test/web/prepare.js +0 -8
- package/test/web/test.html +5 -4
- package/test/web/tests.js +25731 -587
- package/dist/modules/constants.js +0 -2
- package/dist/modules/constraints/abstract.js +0 -2
- package/dist/modules/constraints/abstractoperator.js +0 -2
- package/dist/modules/constraints/andoperator.js +0 -2
- package/dist/modules/constraints/invalid.js +0 -2
- package/dist/modules/constraints/isarray.js +0 -2
- package/dist/modules/constraints/isobject.js +0 -2
- package/dist/modules/constraints/namespace.js +0 -2
- package/dist/modules/constraints/oroperator.js +0 -2
- package/dist/modules/constraints/valid.js +0 -2
- package/dist/modules/data/buildmap.js +0 -2
- package/dist/modules/data/buildtree.js +0 -2
- package/dist/modules/data/datasource/namespace.js +0 -2
- package/dist/modules/data/datasource/restapi/writeerror.js +0 -2
- package/dist/modules/data/datasource/restapi.js +0 -2
- package/dist/modules/data/datasource/storage/localstorage.js +0 -2
- package/dist/modules/data/datasource/storage/namespace.js +0 -2
- package/dist/modules/data/datasource/storage/sessionstorage.js +0 -2
- package/dist/modules/data/datasource/storage.js +0 -2
- package/dist/modules/data/datasource.js +0 -2
- package/dist/modules/data/diff.js +0 -2
- package/dist/modules/data/extend.js +0 -2
- package/dist/modules/data/namespace.js +0 -2
- package/dist/modules/data/pathfinder.js +0 -2
- package/dist/modules/data/pipe.js +0 -2
- package/dist/modules/data/transformer.js +0 -2
- package/dist/modules/dom/assembler.js +0 -2
- package/dist/modules/dom/attributes.js +0 -2
- package/dist/modules/dom/constants.js +0 -2
- package/dist/modules/dom/customcontrol.js +0 -2
- package/dist/modules/dom/customelement.js +0 -2
- package/dist/modules/dom/events.js +0 -2
- package/dist/modules/dom/focusmanager.js +0 -2
- package/dist/modules/dom/locale.js +0 -2
- package/dist/modules/dom/namespace.js +0 -2
- package/dist/modules/dom/ready.js +0 -2
- package/dist/modules/dom/resource/data.js +0 -2
- package/dist/modules/dom/resource/link/stylesheet.js +0 -2
- package/dist/modules/dom/resource/link.js +0 -2
- package/dist/modules/dom/resource/script.js +0 -2
- package/dist/modules/dom/resource.js +0 -2
- package/dist/modules/dom/resourcemanager.js +0 -2
- package/dist/modules/dom/template.js +0 -2
- package/dist/modules/dom/theme.js +0 -2
- package/dist/modules/dom/updater.js +0 -2
- package/dist/modules/dom/util.js +0 -2
- package/dist/modules/dom/worker/factory.js +0 -2
- package/dist/modules/i18n/formatter.js +0 -2
- package/dist/modules/i18n/locale.js +0 -2
- package/dist/modules/i18n/namespace.js +0 -2
- package/dist/modules/i18n/provider.js +0 -2
- package/dist/modules/i18n/providers/fetch.js +0 -2
- package/dist/modules/i18n/providers/namespace.js +0 -2
- package/dist/modules/i18n/translations.js +0 -2
- package/dist/modules/logging/handler/console.js +0 -2
- package/dist/modules/logging/handler/namespace.js +0 -2
- package/dist/modules/logging/handler.js +0 -2
- package/dist/modules/logging/logentry.js +0 -2
- package/dist/modules/logging/logger.js +0 -2
- package/dist/modules/logging/namespace.js +0 -2
- package/dist/modules/math/namespace.js +0 -2
- package/dist/modules/math/random.js +0 -2
- package/dist/modules/monster.js +0 -2
- package/dist/modules/namespace.js +0 -2
- package/dist/modules/text/formatter.js +0 -2
- package/dist/modules/text/namespace.js +0 -2
- package/dist/modules/types/base.js +0 -2
- package/dist/modules/types/basewithoptions.js +0 -2
- package/dist/modules/types/binary.js +0 -2
- package/dist/modules/types/dataurl.js +0 -2
- package/dist/modules/types/global.js +0 -2
- package/dist/modules/types/id.js +0 -2
- package/dist/modules/types/is.js +0 -2
- package/dist/modules/types/mediatype.js +0 -2
- package/dist/modules/types/namespace.js +0 -2
- package/dist/modules/types/node.js +0 -2
- package/dist/modules/types/nodelist.js +0 -2
- package/dist/modules/types/noderecursiveiterator.js +0 -2
- package/dist/modules/types/observer.js +0 -2
- package/dist/modules/types/observerlist.js +0 -2
- package/dist/modules/types/proxyobserver.js +0 -2
- package/dist/modules/types/queue.js +0 -2
- package/dist/modules/types/randomid.js +0 -2
- package/dist/modules/types/regex.js +0 -2
- package/dist/modules/types/stack.js +0 -2
- package/dist/modules/types/tokenlist.js +0 -2
- package/dist/modules/types/typeof.js +0 -2
- package/dist/modules/types/uniquequeue.js +0 -2
- package/dist/modules/types/uuid.js +0 -2
- package/dist/modules/types/validate.js +0 -2
- package/dist/modules/types/version.js +0 -2
- package/dist/modules/util/clone.js +0 -2
- package/dist/modules/util/comparator.js +0 -2
- package/dist/modules/util/deadmansswitch.js +0 -2
- package/dist/modules/util/freeze.js +0 -2
- package/dist/modules/util/namespace.js +0 -2
- package/dist/modules/util/processing.js +0 -2
- package/dist/modules/util/trimspaces.js +0 -2
- package/dist/monster.dev.js +0 -15490
- package/dist/monster.dev.js.map +0 -1
- package/dist/monster.js +0 -2
- package/source/constraints/andoperator.js +0 -71
- package/source/constraints/invalid.js +0 -63
- package/source/constraints/isarray.js +0 -71
- package/source/constraints/isobject.js +0 -72
- package/source/constraints/valid.js +0 -63
- package/source/data/datasource/storage/localstorage.js +0 -64
- package/source/data/datasource/storage/sessionstorage.js +0 -61
- package/source/dom/resource/link/stylesheet.js +0 -54
- package/source/i18n/provider.js +0 -58
- package/source/i18n/providers/namespace.js +0 -16
- package/source/logging/handler/console.js +0 -66
- package/source/logging/handler/namespace.js +0 -14
- package/source/logging/logentry.js +0 -68
- package/source/monster.js +0 -80
- package/source/namespace.js +0 -171
- package/source/types/base.js +0 -50
- package/source/types/is.js +0 -429
- package/source/types/package.d.ts +0 -1
- package/source/types/randomid.js +0 -60
- package/source/types/regex.js +0 -49
- package/source/types/typeof.js +0 -63
- package/source/util/freeze.js +0 -57
- package/test/cases/math/random.js +0 -82
- package/test/cases/monster.js +0 -23
- package/test/cases/namespace.js +0 -93
- package/test/cases/types/randomid.js +0 -24
- package/test/cases/types/regex.js +0 -32
- package/test/web/monster-dev.html +0 -22
- package/test/web/monster.html +0 -21
@@ -0,0 +1,9 @@
|
|
1
|
+
import {Observer} from '@schukai/monster/source/types/observer.mjs';
|
2
|
+
|
3
|
+
const observer = new Observer(function (a, b, c) {
|
4
|
+
console.log(this, a, b, c); // ↦ "a", 2, true
|
5
|
+
}, "a", 2, true);
|
6
|
+
|
7
|
+
observer.update({value: true}).then(() => {
|
8
|
+
});
|
9
|
+
// ↦ {value: true} "a" 2 true
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import {ProxyObserver} from '@schukai/monster/source/types/proxyobserver.mjs';
|
2
|
+
import {Observer} from '@schukai/monster/source/types/observer.mjs';
|
3
|
+
import {isObject} from '@schukai/monster/source/types/is.mjs';
|
4
|
+
|
5
|
+
const o = new Observer(function () {
|
6
|
+
if (isObject(this) && this instanceof ProxyObserver) {
|
7
|
+
// do something (this ist ProxyObserver)
|
8
|
+
const subject = this.getSubject();
|
9
|
+
console.log(subject);
|
10
|
+
}
|
11
|
+
});
|
12
|
+
|
13
|
+
let realSubject = {
|
14
|
+
a: {
|
15
|
+
b: {
|
16
|
+
c: true
|
17
|
+
},
|
18
|
+
d: 9
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
const p = new ProxyObserver(realSubject);
|
23
|
+
p.attachObserver(o);
|
24
|
+
const s = p.getSubject();
|
25
|
+
s.a.b.c = false;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import {Queue} from '@schukai/monster/source/types/queue.mjs';
|
2
|
+
|
3
|
+
const queue = new Queue;
|
4
|
+
|
5
|
+
queue.add(2);
|
6
|
+
queue.add(true);
|
7
|
+
queue.add("Hello");
|
8
|
+
queue.add(4.5);
|
9
|
+
|
10
|
+
console.log(queue.poll());
|
11
|
+
// ↦ 2
|
12
|
+
console.log(queue.poll());
|
13
|
+
// ↦ true
|
14
|
+
console.log(queue.poll());
|
15
|
+
// ↦ "Hello"
|
16
|
+
console.log(queue.poll());
|
17
|
+
// ↦ 4.5
|
18
|
+
console.log(queue.poll());
|
19
|
+
// ↦ undefined
|
20
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import {TokenList} from '@schukai/monster/source/types/tokenlist.mjs';
|
2
|
+
|
3
|
+
new TokenList("start middle end").contains('start'); // ↦ true
|
4
|
+
new TokenList("start middle end").contains('end'); // ↦ true
|
5
|
+
new TokenList("start middle end").contains('xyz'); // ↦ false
|
6
|
+
new TokenList("start middle end").contains(['end','start','middle']); // ↦ true
|
7
|
+
new TokenList("start middle end").contains(['end','start','xyz']); // ↦ false
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import {TokenList} from '@schukai/monster/source/types/tokenlist.mjs';
|
2
|
+
|
3
|
+
new TokenList("abc def ghi").toggle("def xyz").toString(); // ↦ "abc ghi xyz"
|
4
|
+
new TokenList("abc def ghi").toggle(["abc", "xyz"]).toString(); // ↦ "def ghi xyz"
|
5
|
+
new TokenList().toggle(undefined); // ↦ nothing
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import {Comparator} from '@schukai/monster/source/util/comparator.mjs';
|
2
|
+
|
3
|
+
console.log(new Comparator().lessThanOrEqual(2, 5))
|
4
|
+
// ↦ true
|
5
|
+
console.log(new Comparator().greaterThan(4, 2))
|
6
|
+
// ↦ true
|
7
|
+
console.log(new Comparator().equal(4, 4))
|
8
|
+
// ↦ true
|
9
|
+
console.log(new Comparator().equal(4, 5))
|
10
|
+
// ↦ false
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import {DeadMansSwitch} from '@schukai/monster/source/util/deadmansswitch.mjs';
|
2
|
+
|
3
|
+
const deadmansswitch = new DeadMansSwitch(100, () => {
|
4
|
+
console.log('yeah!')
|
5
|
+
// ↦ "yeah!"
|
6
|
+
})
|
7
|
+
|
8
|
+
deadmansswitch.touch(); // from here wait again 100 ms
|
9
|
+
deadmansswitch.touch(200); // from here wait 200 ms
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import {Processing} from '@schukai/monster/source/util/processing.mjs';
|
2
|
+
|
3
|
+
let startTime = +new Date();
|
4
|
+
|
5
|
+
new Processing((url) => {
|
6
|
+
return fetch(url)
|
7
|
+
}, (response) => {
|
8
|
+
// do something with the response
|
9
|
+
console.log(response.status, +new Date() - startTime)
|
10
|
+
}, 200, () => {
|
11
|
+
// this function is called 200 seconds after fetch is received.
|
12
|
+
console.log('finished', +new Date() - startTime)
|
13
|
+
return 'done'
|
14
|
+
}).run('https://monsterjs.org/assets/world.json').then(r => {
|
15
|
+
console.log(r)
|
16
|
+
// ↦ "done"
|
17
|
+
})
|
package/package.json
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@schukai/monster",
|
3
|
-
"version": "
|
4
|
-
"types": "./source/types/package.d.ts",
|
3
|
+
"version": "2.0.0",
|
5
4
|
"description": "Monster is a simple library for creating fast, robust and lightweight websites.",
|
6
5
|
"keywords": [
|
7
6
|
"framework",
|
@@ -30,67 +29,14 @@
|
|
30
29
|
"log",
|
31
30
|
"theme"
|
32
31
|
],
|
32
|
+
"main": "source/monster.js",
|
33
|
+
"module": "source/monster.js",
|
33
34
|
"type": "module",
|
34
35
|
"homepage": "https://monsterjs.org",
|
35
36
|
"repository": {
|
36
37
|
"type": "git",
|
37
38
|
"url": "https://gitlab.schukai.com/oss/libraries/javascript/monster.git"
|
38
39
|
},
|
39
|
-
"main": "dist/monster.js",
|
40
|
-
"module": "dist/modules/monster.js",
|
41
40
|
"author": "schukai GmbH",
|
42
|
-
"license": "AGPL 3.0"
|
43
|
-
|
44
|
-
"last 10 version",
|
45
|
-
"> 1%",
|
46
|
-
"IE 10"
|
47
|
-
],
|
48
|
-
"browserify": {
|
49
|
-
"transform": [
|
50
|
-
[
|
51
|
-
"babelify",
|
52
|
-
{
|
53
|
-
"presets": [
|
54
|
-
[
|
55
|
-
"@babel/preset-env",
|
56
|
-
{
|
57
|
-
"useBuiltIns": "usage",
|
58
|
-
"corejs": 3,
|
59
|
-
"targets": {
|
60
|
-
"browsers": [
|
61
|
-
"last 2 versions",
|
62
|
-
"safari >= 7",
|
63
|
-
"ie >= 11"
|
64
|
-
]
|
65
|
-
}
|
66
|
-
}
|
67
|
-
]
|
68
|
-
],
|
69
|
-
"plugins": [
|
70
|
-
[
|
71
|
-
"@babel/plugin-transform-regenerator",
|
72
|
-
{
|
73
|
-
"asyncGenerators": false,
|
74
|
-
"generators": false,
|
75
|
-
"async": false
|
76
|
-
}
|
77
|
-
],
|
78
|
-
[
|
79
|
-
"@babel/plugin-transform-runtime",
|
80
|
-
{
|
81
|
-
"absoluteRuntime": false,
|
82
|
-
"corejs": false,
|
83
|
-
"helpers": true,
|
84
|
-
"regenerator": true,
|
85
|
-
"version": "7.0.0-beta.0"
|
86
|
-
}
|
87
|
-
],
|
88
|
-
[
|
89
|
-
"@babel/plugin-transform-classes"
|
90
|
-
]
|
91
|
-
]
|
92
|
-
}
|
93
|
-
]
|
94
|
-
]
|
95
|
-
}
|
96
|
-
}
|
41
|
+
"license": "AGPL 3.0"
|
42
|
+
}
|
@@ -1,15 +1,18 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
import {Monster} from './namespace.js';
|
4
1
|
/**
|
5
2
|
* Property-Keys
|
6
3
|
* @author schukai GmbH
|
7
4
|
*/
|
8
5
|
|
6
|
+
export {
|
7
|
+
internalSymbol,
|
8
|
+
internalStateSymbol
|
9
|
+
}
|
10
|
+
|
9
11
|
/**
|
10
12
|
* @private
|
11
13
|
* @type {symbol}
|
12
14
|
* @memberOf Monster
|
15
|
+
* @license AGPLv3
|
13
16
|
* @since 1.24.0
|
14
17
|
*/
|
15
18
|
const internalSymbol = Symbol('internalData');
|
@@ -18,14 +21,8 @@ const internalSymbol = Symbol('internalData');
|
|
18
21
|
* @private
|
19
22
|
* @type {symbol}
|
20
23
|
* @memberOf Monster
|
24
|
+
* @license AGPLv3
|
21
25
|
* @since 1.25.0
|
22
26
|
*/
|
23
27
|
const internalStateSymbol = Symbol('state');
|
24
28
|
|
25
|
-
|
26
|
-
export {
|
27
|
-
Monster,
|
28
|
-
internalSymbol,
|
29
|
-
internalStateSymbol
|
30
|
-
}
|
31
|
-
|
@@ -1,12 +1,13 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
1
|
/**
|
4
|
-
*
|
2
|
+
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
5
6
|
*/
|
6
7
|
|
7
|
-
import {
|
8
|
-
import {Base} from '../types/base.js';
|
8
|
+
import {Base} from '../types/base.mjs';
|
9
9
|
|
10
|
+
export {AbstractConstraint}
|
10
11
|
|
11
12
|
/**
|
12
13
|
* Constraints are used to define conditions that must be met by the value of a variable.
|
@@ -15,8 +16,9 @@ import {Base} from '../types/base.js';
|
|
15
16
|
*
|
16
17
|
* The abstract constraint defines the api for all constraints. mainly the method isValid() is defined.
|
17
18
|
*
|
18
|
-
*
|
19
|
+
* Derived classes must implement the method isValid().
|
19
20
|
*
|
21
|
+
* @license AGPLv3
|
20
22
|
* @since 1.3.0
|
21
23
|
* @copyright schukai GmbH
|
22
24
|
* @memberOf Monster.Constraints
|
@@ -41,6 +43,3 @@ class AbstractConstraint extends Base {
|
|
41
43
|
return Promise.reject(value);
|
42
44
|
}
|
43
45
|
}
|
44
|
-
|
45
|
-
assignToNamespace('Monster.Constraints', AbstractConstraint);
|
46
|
-
export {Monster, AbstractConstraint}
|
@@ -1,18 +1,23 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
1
|
/**
|
4
|
-
*
|
2
|
+
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
5
6
|
*/
|
6
|
-
|
7
|
-
import {AbstractConstraint} from "./abstract.
|
7
|
+
|
8
|
+
import {AbstractConstraint} from "./abstract.mjs";
|
9
|
+
|
10
|
+
export {AbstractOperator}
|
8
11
|
|
9
12
|
/**
|
10
13
|
* Constraints are used to define conditions that must be met by the value of a variable.
|
11
14
|
*
|
12
15
|
* The uniform API of the constraints allows chains to be formed.
|
13
16
|
*
|
14
|
-
* Operators allow you to link constraints together. for example, you can check whether a value is
|
17
|
+
* Operators allow you to link constraints together. for example, you can check whether a value is
|
18
|
+
* an object or an array. each operator has two operands that are linked together.
|
15
19
|
*
|
20
|
+
* @license AGPLv3
|
16
21
|
* @since 1.3.0
|
17
22
|
* @copyright schukai GmbH
|
18
23
|
* @memberOf Monster.Constraints
|
@@ -41,5 +46,3 @@ class AbstractOperator extends AbstractConstraint {
|
|
41
46
|
|
42
47
|
}
|
43
48
|
|
44
|
-
assignToNamespace('Monster.Constraints', AbstractOperator);
|
45
|
-
export {Monster, AbstractOperator}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
|
+
*/
|
7
|
+
|
8
|
+
import {AbstractOperator} from "./abstractoperator.mjs";
|
9
|
+
|
10
|
+
export {AndOperator}
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Constraints are used to define conditions that must be met by the value of a variable.
|
14
|
+
*
|
15
|
+
* The uniform API of the constraints allows chains to be formed.
|
16
|
+
*
|
17
|
+
* The AndOperator is used to link several constraints. The constraint is fulfilled if all constraints of the operators are fulfilled.
|
18
|
+
*
|
19
|
+
* @externalExample ../../example/constraints/andoperator.mjs
|
20
|
+
* @license AGPLv3
|
21
|
+
* @since 1.3.0
|
22
|
+
* @copyright schukai GmbH
|
23
|
+
* @memberOf Monster.Constraints
|
24
|
+
* @summary A and operator constraint
|
25
|
+
*/
|
26
|
+
class AndOperator extends AbstractOperator {
|
27
|
+
|
28
|
+
/**
|
29
|
+
* this method return a promise containing the result of the check.
|
30
|
+
*
|
31
|
+
* @param {*} value
|
32
|
+
* @returns {Promise}
|
33
|
+
*/
|
34
|
+
isValid(value) {
|
35
|
+
return Promise.all([this.operantA.isValid(value), this.operantB.isValid(value)]);
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
|
+
*/
|
7
|
+
|
8
|
+
import {AbstractConstraint} from "./abstract.mjs";
|
9
|
+
|
10
|
+
export {Invalid}
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Constraints are used to define conditions that must be met by the value of a variable.
|
14
|
+
*
|
15
|
+
* The uniform API of the constraints allows chains to be formed.
|
16
|
+
*
|
17
|
+
* The invalid constraint allows an always invalid query to be performed. this constraint is mainly intended for testing.
|
18
|
+
*
|
19
|
+
* @externalExample ../../example/constraints/invalid.mjs
|
20
|
+
* @license AGPLv3
|
21
|
+
* @since 1.3.0
|
22
|
+
* @copyright schukai GmbH
|
23
|
+
* @memberOf Monster.Constraints
|
24
|
+
* @summary A constraint that always invalid
|
25
|
+
*/
|
26
|
+
class Invalid extends AbstractConstraint {
|
27
|
+
|
28
|
+
/**
|
29
|
+
* this method return a rejected promise
|
30
|
+
*
|
31
|
+
* @param {*} value
|
32
|
+
* @returns {Promise}
|
33
|
+
*/
|
34
|
+
isValid(value) {
|
35
|
+
return Promise.reject(value);
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
|
+
*/
|
7
|
+
|
8
|
+
import {isArray} from "../types/is.mjs";
|
9
|
+
import {AbstractConstraint} from "./abstract.mjs";
|
10
|
+
|
11
|
+
export {IsArray}
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Constraints are used to define conditions that must be met by the value of a variable.
|
15
|
+
*
|
16
|
+
* The uniform API of the constraints allows chains to be formed.
|
17
|
+
*
|
18
|
+
* @externalExample ../../example/constraints/isarray.mjs
|
19
|
+
* @license AGPLv3
|
20
|
+
* @since 1.3.0
|
21
|
+
* @copyright schukai GmbH
|
22
|
+
* @memberOf Monster.Constraints
|
23
|
+
* @summary A constraint to check if a value is an array
|
24
|
+
*/
|
25
|
+
class IsArray extends AbstractConstraint {
|
26
|
+
|
27
|
+
/**
|
28
|
+
* this method return a promise containing the result of the check.
|
29
|
+
*
|
30
|
+
* @param {*} value
|
31
|
+
* @returns {Promise}
|
32
|
+
*/
|
33
|
+
isValid(value) {
|
34
|
+
if (isArray(value)) {
|
35
|
+
return Promise.resolve(value);
|
36
|
+
}
|
37
|
+
|
38
|
+
return Promise.reject(value);
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
|
+
*/
|
7
|
+
|
8
|
+
import {isObject} from "../types/is.mjs";
|
9
|
+
import {AbstractConstraint} from "./abstract.mjs";
|
10
|
+
|
11
|
+
export {IsObject}
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Constraints are used to define conditions that must be met by the value of a variable.
|
15
|
+
*
|
16
|
+
* The uniform API of the constraints allows chains to be formed.
|
17
|
+
*
|
18
|
+
* @externalExample ../../example/constraints/isobject.mjs
|
19
|
+
* @license AGPLv3
|
20
|
+
* @since 1.3.0
|
21
|
+
* @copyright schukai GmbH
|
22
|
+
* @memberOf Monster.Constraints
|
23
|
+
* @summary A constraint to check if a value is an object
|
24
|
+
*/
|
25
|
+
class IsObject extends AbstractConstraint {
|
26
|
+
|
27
|
+
/**
|
28
|
+
* this method return a promise containing the result of the check.
|
29
|
+
*
|
30
|
+
* @param {*} value
|
31
|
+
* @returns {Promise}
|
32
|
+
*/
|
33
|
+
isValid(value) {
|
34
|
+
if (isObject(value)) {
|
35
|
+
return Promise.resolve(value);
|
36
|
+
}
|
37
|
+
|
38
|
+
return Promise.reject(value);
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
@@ -1,15 +1,10 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Constraints are used to define conditions that must be met by the value of a variable so that the value can be transferred to the system.
|
5
5
|
*
|
6
|
-
* @namespace Constraints
|
6
|
+
* @namespace Monster.Constraints
|
7
7
|
* @memberOf Monster
|
8
8
|
* @author schukai GmbH
|
9
9
|
*/
|
10
|
-
|
11
|
-
/**
|
12
|
-
* @private
|
13
|
-
* @type {string}
|
14
|
-
*/
|
15
|
-
export const namespace = "Monster.Constraints";
|
10
|
+
const ns = {};
|
@@ -1,10 +1,13 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
1
|
/**
|
4
|
-
*
|
2
|
+
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
5
6
|
*/
|
6
|
-
|
7
|
-
import {AbstractOperator} from "./abstractoperator.
|
7
|
+
|
8
|
+
import {AbstractOperator} from "./abstractoperator.mjs";
|
9
|
+
|
10
|
+
export {OrOperator}
|
8
11
|
|
9
12
|
/**
|
10
13
|
* Constraints are used to define conditions that must be met by the value of a variable.
|
@@ -13,40 +16,8 @@ import {AbstractOperator} from "./abstractoperator.js";
|
|
13
16
|
*
|
14
17
|
* The OrOperator is used to link several constraints. The constraint is fulfilled if one of the constraints is fulfilled.
|
15
18
|
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
|
19
|
-
* new Monster.Constraint.OrOperator();
|
20
|
-
* </script>
|
21
|
-
* ```
|
22
|
-
*
|
23
|
-
* Alternatively, you can also integrate this function individually.
|
24
|
-
*
|
25
|
-
* ```
|
26
|
-
* <script type="module">
|
27
|
-
* import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/constraint/oroperator.js';
|
28
|
-
* new OrOperator();
|
29
|
-
* </script>
|
30
|
-
* ```
|
31
|
-
*
|
32
|
-
* @example
|
33
|
-
*
|
34
|
-
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/constraints/valid.js';
|
35
|
-
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/constraints/invalid.js';
|
36
|
-
* import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/constraints/oroperator.js';
|
37
|
-
*
|
38
|
-
* new OrOperator(
|
39
|
-
* new Valid(), new Invalid()).isValid()
|
40
|
-
* .then(()=>console.log(true))
|
41
|
-
* .catch(()=>console.log(false));
|
42
|
-
* // ↦ true
|
43
|
-
*
|
44
|
-
* new OrOperator(
|
45
|
-
* new Invalid(), new Invalid()).isValid()
|
46
|
-
* .then(()=>console.log(true))
|
47
|
-
* .catch(()=>console.log(false));
|
48
|
-
* // ↦ false
|
49
|
-
*
|
19
|
+
* @externalExample ../../example/constraints/oroperator.mjs
|
20
|
+
* @license AGPLv3
|
50
21
|
* @since 1.3.0
|
51
22
|
* @copyright schukai GmbH
|
52
23
|
* @memberOf Monster.Constraints
|
@@ -92,6 +63,3 @@ class OrOperator extends AbstractOperator {
|
|
92
63
|
|
93
64
|
|
94
65
|
}
|
95
|
-
|
96
|
-
assignToNamespace('Monster.Constraints', OrOperator);
|
97
|
-
export {Monster, OrOperator}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
|
+
*/
|
7
|
+
|
8
|
+
import {AbstractConstraint} from "./abstract.mjs";
|
9
|
+
|
10
|
+
export {Valid}
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Constraints are used to define conditions that must be met by the value of a variable.
|
14
|
+
*
|
15
|
+
* The uniform API of the constraints allows chains to be formed.
|
16
|
+
*
|
17
|
+
* The valid constraint allows an always valid query to be performed. this constraint is mainly intended for testing.
|
18
|
+
*
|
19
|
+
* @externalExample ../../example/constraints/valid.mjs
|
20
|
+
* @license AGPLv3
|
21
|
+
* @since 1.3.0
|
22
|
+
* @copyright schukai GmbH
|
23
|
+
* @memberOf Monster.Constraints
|
24
|
+
* @summary A constraint that always valid
|
25
|
+
*/
|
26
|
+
class Valid extends AbstractConstraint {
|
27
|
+
|
28
|
+
/**
|
29
|
+
* this method return a promise containing the result of the check.
|
30
|
+
*
|
31
|
+
* @param {*} value
|
32
|
+
* @returns {Promise}
|
33
|
+
*/
|
34
|
+
isValid(value) {
|
35
|
+
return Promise.resolve(value);
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|