Namespace: obj

noypiJS.obj

NOYPI obj funcs
Source:

Methods

(static) arsort(obj) → {boolean}

Sort an object in descending order and maintain index association.
Parameters:
Name Type Description
obj Object The object to sort.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) asort(obj) → {boolean}

Sort an object in ascending order and maintain index association.
Parameters:
Name Type Description
obj Object The object to sort.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) compact(…vars) → {Object}

Create an object containing variables and their values.
Parameters:
Name Type Attributes Description
vars any <repeatable>
The variables and their values to include in the object.
Source:
Returns:
The created object.
Type
Object

(static) count(obj, modeopt) → {number}

Counts all elements in an object or in a Countable object.
Parameters:
Name Type Attributes Default Description
obj Object | Countable The object to count elements in.
mode number <optional>
COUNT_NORMAL Optional. The mode for counting.
Source:
Returns:
The number of elements in the object.
Type
number

(static) current(obj) → {any}

Return the current element in an object.
Parameters:
Name Type Description
obj Object The object to get the current element from.
Source:
Returns:
The current element value.
Type
any

(static) each(obj) → {Object}

Return the current key and value pair from an object and advance the object cursor.
Parameters:
Name Type Description
obj Object The object to get the current key and value pair from.
Source:
Returns:
An object containing the current key and value, and then advances the cursor.
Type
Object

(static) end(obj) → {any}

Set the internal pointer of an object to its last element.
Parameters:
Name Type Description
obj Object The object to set the internal pointer in.
Source:
Returns:
The value of the last element in the object.
Type
any

(static) extract(obj) → {boolean}

Import variables into the current symbol table from an object.
Parameters:
Name Type Description
obj Object The object containing variables and their values.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) in_object(value, obj) → {boolean}

Checks if a value exists in an object.
Parameters:
Name Type Description
value any The value to check for.
obj Object The object to check in.
Source:
Returns:
True if the value exists in the object, false otherwise.
Type
boolean

(static) key(index, obj) → {string|boolean}

Fetch a key from an object.
Parameters:
Name Type Description
index number The index of the key to fetch.
obj Object The object to fetch the key from.
Source:
Returns:
The key at the specified index or false if the index is out of range.
Type
string | boolean

(static) krsort(obj) → {boolean}

Sort an object by key in descending order.
Parameters:
Name Type Description
obj Object The object to sort.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) ksort(obj) → {boolean}

Sort an object by key in ascending order.
Parameters:
Name Type Description
obj Object The object to sort.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) list(vars) → {Object}

Assign variables as if they were an object.
Parameters:
Name Type Description
vars any The variables to assign.
Source:
Returns:
The object containing the assigned variables.
Type
Object

(static) natcasesort(obj) → {boolean}

Sort an object using a case insensitive "natural order" algorithm.
Parameters:
Name Type Description
obj Object The object to sort.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) natsort(obj) → {boolean}

Sort an object using a "natural order" algorithm.
Parameters:
Name Type Description
obj Object The object to sort.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) next(obj) → {boolean}

Advance the internal pointer of an object.
Parameters:
Name Type Description
obj Object The object to advance the pointer in.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) object(…elements) → {Object}

Create an object.
Parameters:
Name Type Attributes Description
elements any <repeatable>
Optional. The elements to include in the object.
Source:
Returns:
The created object.
Type
Object

(static) object_change_key_case(obj, modeopt) → {Object}

Changes the case of all keys in an object.
Parameters:
Name Type Attributes Default Description
obj Object The object to change the case of keys for.
mode number <optional>
CASE_LOWER Optional. Case conversion mode. Use CASE_LOWER for lowercase keys (default), CASE_UPPER for uppercase keys.
Source:
Returns:
The object with keys in the desired case.
Type
Object

(static) object_chunk(obj, size) → {Array}

Split an object into chunks.
Parameters:
Name Type Description
obj Object The object to split into chunks.
size number The size of each chunk.
Source:
Returns:
An array of objects, each containing a chunk of the original object.
Type
Array

