Namespace for utilities.
Classes
- Comparator
- Processing
Class to be able to execute function chains
Methods
# (static) clone(obj) → {*}
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.23.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.23.0/dist/modules/util/clone.js';
console.log(clone({}))
</script>
Name | Type | Description |
---|---|---|
obj |
* | object to be cloned |
- Since:
- 1.0.0
- Copyright:
- schukai GmbH
-
unable to clone obj! its type isn't supported.
- Type
- Error
- Type
- *
# (static) deepFreeze(object) → {object}
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.23.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.23.0/dist/modules/util/freeze.js';
console.log(deepFreeze({}))
</script>
Name | Type | Description |
---|---|---|
object |
object | object to be freeze |
- Since:
- 1.0.0
- Copyright:
- schukai GmbH
-
value is not a object
- Type
- TypeError
- Type
- object
Type Definitions
# exampleCallback(a, b) → {integer}
This is the description for the callback function used by the operator
new Comparator(function (a, b) {
if (a.v === b.v) return 0;
return a.v < b.v ? -1 : 1;
}).equal({v: 2}, {v: 2}); // ↦ true
Name | Type | Description |
---|---|---|
a |
* | |
b |
* |
-1, 0 or 1
- Type
- integer