Types

Monster. Types

Namespace for types.

Author:
  • schukai GmbH

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

Observer
ObserverList
ProxyObserver
Queue

A Queue (Fifo)

RandomID

class to generate random numbers

Stack
TokenList
UniqueQueue

A queue for unique values

UUID
Version

The version object contains a sematic version number

Methods

# (static) escapeString(value) → {string}

This function prefixes all special characters that may appear in a regex with a slash.

You can call the method via the monster namespace Monster.Types.escapeString().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
Monster.Types.escapeString()
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {escapeString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/validate.js';
escapeString()
</script>
Parameters:
Name Type Description
value string
Since:
  • 1.26.0
Throws:

value is not a string

Type
TypeError
Returns:
Type
string

# (static) fromBinary(binary) → {String}

You can call the function via the monster namespace Monster.Types.fromBinary().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
Monster.Types.fromBinary()
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {fromBinary} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/binary.js';
fromBinary()
</script>
Parameters:
Name Type Description
binary String
Since:
  • 1.18.0
Throws:

value is not a string

Type
TypeError
Returns:
Type
String

# (static) getGlobal() → {objec}

Return globalThis

If globalThis is not available, it will be polyfilled

Since:
  • 1.6.0
Returns:

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().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
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/monster@1.30.0/dist/modules/types/global.js';
console.log(getGlobalFunction('parseInt')) // ↦ f parseInt() { }
</script>
Parameters:
Name Type Description
name string
Since:
  • 1.6.0
Throws:
  • value is not a function

    Type
    TypeError
  • the function is not defined

    Type
    Error
  • value is not a string

    Type
    TypeError
Returns:
Type
objec

# (static) getGlobalObject(name) → {objec}

Return global object or throw Error

You can call the method via the monster namespace Monster.Types.getGlobalObject().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
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/monster@1.30.0/dist/modules/types/global.js';
getGlobalObject('document') 
// ↦ { }
</script>
Parameters:
Name Type Description
name string
Since:
  • 1.6.0
Throws:
  • the object is not defined

    Type
    Error
  • value is not a object

    Type
    TypeError
  • value is not a string

    Type
    TypeError
Returns:
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.

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.30.0/dist/monster.js';
Monster.Types.isArray('2') // ↦ false
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.30.0/dist/modules/types/is.js';
isArray('2'))  // ↦ false
isArray([]))  // ↦ true
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Returns:
Type
boolean

# (static) isBoolean(value) → {boolean}

Checks whether the value passed is a boolean.

This method is used in the library to have consistent names.

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.30.0/dist/monster.js';
Monster.Types.isBoolean('2') // ↦ false
Monster.Types.isBoolean([]) // ↦ false
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.30.0/dist/modules/types/is.js';
isBoolean('2'))  // ↦ false
isBoolean([]))  // ↦ false
isBoolean(2>4))  // ↦ true
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Returns:
Type
boolean

# (static) isFunction(value) → {boolean}

Checks whether the value passed is a function