(static) object_column(obj, columnKey) → {Array}

Return the values from a single column in the input object.
Parameters:
Name Type Description
obj Object The input object.
columnKey string The column key to extract values from.
Source:
Returns:
An array containing the values from the specified column.
Type
Array

(static) object_combine(keys, values) → {Object}

Creates an object by using one object for keys and another for its values.
Parameters:
Name Type Description
keys Object The object containing keys.
values Object The object containing values.
Source:
Returns:
The resulting object with keys and their corresponding values.
Type
Object

(static) object_count_values(obj) → {Object}

Counts the occurrences of each distinct value in an object.
Parameters:
Name Type Description
obj Object The object to count values in.
Source:
Returns:
An object with distinct values as keys and their counts as values.
Type
Object

(static) object_diff(obj1, obj2) → {Object}

Computes the difference of objects.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
Source:
Returns:
An object containing values from obj1 that are not present in obj2.
Type
Object

(static) object_diff_assoc(obj1, obj2) → {Object}

Computes the difference of objects with additional index check.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
Source:
Returns:
An object containing values from obj1 that are not present in obj2.
Type
Object

(static) object_diff_key(obj1, obj2) → {Object}

Computes the difference of objects using keys for comparison.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
Source:
Returns:
An object containing values from obj1 whose keys are absent from obj2.
Type
Object

(static) object_diff_uassoc(obj1, obj2, callback) → {Object}

Computes the difference of objects with additional index check which is performed by a user supplied callback function.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
callback function The callback function to perform the index check.
Source:
Returns:
An object containing values from obj1 that are not present in obj2 based on the callback function.
Type
Object

(static) object_diff_ukey(obj1, obj2, callback) → {Object}

Computes the difference of objects using a callback function on the keys for comparison.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
callback function The callback function to perform the key comparison.
Source:
Returns:
An object containing values from obj1 whose keys are absent from obj2 based on the callback function.
Type
Object

(static) object_fill(obj, value) → {Object}

Fill an object with values.
Parameters:
Name Type Description
obj Object The object to fill with values.
value any The value to fill the object with.
Source:
Returns:
The object with all keys filled with the specified value.
Type
Object

(static) object_fill_keys(keys, value) → {Object}

Fill an object with values, specifying keys.
Parameters:
Name Type Description
keys Object The object containing keys to fill.
value any The value to fill the object with.
Source:
Returns:
The object with keys filled with the specified value.
Type
Object

(static) object_filter(obj, callback) → {Object}

Filters elements of an object using a callback function.
Parameters:
Name Type Description
obj Object The object to filter.
callback function The callback function to filter elements.
Source:
Returns:
The filtered object.
Type
Object

(static) object_flip(obj) → {Object}

Exchanges all keys with their associated values in an object.
Parameters:
Name Type Description
obj Object The object to flip keys and values.
Source:
Returns:
The object with keys and values flipped.
Type
Object

(static) object_intersect(obj1, obj2) → {Object}

Computes the intersection of objects.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
Source:
Returns:
An object containing values from obj1 that are present in obj2.
Type
Object

(static) object_intersect_assoc(obj1, obj2) → {Object}

Computes the intersection of objects with additional index check.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
Source:
Returns:
An object containing values from obj1 that are present in obj2.
Type
Object

(static) object_intersect_key(obj1, obj2) → {Object}

Computes the intersection of objects using keys for comparison.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
Source:
Returns:
An object containing values from obj1 whose keys are present in obj2.
Type
Object

(static) object_intersect_uassoc(obj1, obj2, callback) → {Object}

Computes the intersection of objects with additional index check, compares indexes by a callback function.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
callback function The callback function to perform the index check.
Source:
Returns:
An object containing values from obj1 that are present in obj2 based on the callback function.
Type
Object

(static) object_intersect_ukey(obj1, obj2, callback) → {Object}

Computes the intersection of objects using a callback function on the keys for comparison.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
callback function The callback function to perform the key comparison.
Source:
Returns:
An object containing values from obj1 whose keys are present in obj2 based on the callback function.
Type
Object

