Skip to content
Zach Vaughan edited this page May 16, 2025 · 4 revisions

Utility tools for working with Dynamic-Length Arrays.


ArrayifyType

type ArrayifyType <T> = any[];

Convert the specified type into an array, if it is not one already.

Template Parameters

  • T: The type being arrayified.

Returns

The arrayified type of T.


arrayify

arrayify <T> ( x: T ): ArrayifyType<T>;
// arrayify ( x: unknown ): any[];

Convert the specified value into an array, if it is not one already.

Template Parameters

  • T: The type of the value being arrayified.

Parameters

  • x: The value being arrayified.

Returns

The arrayified type of x.


toListString

function toListString (
    arr: unknown[],
    modifier: string | null = ' & ',
    separator: string | null = ', '
): string;

Convert the specified array to a string containing a list of the elements in the array.

This function is similar to the join() method on arrays but behaves slightly differently.

Parameters

  • arr: The array being converted into a list string.

  • modifier: The modifier string inserted between elements when arr contains two elements or between the last two elements when arr contains three or more elements.

    If an empty string or null is provided, no modifier string will be inserted into the returned string.

  • separator: The separator string inserted between elements when arr contains three or more elements.

    If an empty string or null is provided, no separator string will be inserted into the returned string.

Returns

A List string made up of the stringified elements of arr.

Clone this wiki locally