Monster/Types

Monster/Types

Source:
Author:
  • schukai GmbH

Classes

Base
ID
Observer
ObserverList
ProxyObserver
Queue
Stack
TokenList
UniqueQueue
Version

Methods

(static) isArray(value) → {boolean}

Source:
Since:
  • 1.0.0

checks whether the value passed is a array

you can call the method via the monster namespace Monster.Types.isArray().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isArray('2')) // ↦ false
console.log(Monster.Types.isArray([])) // ↦ true
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isArray('2'))  // ↦ false
console.log(isArray([]))  // ↦ true
</script>
Parameters:
Name Type Description
value *
Returns:
Type
boolean

(static) isBoolean(value) → {boolean}

Source:
Since:
  • 1.0.0

checks whether the value passed is a boolean

you can call the method via the monster namespace Monster.Types.isBoolean().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isBoolean('2')) // ↦ false
console.log(Monster.Types.isBoolean([])) // ↦ false
console.log(Monster.Types.isBoolean(true)) // ↦ true
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isBoolean('2'))  // ↦ false
console.log(isBoolean([]))  // ↦ false
console.log(isBoolean(2>4))  // ↦ true
</script>
Parameters:
Name Type Description
value *
Returns:
Type
boolean

(static) isFunction(value) → {boolean}

Source:
Since:
  • 1.0.0

checks whether the value passed is a function

you can call the method via the monster namespace Monster.Types.isFunction().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isFunction(()=>{})) // ↦ true
console.log(Monster.Types.isFunction('2')) // ↦ false
console.log(Monster.Types.isFunction([])) // ↦ false
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isFunction(()=>{})) // ↦ true
console.log(isFunction('2'))  // ↦ false
console.log(isFunction([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
Returns:
Type
boolean

(static) isInstance(value, instance) → {boolean}

Source:
Since:
  • 1.5.0

checks whether the value passed is a object and instance of instance

you can call the method via the monster namespace Monster.Types.isInstance().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isInstance('2')) // ↦ false
console.log(Monster.Types.isInstance([])) // ↦ false
console.log(Monster.Types.isInstance({})) // ↦ true
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isInstance('2'))  // ↦ false
console.log(isInstance([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
instance *
Returns:
Type
boolean

(static) isInteger(value) → {boolean}

Source:
Since:
  • 1.4.0

checks whether the value passed is an integer

you can call the method via the monster namespace Monster.Types.isFunction().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isInteger(()=>{})) // ↦ true
console.log(Monster.Types.isInteger('2')) // ↦ false
console.log(Monster.Types.isInteger(2)) // ↦ true
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isInteger} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isInteger(()=>{})) // ↦ true
console.log(isInteger('2'))  // ↦ false
console.log(isInteger(2))  // ↦ true
</script>
Parameters:
Name Type Description
value *
Returns:
Type
boolean

(static) isIterable(value) → {boolean}

Source:
Since:
  • 1.2.0

with this function you can check if a value is iterable

you can call the method via the monster namespace Monster.Types.isPrimitive().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isIterable(null)) // ↦ false
console.log(Monster.Types.isIterable('hello')) // ↦ true
console.log(Monster.Types.isIterable([])) // ↦ true
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isIterable} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isIterable(null))  // ↦ false
console.log(isIterable('hello'))  // ↦ true
console.log(isIterable([]))  // ↦ true
</script>
Parameters:
Name Type Description
value *
Returns:
Type
boolean

(static) isObject(value) → {boolean}

Source:
Since:
  • 1.0.0

checks whether the value passed is a object

