Core
utils/core
Core utility functions/classes for Transformers.js.
These are only used internally, meaning an end-user shouldnβt need to access anything here.
static
.Callable:*.reverseDictionary(data)βObject.escapeRegExp(string)βstring.isString(text)βboolean.isTypedArray(val)βboolean.isIntegralNumber(x)βboolean.exists(x)βboolean.calculateDimensions(arr)βArray.mergeArrays(arrs)βArray
utils/core.Callable : <code> * </code>
A base class for creating callable objects.
Kind: static constant of utils/core
utils/core.reverseDictionary(data) β <code> Object </code>
Reverses the keys and values of an object.
Kind: static method of utils/core
Returns: Object - The reversed object.
See: https://ultimatecourses.com/blog/reverse-object-keys-and-values-in-javascript
data
Object
The object to reverse.
utils/core.escapeRegExp(string) β <code> string </code>
Escapes regular expression special characters from a string by replacing them with their escaped counterparts.
Kind: static method of utils/core
Returns: string - The escaped string.
string
string
The string to escape.
utils/core.isString(text) β <code> boolean </code>
Check if a value is a string.
Kind: static method of utils/core
Returns: boolean - True if the value is a string, false otherwise.
text
*
The value to check.
utils/core.isTypedArray(val) β <code> boolean </code>
Check if a value is a typed array.
Kind: static method of utils/core
Returns: boolean - True if the value is a TypedArray, false otherwise.
Adapted from https://stackoverflow.com/a/71091338/13989043
val
*
The value to check.
utils/core.isIntegralNumber(x) β <code> boolean </code>
Check if a value is an integer.
Kind: static method of utils/core
Returns: boolean - True if the value is a string, false otherwise.
x
*
The value to check.
utils/core.exists(x) β <code> boolean </code>
Check if a value is exists.
Kind: static method of utils/core
Returns: boolean - True if the value exists, false otherwise.
x
*
The value to check.
utils/core.calculateDimensions(arr) β <code> Array </code>
Calculates the dimensions of a nested array.
Kind: static method of utils/core
Returns: Array - An array containing the dimensions of the input array.
arr
Array
The nested array to calculate dimensions for.
utils/core.pop(obj, key, defaultValue) β <code> * </code>
Replicate pythonβs .pop() method for objects.
Kind: static method of utils/core
Returns: * - The value of the popped key.
Throws:
ErrorIf the key does not exist and no default value is provided.
obj
Object
The object to pop from.
key
string
The key to pop.
defaultValue
*
The default value to return if the key does not exist.
utils/core.mergeArrays(arrs) β <code> Array </code>
Efficiently merge arrays, creating a new copy. Adapted from https://stackoverflow.com/a/6768642/13989043
Kind: static method of utils/core
Returns: Array - The merged array.
arrs
Array.<Array>
Arrays to merge.
utils/core~Callable
Kind: inner class of utils/core
new Callable()
Creates a new instance of the Callable class.
callable._call(...args)
This method should be implemented in subclasses to provide the functionality of the callable object.
Kind: instance method of Callable
Throws:
ErrorIf the subclass does not implement the `_call` method.
...args
Array.<any>
Last updated