@schukai/monster 1.30.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +17 -1
- 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} +55 -59
- 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.mjs +63 -0
- 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.mjs +42 -0
- 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 -77
- 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/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 -15469
- 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 -170
- 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
|
@@ -1,44 +1,25 @@
|
|
|
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 {
|
|
9
|
-
import {
|
|
10
|
-
|
|
8
|
+
import {isIterable, isString} from '../types/is.mjs';
|
|
9
|
+
import {validateFunction, validateString} from '../types/validate.mjs';
|
|
10
|
+
import {Base} from './base.mjs';
|
|
11
|
+
|
|
12
|
+
export {TokenList}
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
|
-
* A
|
|
14
|
-
*
|
|
15
|
-
* The tokenlist offers various functions to manipulate values. For example, you can add, remove or replace a class in a CSS list.
|
|
16
|
-
*
|
|
17
|
-
* You can call the method via the monster namespace `new Monster.Types.TokenList()`.
|
|
18
|
-
*
|
|
19
|
-
* ```
|
|
20
|
-
* <script type="module">
|
|
21
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
22
|
-
* new Monster.Types.TokenList("myclass row")
|
|
23
|
-
* </script>
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Alternatively, you can also integrate this function individually.
|
|
15
|
+
* A `TokenList` allows you to manage tokens (individual character strings such as css classes in an attribute string).
|
|
27
16
|
*
|
|
28
|
-
*
|
|
29
|
-
* <script type="module">
|
|
30
|
-
* import {TokenList} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/tokenlist.js';
|
|
31
|
-
* new TokenList("myclass row")
|
|
32
|
-
* </script>
|
|
33
|
-
* ```
|
|
17
|
+
* The `TokenList` offers various functions to manipulate values. For example, you can add, remove or replace a class in a CSS list.
|
|
34
18
|
*
|
|
35
19
|
* This class implements the [iteration protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
|
|
36
20
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* // ↦ "function"
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
21
|
+
* @externalExample ../../example/types/tokenlist-1.mjs
|
|
22
|
+
* @license AGPLv3
|
|
42
23
|
* @since 1.2.0
|
|
43
24
|
* @copyright schukai GmbH
|
|
44
25
|
* @memberOf Monster.Types
|
|
@@ -94,14 +75,7 @@ class TokenList extends Base {
|
|
|
94
75
|
/**
|
|
95
76
|
* Returns true if it contains token, otherwise false
|
|
96
77
|
*
|
|
97
|
-
*
|
|
98
|
-
* new TokenList("start middle end").contains('start')); // ↦ true
|
|
99
|
-
* new TokenList("start middle end").contains('end')); // ↦ true
|
|
100
|
-
* new TokenList("start middle end").contains('xyz')); // ↦ false
|
|
101
|
-
* new TokenList("start middle end").contains(['end','start','middle'])); // ↦ true
|
|
102
|
-
* new TokenList("start middle end").contains(['end','start','xyz'])); // ↦ false
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
78
|
+
* @externalExample ../../example/types/tokenlist-2.mjs
|
|
105
79
|
* @param {array|string|iteratable} value
|
|
106
80
|
* @returns {boolean}
|
|
107
81
|
*/
|
|
@@ -130,14 +104,9 @@ class TokenList extends Base {
|
|
|
130
104
|
}
|
|
131
105
|
|
|
132
106
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* ```
|
|
136
|
-
* new TokenList().add("abc xyz").toString(); // ↦ "abc xyz"
|
|
137
|
-
* new TokenList().add(["abc","xyz"]).toString(); // ↦ "abc xyz"
|
|
138
|
-
* new TokenList().add(undefined); // ↦ add nothing
|
|
139
|
-
* ```
|
|
107
|
+
* Add tokens
|
|
140
108
|
*
|
|
109
|
+
* @externalExample ../../example/types/tokenlist-3.mjs
|
|
141
110
|
* @param {array|string|iteratable} value
|
|
142
111
|
* @returns {TokenList}
|
|
143
112
|
* @throws {TypeError} unsupported value
|
|
@@ -172,12 +141,7 @@ class TokenList extends Base {
|
|
|
172
141
|
/**
|
|
173
142
|
* Removes token
|
|
174
143
|
*
|
|
175
|
-
*
|
|
176
|
-
* new TokenList("abc xyz").remove("xyz").toString(); // ↦ "abc"
|
|
177
|
-
* new TokenList("abc xyz").remove(["xyz"]).toString(); // ↦ "abc"
|
|
178
|
-
* new TokenList("abc xyz").remove(undefined); // ↦ remove nothing
|
|
179
|
-
* ```
|
|
180
|
-
*
|
|
144
|
+
* @externalExample ../../example/types/tokenlist-4.mjs
|
|
181
145
|
* @param {array|string|iteratable} value
|
|
182
146
|
* @returns {TokenList}
|
|
183
147
|
* @throws {TypeError} unsupported value
|
|
@@ -193,7 +157,7 @@ class TokenList extends Base {
|
|
|
193
157
|
this.tokens.delete(token.trim());
|
|
194
158
|
}
|
|
195
159
|
} else if (typeof value !== "undefined") {
|
|
196
|
-
throw new TypeError("unsupported value", "types/tokenlist.
|
|
160
|
+
throw new TypeError("unsupported value", "types/tokenlist.mjs");
|
|
197
161
|
}
|
|
198
162
|
|
|
199
163
|
return this;
|
|
@@ -232,12 +196,7 @@ class TokenList extends Base {
|
|
|
232
196
|
/**
|
|
233
197
|
* Removes token from string. If token doesn't exist it's added.
|
|
234
198
|
*
|
|
235
|
-
*
|
|
236
|
-
* new TokenList("abc def ghi").toggle("def xyz").toString(); // ↦ "abc ghi xyz"
|
|
237
|
-
* new TokenList("abc def ghi").toggle(["abc","xyz"]).toString(); // ↦ "def ghi xyz"
|
|
238
|
-
* new TokenList().toggle(undefined); // ↦ nothing
|
|
239
|
-
* ```
|
|
240
|
-
*
|
|
199
|
+
* @externalExample ../../example/types/tokenlist-5.mjs
|
|
241
200
|
* @param {array|string|iteratable} value
|
|
242
201
|
* @returns {boolean}
|
|
243
202
|
* @throws {TypeError} unsupported value
|
|
@@ -253,7 +212,7 @@ class TokenList extends Base {
|
|
|
253
212
|
toggleValue.call(this, token);
|
|
254
213
|
}
|
|
255
214
|
} else if (typeof value !== "undefined") {
|
|
256
|
-
throw new TypeError("unsupported value", "types/tokenlist.
|
|
215
|
+
throw new TypeError("unsupported value", "types/tokenlist.mjs");
|
|
257
216
|
}
|
|
258
217
|
|
|
259
218
|
return this;
|
|
@@ -309,6 +268,3 @@ function toggleValue(token) {
|
|
|
309
268
|
this.add(token);
|
|
310
269
|
return this;
|
|
311
270
|
}
|
|
312
|
-
|
|
313
|
-
assignToNamespace('Monster.Types', TokenList);
|
|
314
|
-
export {Monster, TokenList}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
export {typeOf}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The built-in typeof method is known to have some historical weaknesses. This function tries to provide a better and more accurate result.
|
|
12
|
+
*
|
|
13
|
+
* @externalExample ../../example/types/typeof.mjs
|
|
14
|
+
* @param {*} value
|
|
15
|
+
* @return {string}
|
|
16
|
+
* @license AGPLv3
|
|
17
|
+
* @since 1.7.0
|
|
18
|
+
* @copyright schukai GmbH
|
|
19
|
+
* @memberOf Monster.Types
|
|
20
|
+
* @throws {TypeError} value is not a primitive
|
|
21
|
+
*/
|
|
22
|
+
function typeOf(value) {
|
|
23
|
+
let type = ({}).toString.call(value).match(/\s([a-zA-Z]+)/)[1];
|
|
24
|
+
if ('Object' === type) {
|
|
25
|
+
|
|
26
|
+
const name = value.constructor.name;
|
|
27
|
+
if (name) {
|
|
28
|
+
return name.toLowerCase();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const results = (/^(class|function)\s+(\w+)/).exec(value.constructor.toString());
|
|
32
|
+
type = (results && results.length > 2) ? results[2] : '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return type.toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
|
|
@@ -1,38 +1,25 @@
|
|
|
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 {
|
|
9
|
-
|
|
8
|
+
import {Queue} from "./queue.mjs";
|
|
9
|
+
import {validateObject} from "./validate.mjs";
|
|
10
|
+
|
|
11
|
+
export {UniqueQueue}
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* ```
|
|
15
|
-
* <script type="module">
|
|
16
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
17
|
-
* new Monster.Types.UniqueQueue()
|
|
18
|
-
* </script>
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Alternatively, you can also integrate this function individually.
|
|
22
|
-
*
|
|
23
|
-
* ```
|
|
24
|
-
* <script type="module">
|
|
25
|
-
* import {UniqueQueue} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/uniquequeue.js';
|
|
26
|
-
* new UniqueQueue()
|
|
27
|
-
* </script>
|
|
28
|
-
* ```
|
|
14
|
+
* A UniqueQueue is a queue that contains items only once.
|
|
29
15
|
*
|
|
16
|
+
* @license AGPLv3
|
|
30
17
|
* @since 1.4.0
|
|
31
18
|
* @copyright schukai GmbH
|
|
32
19
|
* @memberOf Monster.Types
|
|
33
20
|
* @summary A queue for unique values
|
|
34
21
|
*/
|
|
35
|
-
class UniqueQueue extends Queue {
|
|
22
|
+
class UniqueQueue extends Queue {
|
|
36
23
|
|
|
37
24
|
/**
|
|
38
25
|
*
|
|
@@ -90,6 +77,3 @@ class UniqueQueue extends Queue {
|
|
|
90
77
|
|
|
91
78
|
|
|
92
79
|
}
|
|
93
|
-
|
|
94
|
-
assignToNamespace('Monster.Types', UniqueQueue);
|
|
95
|
-
export {Monster, UniqueQueue}
|
|
@@ -1,43 +1,28 @@
|
|
|
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 {internalSymbol} from "../constants.
|
|
8
|
-
import {random} from "../math/random.
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
8
|
+
import {internalSymbol} from "../constants.mjs";
|
|
9
|
+
import {random} from "../math/random.mjs";
|
|
10
|
+
import {isObject} from '../types/is.mjs';
|
|
11
|
+
import {Base} from "./base.mjs";
|
|
12
|
+
import {getGlobalObject} from "./global.mjs";
|
|
13
|
+
|
|
14
|
+
export {UUID}
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* ```
|
|
20
|
-
* <script type="module">
|
|
21
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
22
|
-
* new Monster.Types.UUID()
|
|
23
|
-
* </script>
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Or directly via the class:
|
|
27
|
-
*
|
|
28
|
-
* ```
|
|
29
|
-
* <script type="module">
|
|
30
|
-
* import {Base} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/uuid.js';
|
|
31
|
-
* new UUID()
|
|
32
|
-
* </script>
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
17
|
+
* The UUID class makes it possible to get a unique UUID for an object.
|
|
18
|
+
*
|
|
19
|
+
* @license AGPLv3
|
|
35
20
|
* @since 1.25.0
|
|
36
21
|
* @copyright schukai GmbH
|
|
37
22
|
* @memberOf Monster.Types
|
|
38
23
|
* @throws {Error} unsupported
|
|
39
24
|
*/
|
|
40
|
-
class UUID extends Base {
|
|
25
|
+
class UUID extends Base {
|
|
41
26
|
|
|
42
27
|
/**
|
|
43
28
|
*
|
|
@@ -97,6 +82,3 @@ function createWithCrypto() {
|
|
|
97
82
|
return crypt.randomUUID();
|
|
98
83
|
}
|
|
99
84
|
|
|
100
|
-
|
|
101
|
-
assignToNamespace('Monster.Types', UUID);
|
|
102
|
-
export {Monster, UUID}
|
|
@@ -1,10 +1,10 @@
|
|
|
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 {assignToNamespace, Monster} from '../namespace.js';
|
|
8
8
|
import {
|
|
9
9
|
isArray,
|
|
10
10
|
isBoolean,
|
|
@@ -16,26 +16,27 @@ import {
|
|
|
16
16
|
isPrimitive,
|
|
17
17
|
isString,
|
|
18
18
|
isSymbol
|
|
19
|
-
} from './is.
|
|
19
|
+
} from './is.mjs';
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
validateIterable,
|
|
23
|
+
validatePrimitive,
|
|
24
|
+
validateBoolean,
|
|
25
|
+
validateString,
|
|
26
|
+
validateObject,
|
|
27
|
+
validateInstance,
|
|
28
|
+
validateArray,
|
|
29
|
+
validateSymbol,
|
|
30
|
+
validateFunction,
|
|
31
|
+
validateInteger
|
|
32
|
+
}
|
|
20
33
|
|
|
21
34
|
/**
|
|
22
35
|
* This method checks if the type matches the primitive type. this function is identical to isPrimitive() except that a TypeError is thrown.
|
|
23
36
|
*
|
|
24
|
-
* You can call the method via the monster namespace `Monster.Types.validatePrimitive()`.
|
|
25
|
-
*
|
|
26
|
-
* ```
|
|
27
|
-
* <script type="module">
|
|
28
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
29
|
-
* console.log(Monster.Types.validateIterable('2')) // ↦ TypeError
|
|
30
|
-
* console.log(Monster.Types.validateIterable([])) // ↦ value
|
|
31
|
-
* </script>
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* Alternatively, you can also integrate this function individually.
|
|
35
|
-
*
|
|
36
37
|
* ```
|
|
37
38
|
* <script type="module">
|
|
38
|
-
* import {validateIterable} from '
|
|
39
|
+
* import {validateIterable} from '@schukai/monster/source/types/validate.mjs';
|
|
39
40
|
* console.log(validateIterable('2')) // ↦ TypeError
|
|
40
41
|
* console.log(validateIterable([])) // ↦ value
|
|
41
42
|
* </script>
|
|
@@ -43,6 +44,7 @@ import {
|
|
|
43
44
|
*
|
|
44
45
|
* @param {*} value
|
|
45
46
|
* @return {*}
|
|
47
|
+
* @license AGPLv3
|
|
46
48
|
* @since 1.2.0
|
|
47
49
|
* @copyright schukai GmbH
|
|
48
50
|
* @memberOf Monster.Types
|
|
@@ -61,21 +63,9 @@ function validateIterable(value) {
|
|
|
61
63
|
/**
|
|
62
64
|
* This method checks if the type matches the primitive type. this function is identical to isPrimitive() except that a TypeError is thrown.
|
|
63
65
|
*
|
|
64
|
-
* You can call the method via the monster namespace `Monster.Types.validatePrimitive()`.
|
|
65
|
-
*
|
|
66
66
|
* ```
|
|
67
67
|
* <script type="module">
|
|
68
|
-
* import {
|
|
69
|
-
* console.log(Monster.Types.validatePrimitive('2')) // ↦ value
|
|
70
|
-
* console.log(Monster.Types.validatePrimitive([])) // ↦ TypeError
|
|
71
|
-
* </script>
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* Alternatively, you can also integrate this function individually.
|
|
75
|
-
*
|
|
76
|
-
* ```
|
|
77
|
-
* <script type="module">
|
|
78
|
-
* import {validatePrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/validate.js';
|
|
68
|
+
* import {validatePrimitive} from '@schukai/monster/source/types/validate.mjs';
|
|
79
69
|
* console.log(validatePrimitive('2')) // ↦ value
|
|
80
70
|
* console.log(validatePrimitive([])) // ↦ TypeError
|
|
81
71
|
* </script>
|
|
@@ -83,6 +73,7 @@ function validateIterable(value) {
|
|
|
83
73
|
*
|
|
84
74
|
* @param {*} value
|
|
85
75
|
* @return {*}
|
|
76
|
+
* @license AGPLv3
|
|
86
77
|
* @since 1.0.0
|
|
87
78
|
* @copyright schukai GmbH
|
|
88
79
|
* @memberOf Monster.Types
|
|
@@ -101,22 +92,9 @@ function validatePrimitive(value) {
|
|
|
101
92
|
/**
|
|
102
93
|
* This method checks if the type matches the boolean type. this function is identical to isBoolean() except that a TypeError is thrown.
|
|
103
94
|
*
|
|
104
|
-
* You can call the method via the monster namespace `Monster.Types.validateBoolean()`.
|
|
105
|
-
*
|
|
106
|
-
* ```
|
|
107
|
-
* <script type="module">
|
|
108
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
109
|
-
* console.log(Monster.Types.validateBoolean(true)) // ↦ value
|
|
110
|
-
* console.log(Monster.Types.validateBoolean('2')) // ↦ TypeError
|
|
111
|
-
* console.log(Monster.Types.validateBoolean([])) // ↦ TypeError
|
|
112
|
-
* </script>
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* Alternatively, you can also integrate this function individually.
|
|
116
|
-
*
|
|
117
95
|
* ```
|
|
118
96
|
* <script type="module">
|
|
119
|
-
* import {validateBoolean} from '
|
|
97
|
+
* import {validateBoolean} from '@schukai/monster/source/types/validate.mjs';
|
|
120
98
|
* console.log(validateBoolean(false)) // ↦ value
|
|
121
99
|
* console.log(validateBoolean('2')) // ↦ TypeError
|
|
122
100
|
* console.log(validateBoolean([])) // ↦ TypeError
|
|
@@ -125,6 +103,7 @@ function validatePrimitive(value) {
|
|
|
125
103
|
*
|
|
126
104
|
* @param {*} value
|
|
127
105
|
* @return {*}
|
|
106
|
+
* @license AGPLv3
|
|
128
107
|
* @since 1.0.0
|
|
129
108
|
* @copyright schukai GmbH
|
|
130
109
|
* @memberOf Monster.Types
|
|
@@ -141,21 +120,9 @@ function validateBoolean(value) {
|
|
|
141
120
|
/**
|
|
142
121
|
* This method checks if the type matches the string type. this function is identical to isString() except that a TypeError is thrown.
|
|
143
122
|
*
|
|
144
|
-
* You can call the method via the monster namespace `Monster.Types.validateString()`.
|
|
145
|
-
*
|
|
146
123
|
* ```
|
|
147
124
|
* <script type="module">
|
|
148
|
-
* import {
|
|
149
|
-
* console.log(Monster.Types.validateString('2')) // ↦ value
|
|
150
|
-
* console.log(Monster.Types.validateString([])) // ↦ TypeError
|
|
151
|
-
* </script>
|
|
152
|
-
* ```
|
|
153
|
-
*
|
|
154
|
-
* Alternatively, you can also integrate this function individually.
|
|
155
|
-
*
|
|
156
|
-
* ```
|
|
157
|
-
* <script type="module">
|
|
158
|
-
* import {validateString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/validate.js';
|
|
125
|
+
* import {validateString} from '@schukai/monster/source/types/validate.mjs';
|
|
159
126
|
* console.log(validateString('2')) // ↦ value
|
|
160
127
|
* console.log(validateString([])) // ↦ TypeError
|
|
161
128
|
* </script>
|
|
@@ -163,6 +130,7 @@ function validateBoolean(value) {
|
|
|
163
130
|
*
|
|
164
131
|
* @param {*} value
|
|
165
132
|
* @return {*}
|
|
133
|
+
* @license AGPLv3
|
|
166
134
|
* @since 1.0.0
|
|
167
135
|
* @copyright schukai GmbH
|
|
168
136
|
* @memberOf Monster.Types
|
|
@@ -179,22 +147,9 @@ function validateString(value) {
|
|
|
179
147
|
/**
|
|
180
148
|
* This method checks if the type matches the object type. this function is identical to isObject() except that a TypeError is thrown.
|
|
181
149
|
*
|
|
182
|
-
* You can call the method via the monster namespace `Monster.Types.validateObject()`.
|
|
183
|
-
*
|
|
184
|
-
* ```
|
|
185
|
-
* <script type="module">
|
|
186
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
187
|
-
* console.log(Monster.Types.validateObject({})) // ↦ value
|
|
188
|
-
* console.log(Monster.Types.validateObject('2')) // ↦ TypeError
|
|
189
|
-
* console.log(Monster.Types.validateObject([])) // ↦ TypeError
|
|
190
|
-
* </script>
|
|
191
|
-
* ```
|
|
192
|
-
*
|
|
193
|
-
* Alternatively, you can also integrate this function individually.
|
|
194
|
-
*
|
|
195
150
|
* ```
|
|
196
151
|
* <script type="module">
|
|
197
|
-
* import {validateObject} from '
|
|
152
|
+
* import {validateObject} from '@schukai/monster/source/types/validate.mjs';
|
|
198
153
|
* console.log(validateObject({})) // ↦ value
|
|
199
154
|
* console.log(validateObject('2')) // ↦ TypeError
|
|
200
155
|
* console.log(validateObject([])) // ↦ TypeError
|
|
@@ -203,6 +158,7 @@ function validateString(value) {
|
|
|
203
158
|
*
|
|
204
159
|
* @param {*} value
|
|
205
160
|
* @return {*}
|
|
161
|
+
* @license AGPLv3
|
|
206
162
|
* @since 1.0.0
|
|
207
163
|
* @copyright schukai GmbH
|
|
208
164
|
* @memberOf Monster.Types
|
|
@@ -218,22 +174,9 @@ function validateObject(value) {
|
|
|
218
174
|
/**
|
|
219
175
|
* This method checks if the type matches the object instance.
|
|
220
176
|
*
|
|
221
|
-
* You can call the method via the monster namespace `Monster.Types.validateInstance()`.
|
|
222
|
-
*
|
|
223
|
-
* ```
|
|
224
|
-
* <script type="module">
|
|
225
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
226
|
-
* console.log(Monster.Types.validateInstance({}, Object)) // ↦ value
|
|
227
|
-
* console.log(Monster.Types.validateInstance('2', Object)) // ↦ TypeError
|
|
228
|
-
* console.log(Monster.Types.validateInstance([], Object)) // ↦ TypeError
|
|
229
|
-
* </script>
|
|
230
|
-
* ```
|
|
231
|
-
*
|
|
232
|
-
* Alternatively, you can also integrate this function individually.
|
|
233
|
-
*
|
|
234
177
|
* ```
|
|
235
178
|
* <script type="module">
|
|
236
|
-
* import {validateInstance} from '
|
|
179
|
+
* import {validateInstance} from '@schukai/monster/source/types/validate.mjs';
|
|
237
180
|
* console.log(validateInstance({}, Object)) // ↦ value
|
|
238
181
|
* console.log(validateInstance('2', Object)) // ↦ TypeError
|
|
239
182
|
* console.log(validateInstance([], Object)) // ↦ TypeError
|
|
@@ -242,6 +185,7 @@ function validateObject(value) {
|
|
|
242
185
|
*
|
|
243
186
|
* @param {*} value
|
|
244
187
|
* @return {*}
|
|
188
|
+
* @license AGPLv3
|
|
245
189
|
* @since 1.5.0
|
|
246
190
|
* @copyright schukai GmbH
|
|
247
191
|
* @memberOf Monster.Types
|
|
@@ -266,21 +210,9 @@ function validateInstance(value, instance) {
|
|
|
266
210
|
/**
|
|
267
211
|
* This method checks if the type matches the array type. this function is identical to isArray() except that a TypeError is thrown.
|
|
268
212
|
*
|
|
269
|
-
* You can call the method via the monster namespace `Monster.Types.validateArray()`.
|
|
270
|
-
*
|
|
271
213
|
* ```
|
|
272
214
|
* <script type="module">
|
|
273
|
-
* import {
|
|
274
|
-
* console.log(Monster.Types.validateArray('2')) // ↦ TypeError
|
|
275
|
-
* console.log(Monster.Types.validateArray([])) // ↦ value
|
|
276
|
-
* </script>
|
|
277
|
-
* ```
|
|
278
|
-
*
|
|
279
|
-
* Alternatively, you can also integrate this function individually.
|
|
280
|
-
*
|
|
281
|
-
* ```
|
|
282
|
-
* <script type="module">
|
|
283
|
-
* import {validateArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/validate.js';
|
|
215
|
+
* import {validateArray} from '@schukai/monster/source/types/validate.mjs';
|
|
284
216
|
* console.log(validateArray('2')) // ↦ TypeError
|
|
285
217
|
* console.log(validateArray([])) // ↦ value
|
|
286
218
|
* </script>
|
|
@@ -288,6 +220,7 @@ function validateInstance(value, instance) {
|
|
|
288
220
|
*
|
|
289
221
|
* @param {*} value
|
|
290
222
|
* @return {*}
|
|
223
|
+
* @license AGPLv3
|
|
291
224
|
* @since 1.0.0
|
|
292
225
|
* @copyright schukai GmbH
|
|
293
226
|
* @memberOf Monster.Types
|
|
@@ -303,21 +236,9 @@ function validateArray(value) {
|
|
|
303
236
|
/**
|
|
304
237
|
* This method checks if the type matches the symbol type. this function is identical to isSymbol() except that a TypeError is thrown.
|
|
305
238
|
*
|
|
306
|
-
* You can call the method via the monster namespace `Monster.Types.validateSymbol()`.
|
|
307
|
-
*
|
|
308
239
|
* ```
|
|
309
240
|
* <script type="module">
|
|
310
|
-
* import {
|
|
311
|
-
* console.log(Monster.Types.validateSymbol('2')) // ↦ TypeError
|
|
312
|
-
* console.log(Monster.Types.validateSymbol([])) // ↦ value
|
|
313
|
-
* </script>
|
|
314
|
-
* ```
|
|
315
|
-
*
|
|
316
|
-
* Alternatively, you can also integrate this function individually.
|
|
317
|
-
*
|
|
318
|
-
* ```
|
|
319
|
-
* <script type="module">
|
|
320
|
-
* import {validateSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/validate.js';
|
|
241
|
+
* import {validateSymbol} from '@schukai/monster/source/types/validate.mjs';
|
|
321
242
|
* console.log(validateSymbol('2')) // ↦ TypeError
|
|
322
243
|
* console.log(validateSymbol()) // ↦ value
|
|
323
244
|
* </script>
|
|
@@ -325,6 +246,7 @@ function validateArray(value) {
|
|
|
325
246
|
*
|
|
326
247
|
* @param {*} value
|
|
327
248
|
* @return {*}
|
|
249
|
+
* @license AGPLv3
|
|
328
250
|
* @since 1.9.0
|
|
329
251
|
* @copyright schukai GmbH
|
|
330
252
|
* @memberOf Monster.Types
|
|
@@ -340,22 +262,9 @@ function validateSymbol(value) {
|
|
|
340
262
|
/**
|
|
341
263
|
* This method checks if the type matches the function type. this function is identical to isFunction() except that a TypeError is thrown.
|
|
342
264
|
*
|
|
343
|
-
* You can call the method via the monster namespace `Monster.Types.validateFunction()`.
|
|
344
|
-
*
|
|
345
|
-
* ```
|
|
346
|
-
* <script type="module">
|
|
347
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
348
|
-
* console.log(Monster.Types.validateFunction(()=>{})) // ↦ value
|
|
349
|
-
* console.log(Monster.Types.validateFunction('2')) // ↦ TypeError
|
|
350
|
-
* console.log(Monster.Types.validateFunction([])) // ↦ TypeError
|
|
351
|
-
* </script>
|
|
352
|
-
* ```
|
|
353
|
-
*
|
|
354
|
-
* Alternatively, you can also integrate this function individually.
|
|
355
|
-
*
|
|
356
265
|
* ```
|
|
357
266
|
* <script type="module">
|
|
358
|
-
* import {validateFunction} from '
|
|
267
|
+
* import {validateFunction} from '@schukai/monster/source/types/validate.mjs';
|
|
359
268
|
* console.log(validateFunction(()=>{})) // ↦ value
|
|
360
269
|
* console.log(validateFunction('2')) // ↦ TypeError
|
|
361
270
|
* console.log(validateFunction([])) // ↦ TypeError
|
|
@@ -364,6 +273,7 @@ function validateSymbol(value) {
|
|
|
364
273
|
*
|
|
365
274
|
* @param {*} value
|
|
366
275
|
* @return {*}
|
|
276
|
+
* @license AGPLv3
|
|
367
277
|
* @since 1.0.0
|
|
368
278
|
* @copyright schukai GmbH
|
|
369
279
|
* @memberOf Monster.Types
|
|
@@ -379,22 +289,9 @@ function validateFunction(value) {
|
|
|
379
289
|
/**
|
|
380
290
|
* This method checks if the type is an integer. this function is identical to isInteger() except that a TypeError is thrown.
|
|
381
291
|
*
|
|
382
|
-
* You can call the method via the monster namespace `Monster.Types.validateInteger()`.
|
|
383
|
-
*
|
|
384
|
-
* ```
|
|
385
|
-
* <script type="module">
|
|
386
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
|
|
387
|
-
* console.log(Monster.Types.validateInteger(true)) // ↦ TypeError
|
|
388
|
-
* console.log(Monster.Types.validateInteger('2')) // ↦ TypeError
|
|
389
|
-
* console.log(Monster.Types.validateInteger(2)) // ↦ value
|
|
390
|
-
* </script>
|
|
391
|
-
* ```
|
|
392
|
-
*
|
|
393
|
-
* Alternatively, you can also integrate this function individually.
|
|
394
|
-
*
|
|
395
292
|
* ```
|
|
396
293
|
* <script type="module">
|
|
397
|
-
* import {validateFunction} from '
|
|
294
|
+
* import {validateFunction} from '@schukai/monster/source/types/validate.mjs';
|
|
398
295
|
* console.log(validateInteger(true)) // ↦ TypeError
|
|
399
296
|
* console.log(validateInteger('2')) // ↦ TypeError
|
|
400
297
|
* console.log(validateInteger(2)) // ↦ value
|
|
@@ -403,6 +300,7 @@ function validateFunction(value) {
|
|
|
403
300
|
*
|
|
404
301
|
* @param {*} value
|
|
405
302
|
* @return {*}
|
|
303
|
+
* @license AGPLv3
|
|
406
304
|
* @since 1.4.0
|
|
407
305
|
* @copyright schukai GmbH
|
|
408
306
|
* @memberOf Monster.Types
|
|
@@ -414,18 +312,3 @@ function validateInteger(value) {
|
|
|
414
312
|
}
|
|
415
313
|
return value
|
|
416
314
|
}
|
|
417
|
-
|
|
418
|
-
assignToNamespace('Monster.Types', validatePrimitive, validateBoolean, validateString, validateObject, validateArray, validateFunction, validateIterable, validateInteger);
|
|
419
|
-
export {
|
|
420
|
-
Monster,
|
|
421
|
-
validatePrimitive,
|
|
422
|
-
validateBoolean,
|
|
423
|
-
validateString,
|
|
424
|
-
validateObject,
|
|
425
|
-
validateInstance,
|
|
426
|
-
validateArray,
|
|
427
|
-
validateFunction,
|
|
428
|
-
validateIterable,
|
|
429
|
-
validateInteger,
|
|
430
|
-
validateSymbol
|
|
431
|
-
}
|