(static) object_is_list(obj) → {boolean}

Checks whether a given object is a list.
Parameters:
Name Type Description
obj Object The object to check.
Source:
Returns:
True if the object is a list (has numerical keys starting from 0), false otherwise.
Type
boolean

(static) object_key_exists(key, obj) → {boolean}

Checks if the given key or index exists in the object.
Parameters:
Name Type Description
key string | int The key or index to check.
obj Object The object to check.
Source:
Returns:
True if the key or index exists in the object, false otherwise.
Type
boolean

(static) object_key_first(obj) → {string|null}

Gets the first key of an object.
Parameters:
Name Type Description
obj Object The object to get the first key from.
Source:
Returns:
The first key of the object or null if the object is empty.
Type
string | null

(static) object_key_last(obj) → {string|null}

Gets the last key of an object.
Parameters:
Name Type Description
obj Object The object to get the last key from.
Source:
Returns:
The last key of the object or null if the object is empty.
Type
string | null

(static) object_keys(obj, searchValueopt, strictopt) → {Array}

Return all the keys or a subset of the keys of an object.
Parameters:
Name Type Attributes Default Description
obj Object The object to get the keys from.
searchValue string <optional>
Optional. If provided, only keys with this value are returned.
strict boolean <optional>
false Optional. Whether to do a strict (===) comparison when searching for keys.
Source:
Returns:
An array containing the keys of the object.
Type
Array

(static) object_map(callback, …objects) → {Array}

Applies the callback to the elements of the given objects.
Parameters:
Name Type Attributes Description
callback function The callback function to apply to each element.
objects Object <repeatable>
The objects to apply the callback on.
Source:
Returns:
An array containing the results of applying the callback to the elements.
Type
Array

(static) object_merge(…objects) → {Object}

Merge one or more objects.
Parameters:
Name Type Attributes Description
objects Object <repeatable>
The objects to merge.
Source:
Returns:
The merged object.
Type
Object

(static) object_merge_recursive(…objects) → {Object}

Merge one or more objects recursively.
Parameters:
Name Type Attributes Description
objects Object <repeatable>
The objects to merge.
Source:
Returns:
The merged object.
Type
Object

(static) object_multisort(…objects)

Sort multiple or multi-dimensional objects.
Parameters:
Name Type Attributes Description
objects Object <repeatable>
The objects to sort.
Source:

(static) object_pad(obj, size, value) → {Object}

Pad object to the specified length with a value.
Parameters:
Name Type Description
obj Object The object to pad.
size number The length to pad the object to.
value any The value to use for padding.
Source:
Returns:
The padded object.
Type
Object

(static) object_pop(obj) → {any}

Pop the element off the end of object.
Parameters:
Name Type Description
obj Object The object to pop from.
Source:
Returns:
The value of the popped element.
Type
any

(static) object_product(obj) → {number}

Calculate the product of values in an object.
Parameters:
Name Type Description
obj Object The object containing numeric values.
Source:
Returns:
The product of all values in the object.
Type
number

(static) object_push(obj, …elements) → {number}

Push one or more elements onto the end of object.
Parameters:
Name Type Attributes Description
obj Object The object to push elements onto.
elements any <repeatable>
The elements to push onto the object.
Source:
Returns:
The new number of elements in the object.
Type
number

(static) object_rand(obj, numopt) → {Array}

Pick one or more random keys out of an object.
Parameters:
Name Type Attributes Default Description
obj Object The object to pick random keys from.
num number <optional>
1 Optional. The number of random keys to pick.
Source:
Returns:
An array containing the randomly picked keys.
Type
Array

(static) object_reduce(obj, callback, initialValueopt) → {any}

Iteratively reduce the object to a single value using a callback function.
Parameters:
Name Type Attributes Description
obj Object The object to reduce.
callback function The callback function to apply.
initialValue any <optional>
Optional. The initial value for the reduction.
Source:
Returns:
The final result of the reduction.
Type
any

