Namespace for types.
Classes
- Base
- BaseWithOptions
- DataUrl
- ID
Automatic generation of ids
- MediaType
- Node
A Node Class
- NodeList
A NodeList class
- NodeRecursiveIterator
An iterator to run recursively through a tree of nodes
- ObservableQueue
An observable Queue (Fifo)
- Observer
- ObserverList
- ProxyObserver
- Queue
A Queue (Fifo)
- RandomID
class to generate random numbers
- Stack
- TokenList
- UUID
- UniqueQueue
A queue for unique values
- Version
The version object contains a sematic version number
Methods
(static) equipWithInternal()
This function extends the given object with the following methods:
- attachInternalObserver
- detachInternalObserver
- containsInternalObserver
- setInternal
- setInternals
- getInternal
This function extends the given object with the following methods:
- attachInternalObserver
- detachInternalObserver
- containsInternalObserver
- setInternal
- setInternals
- getInternal
- Since
- 3.15.0
- Copyright
- schukai GmbH
- License
- AGPLv3
(static) escapeString(value) → {string}
This function prefixes all special characters that may appear in a regex with a slash.
Name | Type | Description |
---|---|---|
value | string |
- Since
- 1.26.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not a string
- Type
- TypeError
- Type:
- string
(static) fromBinary(binary) → {String}
Monster.Types.fromBinary()
.You can call the function via the monster namespace Monster.Types.fromBinary()
.
Name | Type | Description |
---|---|---|
binary | String |
- Since
- 1.18.0
- License
- AGPLv3
value is not a string
- Type
- TypeError
- Type:
- String
(static) getGlobal() → {objec}
Return globalThis
If globalThis is not available, it will be polyfilled
.Return globalThis
If globalThis is not available, it will be polyfilled
- Since
- 1.6.0
- License
- AGPLv3
globalThis
- Type:
- objec
(static) getGlobalFunction(name) → {objec}
Return global function or throw Error
You can call the method via the monster namespace Monster.Types.getGlobalFunction()
.
Return global function or throw Error
You can call the method via the monster namespace Monster.Types.getGlobalFunction()
.
<script type="module">
import {Monster} from '@schukai/monster/source/monster.mjs';
console.log(Monster.Types.getGlobalFunction('parseInt')) // ↦ f parseInt() { }
</script>
Alternatively, you can also integrate this function individually.
<script type="module">
import {getGlobalFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/[email protected]/dist/modules/types/global.mjs';
console.log(getGlobalFunction('parseInt')) // ↦ f parseInt() { }
</script>
Name | Type | Description |
---|---|---|
name | string |
- Since
- 1.6.0
- License
- AGPLv3
value is not a function
- Type
- TypeError
the function is not defined
- Type
- Error
value is not a string
- Type
- TypeError
- Type:
- objec
(static) getGlobalObject(name) → {objec}
Return global object or throw Error
You can call the method via the monster namespace Monster.Types.getGlobalObject()
.
Return global object or throw Error
You can call the method via the monster namespace Monster.Types.getGlobalObject()
.
<script type="module">
import {Monster} from '@schukai/monster/source/monster.mjs';
Monster.Types.getGlobalObject('document')
// ↦ { }
</script>
Alternatively, you can also integrate this function individually.
<script type="module">
import {getGlobalObject} from 'https://cdn.jsdelivr.net/npm/@schukai/[email protected]/dist/modules/types/global.mjs';
getGlobalObject('document')
// ↦ { }
</script>
Name | Type | Description |
---|---|---|
name | string |
- Since
- 1.6.0
- License
- AGPLv3
the object is not defined
- Type
- Error
value is not a object
- Type
- TypeError
value is not a string
- Type
- TypeError
- Type:
- objec
(static) isArray(value) → {boolean}
Checks whether the value passed is a array
This method is used in the library to have consistent names.
Checks whether the value passed is a array
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isArray} from '@schukai/monster/source/types/is.mjs';
isArray('2') // ↦ false
isArray([]) // ↦ true
(static) isBoolean(value) → {boolean}
Checks whether the value passed is a boolean.
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isBoolean} from '@schukai/monster/source/types/is.mjs';
isBoolean('2') // ↦ false
isBoolean([]) // ↦ false
isBoolean(2 > 4) // ↦ true
(static) isFunction(value) → {boolean}
Checks whether the value passed is a function
This method is used in the library to have consistent names.
Checks whether the value passed is a function
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isFunction} from '@schukai/monster/source/types/is.mjs';
isFunction(() => {
}) // ↦ true
isFunction('2') // ↦ false
isFunction([]) // ↦ false
(static) isInstance(value, instance) → {boolean}
Checks whether the value passed is a object and instance of instance.
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * | |
instance | * |
- Since
- 1.5.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isInstance} from '@schukai/monster/source/types/is.mjs';
isInstance('2') // ↦ false
isInstance([]) // ↦ false
(static) isInteger(value) → {boolean}
Checks whether the value passed is an integer.
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.4.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isInteger} from '@schukai/monster/source/types/is.mjs';
isInteger(() => {
}) // ↦ true
isInteger('2') // ↦ false
isInteger(2) // ↦ true
(static) isIterable(value) → {boolean}
With this function you can check if a value is iterable.
This method is used in the library to have consistent names.
You can call the method via the monster namespace Monster.Types.isPrimitive()
.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.2.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isIterable} from '@schukai/monster/source/types/is.mjs';
isIterable(null) // ↦ false
isIterable('hello') // ↦ true
isIterable([]) // ↦ true
(static) isObject(value) → {boolean}
Checks whether the value passed is a object
This method is used in the library to have consistent names.
Checks whether the value passed is a object
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isObject} from '@schukai/monster/source/types/is.mjs';
isObject('2') // ↦ false
isObject([]) // ↦ false
(static) isPrimitive(value) → {boolean}
Checks whether the value passed is a primitive (string, number, boolean, NaN, undefined, null or symbol)
This method is used in the library to have consistent names.
Checks whether the value passed is a primitive (string, number, boolean, NaN, undefined, null or symbol)
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isPrimitive} from '@schukai/monster/source/types/is.mjs';
isPrimitive('2') // ↦ true
isPrimitive([]) // ↦ false
(static) isString(value) → {boolean}
Checks whether the value passed is a string
This method is used in the library to have consistent names.
Checks whether the value passed is a string
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isString} from '@schukai/monster/source/types/is.mjs';
isString('2') // ↦ true
isString([]) // ↦ false
(static) isSymbol(value) → {boolean}
Checks whether the value passed is a symbol
This method is used in the library to have consistent names.
Checks whether the value passed is a symbol
This method is used in the library to have consistent names.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.9.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- Type:
- boolean
import {isSymbol} from '@schukai/monster/source/types/is.mjs';
isSymbol(Symbol('a')) // ↦ true
isSymbol([]) // ↦ false
(static) parseDataURL(dataurl) → {Monster.Types.DataUrl}
Monster.Types.parseDataURL()
.You can call the function via the monster namespace Monster.Types.parseDataURL()
.
Specification:
dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
mediatype := [ type "/" subtype ] *( ";" parameter )
data := *urlchar
parameter := attribute "=" value
Name | Type | Description |
---|---|---|
dataurl | String |
incorrect or missing data protocol
- Type
- TypeError
malformed data url
- Type
- TypeError
- Type:
- Monster.
Types. DataUrl
(static) parseMediaType(mediatype) → {Monster.Types.MediaType}
Monster.Types.parseMediaType()
.You can call the function via the monster namespace Monster.Types.parseMediaType()
.
<script type="module">
import {Monster} from '@schukai/monster/source/monster.mjs';
console.log(Monster.Types.parseMediaType())
</script>
Alternatively, you can also integrate this function individually.
<script type="module">
import {parseMediaType} from '@schukai/monster/source/types/dataurl.mjs';
console.log(parseMediaType())
</script>
Specification:
dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
mediatype := [ type "/" subtype ] *( ";" parameter )
data := *urlchar
parameter := attribute "=" value
Name | Type | Description |
---|---|---|
mediatype | String |
the mimetype can not be parsed
- Type
- TypeError
blank value is not allowed
- Type
- TypeError
malformed data url
- Type
- TypeError
- Type:
- Monster.
Types. MediaType
(static) toBinary(binary) → {String}
Monster.Types.toBinary()
.You can call the function via the monster namespace Monster.Types.toBinary()
.
Name | Type | Description |
---|---|---|
binary | String |
- Since
- 1.18.0
- License
- AGPLv3
value is not a string
- Type
- TypeError
- Type:
- String
(static) typeOf(value) → {string}
The built-in typeof method is known to have some historical weaknesses. This function tries to provide a better and more accurate result.
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.7.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not a primitive
- Type
- TypeError
- Type:
- string
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
(static) validateArray(value) → {*}
This method checks if the type matches the array type. this function is identical to isArray() except that a TypeError is thrown.
<script type="module">
import {validateArray} from '@schukai/monster/source/types/validate.mjs';
console.log(validateArray('2')) // ↦ TypeError
console.log(validateArray([])) // ↦ value
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not an array
- Type
- TypeError
- Type:
- *
(static) validateBoolean(value) → {*}
This method checks if the type matches the boolean type. this function is identical to isBoolean() except that a TypeError is thrown.
<script type="module">
import {validateBoolean} from '@schukai/monster/source/types/validate.mjs';
console.log(validateBoolean(false)) // ↦ value
console.log(validateBoolean('2')) // ↦ TypeError
console.log(validateBoolean([])) // ↦ TypeError
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not primitive
- Type
- TypeError
- Type:
- *
(static) validateFunction(value) → {*}
This method checks if the type matches the function type. this function is identical to isFunction() except that a TypeError is thrown.
<script type="module">
import {validateFunction} from '@schukai/monster/source/types/validate.mjs';
console.log(validateFunction(()=>{})) // ↦ value
console.log(validateFunction('2')) // ↦ TypeError
console.log(validateFunction([])) // ↦ TypeError
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not a function
- Type
- TypeError
- Type:
- *
(static) validateInstance(value) → {*}
This method checks if the type matches the object instance.
<script type="module">
import {validateInstance} from '@schukai/monster/source/types/validate.mjs';
console.log(validateInstance({}, Object)) // ↦ value
console.log(validateInstance('2', Object)) // ↦ TypeError
console.log(validateInstance([], Object)) // ↦ TypeError
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.5.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not an instance of
- Type
- TypeError
- Type:
- *
(static) validateInteger(value) → {*}
This method checks if the type is an integer. this function is identical to isInteger() except that a TypeError is thrown.
<script type="module">
import {validateFunction} from '@schukai/monster/source/types/validate.mjs';
console.log(validateInteger(true)) // ↦ TypeError
console.log(validateInteger('2')) // ↦ TypeError
console.log(validateInteger(2)) // ↦ value
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.4.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not an integer
- Type
- TypeError
- Type:
- *
(static) validateIterable(value) → {*}
This method checks if the type matches the primitive type. this function is identical to isPrimitive() except that a TypeError is thrown.
<script type="module">
import {validateIterable} from '@schukai/monster/source/types/validate.mjs';
console.log(validateIterable('2')) // ↦ TypeError
console.log(validateIterable([])) // ↦ value
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.2.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- See
isPrimitive
Monster.Types.isPrimitive
Monster.Types#isPrimitive
value is not a primitive
- Type
- TypeError
- Type:
- *
(static) validateObject(value) → {*}
This method checks if the type matches the object type. this function is identical to isObject() except that a TypeError is thrown.
<script type="module">
import {validateObject} from '@schukai/monster/source/types/validate.mjs';
console.log(validateObject({})) // ↦ value
console.log(validateObject('2')) // ↦ TypeError
console.log(validateObject([])) // ↦ TypeError
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not a object
- Type
- TypeError
- Type:
- *
(static) validatePrimitive(value) → {*}
This method checks if the type matches the primitive type. this function is identical to isPrimitive() except that a TypeError is thrown.
<script type="module">
import {validatePrimitive} from '@schukai/monster/source/types/validate.mjs';
console.log(validatePrimitive('2')) // ↦ value
console.log(validatePrimitive([])) // ↦ TypeError
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- See
isPrimitive
Monster.Types.isPrimitive
Monster.Types#isPrimitive
value is not a primitive
- Type
- TypeError
- Type:
- *
(static) validateString(value) → {*}
This method checks if the type matches the string type. this function is identical to isString() except that a TypeError is thrown.
<script type="module">
import {validateString} from '@schukai/monster/source/types/validate.mjs';
console.log(validateString('2')) // ↦ value
console.log(validateString([])) // ↦ TypeError
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not a string
- Type
- TypeError
- Type:
- *
(static) validateSymbol(value) → {*}
This method checks if the type matches the symbol type. this function is identical to isSymbol() except that a TypeError is thrown.
<script type="module">
import {validateSymbol} from '@schukai/monster/source/types/validate.mjs';
console.log(validateSymbol('2')) // ↦ TypeError
console.log(validateSymbol()) // ↦ value
</script>
Name | Type | Description |
---|---|---|
value | * |
- Since
- 1.9.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not an symbol
- Type
- TypeError
- Type:
- *
Type Definitions
Parameter
- Object
Name | Type | Description |
---|---|---|
key | string | |
value | string |