stubArray
util
This method returns a new empty array.
Installation
Import
import { stubArray } from '@tulx/utils';Source Code
Implementation
/**
* This method returns a new empty array.
*
* @returns Returns the new empty array.
*
* @example
* ```ts
* const arrays = times(2, stubArray);
* console.log(arrays); // [[], []]
* console.log(arrays[0] === arrays[1]); // false
* ```
*/
export function stubArray(): unknown[] {
return [];
}
Example
import { stubArray } from '@tulx/utils';
const arrays = times(2, stubArray);
console.log(arrays); // [[], []]
console.log(arrays[0] === arrays[1]); // falseRelated Functions
attempt
Attempts to invoke func, returning either the result or the caught error object.
bindAll
Binds methods of an object to the object itself, overwriting the existing method.
cond
Creates a function that iterates over pairs and invokes the corresponding function of the first predicate to return truthy.
conforms
Creates a function that invokes the predicate properties of source with the corresponding property values of a given object.
constant
Creates a function that returns value.
defaultTo
Checks value to determine whether a default value should be returned in its place.