(static) object_replace(target, …sources) → {Object}

Replaces elements from passed objects into the first object.
Parameters:
Name Type Attributes Description
target Object The target object to replace elements in.
sources Object <repeatable>
The source objects containing elements to replace.
Source:
Returns:
The target object with replaced elements.
Type
Object

(static) object_replace_recursive(target, …sources) → {Object}

Replaces elements from passed objects into the first object recursively.
Parameters:
Name Type Attributes Description
target Object The target object to replace elements in.
sources Object <repeatable>
The source objects containing elements to replace.
Source:
Returns:
The target object with replaced elements.
Type
Object

(static) object_reverse(obj) → {Object}

Return an object with elements in reverse order.
Parameters:
Name Type Description
obj Object The object to reverse.
Source:
Returns:
The reversed object.
Type
Object
Searches the object for a given value and returns the first corresponding key if successful.
Parameters:
Name Type Attributes Default Description
obj Object The object to search in.
searchValue any The value to search for in the object.
strict boolean <optional>
false Optional. Whether to do a strict (===) comparison when searching for the value.
Source:
Returns:
The key of the first occurrence of the value in the object, or null if not found.
Type
string | null

(static) object_shift(obj) → {any}

Shift an element off the beginning of object.
Parameters:
Name Type Description
obj Object The object to shift from.
Source:
Returns:
The value of the shifted element.
Type
any

(static) object_slice(obj, offsetopt, lengthopt) → {Object}

Extract a slice of the object.
Parameters:
Name Type Attributes Default Description
obj Object The object to slice.
offset number <optional>
0 Optional. The starting index of the slice.
length number <optional>
Optional. The length of the slice.
Source:
Returns:
The sliced object.
Type
Object

(static) object_splice(obj, start, deleteCountopt, …itemsopt) → {Object}

Remove a portion of the object and replace it with something else.
Parameters:
Name Type Attributes Description
obj Object The object to splice.
start number The starting index where the splice begins.
deleteCount number <optional>
Optional. The number of elements to delete from the object.
items any <optional>
<repeatable>
Optional. The elements to add to the object at the spliced position.
Source:
Returns:
The spliced object.
Type
Object

(static) object_sum(obj) → {number}

Calculate the sum of values in an object.
Parameters:
Name Type Description
obj Object The object containing numeric values.
Source:
Returns:
The sum of all values in the object.
Type
number

(static) object_udiff(obj1, obj2, callback) → {Object}

Computes the difference of objects by using a callback function for data comparison.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
callback function The callback function to perform the data comparison.
Source:
Returns:
An object containing values from obj1 that are not present in obj2 based on the callback function.
Type
Object

(static) object_udiff_assoc(obj1, obj2, callback) → {Object}

Computes the difference of objects with additional index check, compares data by a callback function.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
callback function The callback function to perform the data comparison.
Source:
Returns:
An object containing values from obj1 that are not present in obj2 based on the callback function.
Type
Object

(static) object_udiff_uassoc(obj1, obj2, dataCallback, keyCallback) → {Object}

Computes the difference of objects with additional index check, compares data and indexes by a callback function.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
dataCallback function The callback function to perform the data comparison.
keyCallback function The callback function to perform the index comparison.
Source:
Returns:
An object containing values from obj1 that are not present in obj2 based on the callbacks.
Type
Object

(static) object_uintersect(obj1, obj2, callback) → {Object}

Computes the intersection of objects, compares data by a callback function.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
callback function The callback function to perform the data comparison.
Source:
Returns:
An object containing values from obj1 that are present in obj2 based on the callback function.
Type
Object

(static) object_uintersect_assoc(obj1, obj2, callback) → {Object}

Computes the intersection of objects with additional index check, compares data by a callback function.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
callback function The callback function to perform the data comparison.
Source:
Returns:
An object containing values from obj1 that are present in obj2 based on the callback function.
Type
Object

(static) object_uintersect_uassoc(obj1, obj2, dataCallback, keyCallback) → {Object}