you can call the method via the monster namespace Monster.Types.isObject().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isObject('2')) // ↦ false
console.log(Monster.Types.isObject([])) // ↦ false
console.log(Monster.Types.isObject({})) // ↦ true
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isObject('2'))  // ↦ false
console.log(isObject([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
Returns:
Type
boolean

(static) isPrimitive(value) → {boolean}

Source:
Since:
  • 1.0.0

checks whether the value passed is a primitive (string, number, boolean, NaN, undefined, null or symbol)

you can call the method via the monster namespace Monster.Types.isPrimitive().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isPrimitive('2')) // ↦ false
console.log(Monster.Types.isPrimitive([])) // ↦ true
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isPrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isPrimitive('2'))  // ↦ true
console.log(isPrimitive([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
Returns:
Type
boolean

(static) isString(value) → {boolean}

Source:
Since:
  • 1.0.0

checks whether the value passed is a string

you can call the method via the monster namespace Monster.Types.isString().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(Monster.Types.isString('2')) // ↦ true
console.log(Monster.Types.isString([])) // ↦ false
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/is.js';
console.log(isString('2'))  // ↦ true
console.log(isString([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
Returns:
Type
boolean

(static) validateArray(value) → {undefined}

Source:
Since:
  • 1.0.0

this method checks if the type matches the array type. this function is identical to isArray() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validateArray().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validateArray('2')) // ↦ TypeError
console.log(Monster.Types.validateArray([])) // ↦ undefined
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validateArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validateArray('2'))  // ↦ TypeError
console.log(validateArray([]))  // ↦ undefined
</script>
Parameters:
Name Type Description
value *
Throws:

value is not an array

Type
TypeError
Returns:
Type
undefined

(static) validateBoolean(value) → {undefined}

Source:
Since:
  • 1.0.0

this method checks if the type matches the boolean type. this function is identical to isBoolean() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validateBoolean().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validateBoolean(true)) // ↦ undefined
console.log(Monster.Types.validateBoolean('2')) // ↦ TypeError
console.log(Monster.Types.validateBoolean([])) // ↦ TypeError
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validateBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validateBoolean(false))  // ↦ undefined
console.log(validateBoolean('2'))  // ↦ TypeError
console.log(validateBoolean([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Throws:

value is not primitive

Type
TypeError
Returns:
Type
undefined

(static) validateFunction(value) → {undefined}

Source:
Since:
  • 1.0.0

this method checks if the type matches the function type. this function is identical to isFunction() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validateFunction().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validateFunction(()=>{})) // ↦ undefined
console.log(Monster.Types.validateFunction('2')) // ↦ TypeError
console.log(Monster.Types.validateFunction([])) // ↦ TypeError
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validateFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validateFunction(()=>{})) // ↦ undefined
console.log(validateFunction('2'))  // ↦ TypeError
console.log(validateFunction([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Throws:

value is not a function

Type
TypeError
Returns:
Type
undefined

(static) validateInstance(value) → {undefined}

Source:
Since:
  • 1.5.0

this method checks if the type matches the object type. this function is identical to isObject() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validateObject().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validateInstance({}, Object)) // ↦ undefined
console.log(Monster.Types.validateInstance('2', Object)) // ↦ TypeError
console.log(Monster.Types.validateInstance([], Object)) // ↦ TypeError
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validateInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validateInstance({}, Object)) // ↦ undefined
console.log(validateInstance('2', Object)) // ↦ TypeError
console.log(validateInstance([], Object)) // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Throws:

value is not an instance of

Type
TypeError
Returns:
Type
undefined

(static) validateInteger(value) → {undefined}

Source:
Since:
  • 1.4.0

this method checks if the type is an integer. this function is identical to isInteger() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validateInteger().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validateInteger(true)) // ↦ TypeError
console.log(Monster.Types.validateInteger('2')) // ↦ TypeError
console.log(Monster.Types.validateInteger(2)) // ↦ undefined
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validateFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validateInteger(true)) // ↦ TypeError
console.log(validateInteger('2'))  // ↦ TypeError
console.log(validateInteger(2))  // ↦ undefined
</script>
Parameters:
Name Type Description
value *
Throws:

value is not an integer

Type
TypeError
Returns:
Type
undefined

(static) validateIterable(value) → {undefined}

Source:
Since:
  • 1.2.0
See:
  • isPrimitive
  • Monster/Types/isPrimitive
  • Monster/Types#isPrimitive

this method checks if the type matches the primitive type. this function is identical to isPrimitive() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validatePrimitive().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validateIterable('2')) // ↦ TypeError
console.log(Monster.Types.validateIterable([])) // ↦ undefined
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validateIterable} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validateIterable('2'))  // ↦ TypeError
console.log(validateIterable([]))  // ↦ undefined
</script>
Parameters:
Name Type Description
value *
Throws:

value is not a primitive

Type
TypeError
Returns:
Type
undefined

(static) validateObject(value) → {undefined}

Source:
Since:
  • 1.0.0

this method checks if the type matches the object type. this function is identical to isObject() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validateObject().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validateObject({})) // ↦ undefined
console.log(Monster.Types.validateObject('2')) // ↦ TypeError
console.log(Monster.Types.validateObject([])) // ↦ TypeError
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validateObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validateObject({}))  // ↦ undefined
console.log(validateObject('2'))  // ↦ TypeError
console.log(validateObject([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Throws:

value is not a object

Type
TypeError
Returns:
Type
undefined

(static) validatePrimitive(value) → {undefined}

Source:
Since:
  • 1.0.0
See:
  • isPrimitive
  • Monster/Types/isPrimitive
  • Monster/Types#isPrimitive

this method checks if the type matches the primitive type. this function is identical to isPrimitive() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validatePrimitive().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validatePrimitive('2')) // ↦ undefined
console.log(Monster.Types.validatePrimitive([])) // ↦ TypeError
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validatePrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validatePrimitive('2'))  // ↦ undefined
console.log(validatePrimitive([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Throws:

value is not a primitive

Type
TypeError
Returns:
Type
undefined

(static) validateString(value) → {undefined}

Source:
Since:
  • 1.0.0

this method checks if the type matches the string type. this function is identical to isString() except that a TypeError is thrown.

you can call the method via the monster namespace Monster.Types.validateString().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(Monster.Types.validateString('2')) // ↦ undefined
console.log(Monster.Types.validateString([])) // ↦ TypeError
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {validateString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/types/validate.js';
console.log(validateString('2'))  // ↦ undefined
console.log(validateString([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Throws:

value is not a string

Type
TypeError
Returns:
Type
undefined