Methods
(static) deepCopy(oldObj) → {Object}
Create deep copy of a value object.
The object should have no functions/methods.
Parameters:
Name | Type | Description |
---|---|---|
oldObj |
Object | Object to copy |
Returns:
- Deep copy of object
- Type
- Object
(static) extractItem(array, item)
Extract item object from array
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array of elements |
item |
Object | Element to remove from array |
Returns:
- The element removed from array or null, if not found
(static) generateID() → {number}
Generate unique ID for an object in model
Returns:
- Type
- number
(static) getRandomElement(arr) → {Object}
Get random element from an array
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | Array to choose element from |
Returns:
- Random element in array
- Type
- Object
(static) loadRule(path, ruleName) → {Rule}
Load rule object by path and class name
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path where rule files are stored ('../../lib/rules/' in browser sample) |
ruleName |
string | Name of rule - equal to rule's class name (eg. 'RuleBgCasual') |
Returns:
- Rule object
- Type
- Rule
(static) removeItem(array, item)
Remove item from array
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array of elements |
item |
Object | Element to remove from array |
(static) rotateLeft(array)
Rotate array elements left.
Example:
[6, 4, 1] becomes [4, 1, 6]
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array of elements |
(static) sanitizeName(name) → {string}
Sanitize rule's name so that it is safe to use as a filename
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Rule's name to sanitize (eg. 'RuleBgCasual') |
Returns:
- Type
- string
(static) shallowCopy(oldObj) → {Object}
Create shallow copy of object.
Parameters:
Name | Type | Description |
---|---|---|
oldObj |
Object | Object to copy |
Returns:
- Shallow copy of object
- Type
- Object
(static) simulateServerLoad(oldObj) → {Object}
Simulate server load/hosting throttling
Parameters:
Name | Type | Description |
---|---|---|
oldObj |
Object | Object to copy |
Returns:
- Deep copy of object
- Type
- Object