Monster/Util

Monster/Util

Source:
Author:
  • schukai GmbH

Classes

Comparator

Methods

(static) clone(obj) → {*}

Source:
Since:
  • 1.0.0

with this function, objects can be cloned. the entire object tree is run through.

Proxy, Element, HTMLDocument and DocumentFragment instances are not cloned. Global objects such as windows are also not cloned,

If an object has a method getClone(), this method is used to create the clone.

you can call the method via the monster namespace Monster.Util.clone().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.6.0/dist/modules/util/clone.js';
console.log(Monster.Util.clone({}))
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {clone} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.6.0/dist/modules/util/clone.js';
console.log(clone({}))
</script>
Parameters:
Name Type Description
obj *

object to be cloned

Throws:

unable to clone obj! its type isn't supported.

Type
Error
Returns:
Type
*

(static) deepFreeze(obj) → {object}

Source:
Since:
  • 1.0.0

deep freeze a object

you can call the method via the monster namespace Monster.Util.deepFreeze().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.6.0/dist/modules/util/freeze.js';
console.log(Monster.Util.deepFreeze({})) 
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {deepFreeze} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.6.0/dist/modules/util/freeze.js';
console.log(deepFreeze({}))  
</script>
Parameters:
Name Type Description
obj object

object to be freeze

Throws:

value is not a object

Type
TypeError
Returns:
Type
object