This method is used in the library to have consistent names.

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.30.0/dist/monster.js';
Monster.Types.isFunction(()=>{}) // ↦ true
Monster.Types.isFunction('2') // ↦ false
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.30.0/dist/modules/types/is.js';
isFunction(()=>{}) // ↦ true
isFunction('2'))  // ↦ false
isFunction([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Returns:
Type
boolean

# (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.

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.30.0/dist/monster.js';
Monster.Types.isInstance('2') // ↦ false
Monster.Types.isInstance([]) // ↦ false
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.30.0/dist/modules/types/is.js';
isInstance('2'))  // ↦ false
isInstance([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
instance *
Since:
  • 1.5.0
Returns:
Type
boolean

# (static) isInteger(value) → {boolean}

Checks whether the value passed is an integer.

This method is used in the library to have consistent names.

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.30.0/dist/monster.js';
Monster.Types.isInteger(()=>{}) // ↦ true
Monster.Types.isInteger('2') // ↦ false
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.30.0/dist/modules/types/is.js';
isInteger(()=>{}) // ↦ true
isInteger('2'))  // ↦ false
isInteger(2))  // ↦ true
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.4.0
Returns:
Type
boolean

# (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().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
Monster.Types.isIterable(null) // ↦ false
Monster.Types.isIterable('hello') // ↦ true
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.30.0/dist/modules/types/is.js';
isIterable(null)  // ↦ false
isIterable('hello')  // ↦ true
isIterable([])  // ↦ true
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.2.0
Returns:
Type
boolean

# (static) isObject(value) → {boolean}

Checks whether the value passed is a object

This method is used in the library to have consistent names.

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.30.0/dist/monster.js';
Monster.Types.isObject('2') // ↦ false
Monster.Types.isObject([]) // ↦ false
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.30.0/dist/modules/types/is.js';
isObject('2'))  // ↦ false
isObject([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Returns:
Type
boolean

# (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.

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.30.0/dist/monster.js';
Monster.Types.isPrimitive('2') // ↦ false
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.30.0/dist/modules/types/is.js';
isPrimitive('2'))  // ↦ true
isPrimitive([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Returns:
Type
boolean

# (static) isString(value) → {boolean}

Checks whether the value passed is a string

This method is used in the library to have consistent names.

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.30.0/dist/monster.js';
Monster.Types.isString('2') // ↦ true
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.30.0/dist/modules/types/is.js';
isString('2'))  // ↦ true
isString([]))  // ↦ false
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Returns:
Type
boolean

# (static) isSymbol(value) → {boolean}

Checks whether the value passed is a symbol

This method is used in the library to have consistent names.

You can call the method via the monster namespace Monster.Types.isSymbol().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
Monster.Types.isSymbol('2') // ↦ false
Monster.Types.isSymbol(Symbol('test') // ↦ true
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {isSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/is.js';
isSymbol(Symbol('a')))  // ↦ true
isSymbol([])  // ↦ false
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.9.0
Returns:
Type
boolean

# (static) parseDataURL(dataurl) → {Monster.Types.DataUrl}

You can call the function via the monster namespace Monster.Types.parseDataURL().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
console.log(Monster.Types.parseDataURL())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {parseDataURL} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/dataurl.js';
console.log(parseDataURL())
</script>

Specification:

dataurl    := "data:" [ mediatype ] [ ";base64" ] "," data
mediatype  := [ type "/" subtype ] *( ";" parameter )
data       := *urlchar
parameter  := attribute "=" value
Parameters:
Name Type Description
dataurl String
Throws:
  • incorrect or missing data protocol

    Type
    TypeError
  • malformed data url

    Type
    TypeError
Returns:
Type
Monster.Types.DataUrl

# (static) parseMediaType(mediatype) → {Monster.Types.MediaType}

You can call the function via the monster namespace Monster.Types.parseMediaType().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
console.log(Monster.Types.parseMediaType())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {parseMediaType} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/dataurl.js';
console.log(parseMediaType())
</script>

Specification:

dataurl    := "data:" [ mediatype ] [ ";base64" ] "," data
mediatype  := [ type "/" subtype ] *( ";" parameter )
data       := *urlchar
parameter  := attribute "=" value
Parameters:
Name Type Description
mediatype String
Throws:
  • the mimetype can not be parsed

    Type
    TypeError
  • blank value is not allowed

    Type
    TypeError
  • malformed data url

    Type
    TypeError
Returns:
Type
Monster.Types.MediaType

# (static) toBinary(binary) → {String}

You can call the function via the monster namespace Monster.Types.toBinary().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
Monster.Types.toBinary()
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {toBinary} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/binary.js';
toBinary()
</script>
Parameters:
Name Type Description
binary String
Since:
  • 1.18.0
Throws:

value is not a string

Type
TypeError
Returns:
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.

You can call the method via the monster namespace Monster.Types.typeOf().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
console.log(Monster.Types.typeOf())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {typeOf} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/typeof.js';
console.log(typeOf())
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.7.0
Throws:

value is not a primitive

Type
TypeError
Returns:
Type
string
Example
import {typeOf} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/typeof.js';

console.log(typeOf(undefined)); // ↦ undefined
console.log(typeOf("")); // ↦ string
console.log(typeOf(5)); // ↦ number
console.log(typeOf({})); // ↦ object
console.log(typeOf([])); // ↦ array
console.log(typeOf(new Map)); // ↦ map
console.log(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.

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.30.0/dist/monster.js';
console.log(Monster.Types.validateArray('2')) // ↦ TypeError
console.log(Monster.Types.validateArray([])) // ↦ value
</script>

Alternatively, you can also integrate this function individually.

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

value is not an array

Type
TypeError
Returns:
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.

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.30.0/dist/monster.js';
console.log(Monster.Types.validateBoolean(true)) // ↦ value
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.30.0/dist/modules/types/validate.js';
console.log(validateBoolean(false))  // ↦ value
console.log(validateBoolean('2'))  // ↦ TypeError
console.log(validateBoolean([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Throws:

value is not primitive

Type
TypeError
Returns:
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.

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.30.0/dist/monster.js';
console.log(Monster.Types.validateFunction(()=>{})) // ↦ value
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.30.0/dist/modules/types/validate.js';
console.log(validateFunction(()=>{})) // ↦ value
console.log(validateFunction('2'))  // ↦ TypeError
console.log(validateFunction([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Throws:

value is not a function

Type
TypeError
Returns:
Type
*

# (static) validateInstance(value) → {*}

This method checks if the type matches the object instance.

You can call the method via the monster namespace Monster.Types.validateInstance().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
console.log(Monster.Types.validateInstance({}, Object)) // ↦ value
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.30.0/dist/modules/types/validate.js';
console.log(validateInstance({}, Object)) // ↦ value
console.log(validateInstance('2', Object)) // ↦ TypeError
console.log(validateInstance([], Object)) // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.5.0
Throws:

value is not an instance of

Type
TypeError
Returns:
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.

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.30.0/dist/monster.js';
console.log(Monster.Types.validateInteger(true)) // ↦ TypeError
console.log(Monster.Types.validateInteger('2')) // ↦ TypeError
console.log(Monster.Types.validateInteger(2)) // ↦ value
</script>

Alternatively, you can also integrate this function individually.

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

value is not an integer

Type
TypeError
Returns:
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.

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.30.0/dist/monster.js';
console.log(Monster.Types.validateIterable('2')) // ↦ TypeError
console.log(Monster.Types.validateIterable([])) // ↦ value
</script>

Alternatively, you can also integrate this function individually.

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

value is not a primitive

Type
TypeError
Returns:
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.

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.30.0/dist/monster.js';
console.log(Monster.Types.validateObject({})) // ↦ value
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.30.0/dist/modules/types/validate.js';
console.log(validateObject({}))  // ↦ value
console.log(validateObject('2'))  // ↦ TypeError
console.log(validateObject([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Throws:

value is not a object

Type
TypeError
Returns:
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.

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.30.0/dist/monster.js';
console.log(Monster.Types.validatePrimitive('2')) // ↦ value
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.30.0/dist/modules/types/validate.js';
console.log(validatePrimitive('2'))  // ↦ value
console.log(validatePrimitive([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
See:
Throws:

value is not a primitive

Type
TypeError
Returns:
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.

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.30.0/dist/monster.js';
console.log(Monster.Types.validateString('2')) // ↦ value
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.30.0/dist/modules/types/validate.js';
console.log(validateString('2'))  // ↦ value
console.log(validateString([]))  // ↦ TypeError
</script>
Parameters:
Name Type Description
value *
Since:
  • 1.0.0
Throws:

value is not a string

Type
TypeError
Returns:
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.

You can call the method via the monster namespace Monster.Types.validateSymbol().

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

Alternatively, you can also integrate this function individually.

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

value is not an symbol

Type
TypeError
Returns:
Type
*

Type Definitions

# Parameter

Type:
  • Object
Properties
Name Type Description
key string
value string