Monster/Types

Monster/Types

Source:
Author:
  • schukai GmbH

Classes

ID
Object
Observer
ObserverList
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.0.14/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.0.14/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.0.14/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.0.14/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.0.14/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.0.14/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) 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.0.14/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.0.14/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 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.0.14/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.0.14/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.0.14/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.0.14/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.0.14/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.0.14/dist/modules/types/validate.js';
console.log(validateArray('2'))  // ↦ TypeError
console.log(validateArray([]))  // ↦ undefined
</script>
Parameters:
Name Type Description
value *
Throws:

value is not a 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.0.14/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.0.14/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.0.14/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.0.14/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) 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.0.14/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.0.14/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.0.14/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.0.14/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.0.14/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.0.14/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