Computes the intersection of objects with additional index check, compares data and indexes by separate callback functions.
Parameters:
Name Type Description
obj1 Object The first object to compare.
obj2 Object The second object to compare.
dataCallback function The callback function to perform the data comparison.
keyCallback function The callback function to perform the index comparison.
Source:
Returns:
An object containing values from obj1 that are present in obj2 based on the callbacks.
Type
Object

(static) object_unique(obj) → {Object}

Removes duplicate values from an object.
Parameters:
Name Type Description
obj Object The object to remove duplicates from.
Source:
Returns:
The object with duplicate values removed.
Type
Object

(static) object_unshift(obj, …elements) → {number}

Prepend one or more elements to the beginning of an object.
Parameters:
Name Type Attributes Description
obj Object The object to prepend elements to.
elements any <repeatable>
The elements to prepend to the object.
Source:
Returns:
The new number of elements in the object.
Type
number

(static) object_values(obj) → {Array}

Return all the values of an object.
Parameters:
Name Type Description
obj Object The object to get the values from.
Source:
Returns:
An array containing the values of the object.
Type
Array

(static) object_walk(obj, callback, userdataopt) → {boolean}

Apply a user supplied function to every member of an object.
Parameters:
Name Type Attributes Description
obj Object The object to apply the function to.
callback function The callback function to apply.
userdata any <optional>
Optional. User-defined data to pass to the callback function.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) object_walk_recursive(obj, callback, userdataopt) → {boolean}

Apply a user function recursively to every member of an object.
Parameters:
Name Type Attributes Description
obj Object The object to apply the function to.
callback function The callback function to apply.
userdata any <optional>
Optional. User-defined data to pass to the callback function.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) pos(obj) → {any}

Alias of current.
Parameters:
Name Type Description
obj Object The object to get the current element from.
Source:
Returns:
The current element value.
Type
any

(static) prev(obj) → {boolean}

Rewind the internal object pointer.
Parameters:
Name Type Description
obj Object The object to rewind the pointer in.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) range(start, end, stepopt) → {Object}

Create an object containing a range of elements.
Parameters:
Name Type Attributes Default Description
start number The starting value of the range.
end number The ending value of the range.
step number <optional>
1 Optional. The step value for the range.
Source:
Returns:
The created object containing the range elements.
Type
Object

(static) reset(obj) → {any}

Set the internal pointer of an object to its first element.
Parameters:
Name Type Description
obj Object The object to set the internal pointer in.
Source:
Returns:
The value of the first element in the object.
Type
any

(static) rsort(obj) → {boolean}

Sort an object in descending order.
Parameters:
Name Type Description
obj Object The object to sort.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) shuffle(obj) → {boolean}

Shuffle the elements of an object.
Parameters:
Name Type Description
obj Object The object to shuffle.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) sizeof(obj, modeopt) → {number}

Alias of count.
Parameters:
Name Type Attributes Default Description
obj Object | Countable The object to count elements in.
mode number <optional>
COUNT_NORMAL Optional. The mode for counting.
Source:
Returns:
The number of elements in the object.
Type
number

(static) sort(obj) → {boolean}

Sort an object in ascending order.
Parameters:
Name Type Description
obj Object The object to sort.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) uasort(obj, compareFunction) → {boolean}

Sort an object with a user-defined comparison function and maintain index association.
Parameters:
Name Type Description
obj Object The object to sort.
compareFunction function The comparison function to use for sorting.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) uksort(obj, compareFunction) → {boolean}

Sort an object by keys using a user-defined comparison function.
Parameters:
Name Type Description
obj Object The object to sort.
compareFunction function The comparison function to use for sorting.
Source:
Returns:
True on success, false on failure.
Type
boolean

(static) usort(obj, compareFunction) → {boolean}

Sort an object by values using a user-defined comparison function.
Parameters:
Name Type Description
obj Object The object to sort.
compareFunction function The comparison function to use for sorting.
Source:
Returns:
True on success, false on failure.
Type
boolean