Module: array

Array utility functions
Source:

Methods

(static) createIncrementingArray(length) → {Array.<number>}

Creates an array of incrementing numbers starting from 1
Parameters:
Name Type Description
length number The length of the array
Source:
Returns:
Array of numbers from 1 to length
Type
Array.<number>
Example
```ts
createIncrementingArray(3)  // => [1, 2, 3]
```

(static) pipeFromArray(fns) → {function}

Composes an array of functions into a single function
Parameters:
Name Type Description
fns Array.<function()> Array of functions to compose
Source:
Returns:
The composed function
Type
function
Example
```ts
const addOne = x => x + 1;
const double = x => x * 2;
const composed = pipeFromArray([addOne, double]);
composed(3)  // => 8 ((3 + 1) * 2)
```

(static) shuffleArray(array) → {Array.<T>}

Randomly shuffles an array using Fisher-Yates algorithm
Parameters:
Name Type Description
array Array.<T> The array to shuffle
Source:
Returns:
The shuffled array
Type
Array.<T>
Example
```ts
const arr = [1, 2, 3, 4, 5];
shuffleArray([...arr]);  // => [3, 1, 5, 2, 4] (random order)
```

(static) toArray(val, defaultValueopt) → {Array.<T>}

Converts a value to an array
Parameters:
Name Type Attributes Description
val T | Array.<T> | null | undefined The value to convert
defaultValue T <optional>
Default value when input is null/undefined
Source:
Returns:
The resulting array
Type
Array.<T>
Example
```ts
toArray(1)  // => [1]
toArray([1, 2])  // => [1, 2]
toArray(null, 'default')  // => ['default']
```