FluidReadonlyArray Interface
Like TypeScript's built-in ReadonlyArray type, but independent of TypeScript lib.
This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.
Signature
/** @sealed */
export interface FluidReadonlyArray<T>
Type Parameters
| Parameter | Description |
|---|---|
| T |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| [Symbol.unscopables] | readonly | { [K in keyof (readonly any[])]?: boolean; } | See Symbol.unscopables |
| length | readonly | number | Gets the length of the array. |
Methods
| Method | Return Type | Description |
|---|---|---|
| [Symbol.iterator]() | FluidIterableIterator<T> | Returns an iterator over the elements in this array. |
| at(index) | T | undefined | Returns the item at the specified index, allowing for positive and negative integers. Negative integers count back from the last item in the array. |
| concat(items) | T[] | Combines two or more arrays. |
| concat(items) | T[] | Combines two or more arrays. |
| entries() | FluidIterableIterator<[number, T]> | Returns an iterable of key, value pairs for every entry in the array. |
| every(predicate, thisArg) | this is FluidReadonlyArray<S> | Determines whether all the members of an array satisfy the specified test. |
| every(predicate, thisArg) | boolean | Determines whether all the members of an array satisfy the specified test. |
| filter(predicate, thisArg) | S[] | Returns the elements of an array that meet the condition specified in a callback function. |
| filter(predicate, thisArg) | T[] | Returns the elements of an array that meet the condition specified in a callback function. |
| find(predicate, thisArg) | S | undefined | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
| find(predicate, thisArg) | T | undefined | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
| findIndex(predicate, thisArg) | number | Returns the index of the first element in the array where predicate is true, and -1 otherwise. |
| findLast(predicate, thisArg) | S | undefined | Returns the value of the last element in the array where predicate is true, and undefined otherwise. |
| findLast(predicate, thisArg) | T | undefined | Returns the value of the last element in the array where predicate is true, and undefined otherwise. |
| findLastIndex(predicate, thisArg) | number | Returns the index of the last element in the array where predicate is true, and -1 otherwise. |
| flat(this, depth) | FlatArray<A, D>[] | Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. |
| flatMap(callback, thisArg) | U[] | Calls a defined callback function on each element of an array. Then, flattens the result into a new array. |
| forEach(callbackfn, thisArg) | void | Performs the specified action for each element in an array. |
| includes(searchElement, fromIndex) | boolean | Determines whether an array includes a certain element, returning true or false as appropriate. |
| indexOf(searchElement, fromIndex) | number | Returns the index of the first occurrence of a value in an array, or -1 if it is not present. |
| join(separator) | string | Adds all the elements of an array into a string, separated by the specified separator string. |
| keys() | FluidIterableIterator<number> | Returns an iterable of keys in the array. |
| lastIndexOf(searchElement, fromIndex) | number | Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present. |
| map(callbackfn, thisArg) | U[] | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
| reduce(callbackfn) | T | Executes the provided callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value. |
| reduce(callbackfn, initialValue) | U | Executes the provided callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value. |
| reduceRight(callbackfn) | T | Executes the provided callback function on each element of the array, in descending order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value. |
| reduceRight(callbackfn, initialValue) | U | Executes the provided callback function on each element of the array, in descending order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value. |
| slice(start, end) | T[] | Returns a copy of a section of an array. |
| some(predicate, thisArg) | boolean | Determines whether the specified callback function returns true for any element of an array. |
| toLocaleString() | string | |
| toString() | string | Returns a string representation of an array. |
| values() | FluidIterableIterator<T> | Returns an iterable of values in the array. |
Index Signatures
| Index Signature | Modifiers | Description |
|---|---|---|
| readonly [n: number]: T | readonly | Returns the item located at the specified index. |
Property Details
[Symbol.unscopables]
Signature
readonly [Symbol.unscopables]: {
[K in keyof (readonly any[])]?: boolean;
};
Type: { [K in keyof (readonly any[])]?: boolean; }
length
Gets the length of the array.
Signature
readonly length: number;
Type: number
Method Details
[Symbol.iterator]
Returns an iterator over the elements in this array.
Signature
[Symbol.iterator](): FluidIterableIterator<T>;
Returns
Return type: FluidIterableIterator<T>
at
Returns the item at the specified index, allowing for positive and negative integers. Negative integers count back from the last item in the array.
Signature
at(index: number): T | undefined;
Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | The index of the element to retrieve. |
Returns
Return type: T | undefined
concat
Combines two or more arrays.
Signature
concat(...items: ConcatArray<T>[]): T[];
Remarks
This method returns a new array without modifying any existing arrays.
Parameters
| Parameter | Type | Description |
|---|---|---|
| items | ConcatArray<T>[] | Additional arrays and/or items to add to the end of the array. |
Returns
Return type: T[]
concat
Combines two or more arrays.
Signature
concat(...items: (T | ConcatArray<T>)[]): T[];
Remarks
This method returns a new array without modifying any existing arrays.
Parameters
| Parameter | Type | Description |
|---|---|---|
| items | (T | ConcatArray<T>)[] | Additional arrays and/or items to add to the end of the array. |
Returns
Return type: T[]
entries
Returns an iterable of key, value pairs for every entry in the array.
Signature
entries(): FluidIterableIterator<[number, T]>;
Returns
Return type: FluidIterableIterator<[number, T]>
every
Determines whether all the members of an array satisfy the specified test.
Signature
every<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): this is FluidReadonlyArray<S>;
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| S | T |
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, array: readonly T[]) => value is S | A function that accepts up to three arguments. | |
| thisArg | optional | any | An object to which the this keyword can refer in the predicate function. |
Returns
Return type: this is FluidReadonlyArray<S>
every
Determines whether all the members of an array satisfy the specified test.
Signature
every(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, array: readonly T[]) => unknown | A function that accepts up to three arguments. | |
| thisArg | optional | any | An object to which the this keyword can refer in the predicate function. |
Returns
Return type: boolean
filter
Returns the elements of an array that meet the condition specified in a callback function.
Signature
filter<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[];
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| S | T |
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, array: readonly T[]) => value is S | A function that accepts up to three arguments. | |
| thisArg | optional | any | An object to which the this keyword can refer in the predicate function. |
Returns
Return type: S[]
filter
Returns the elements of an array that meet the condition specified in a callback function.
Signature
filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[];
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, array: readonly T[]) => unknown | A function that accepts up to three arguments. | |
| thisArg | optional | any | An object to which the this keyword can refer in the predicate function. |
Returns
Return type: T[]
find
Returns the value of the first element in the array where predicate is true, and undefined otherwise.
Signature
find<S extends T>(predicate: (value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| S | T |
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, obj: readonly T[]) => value is S | find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. | |
| thisArg | optional | any | If provided, it will be used as the this value for each invocation of predicate. |
Returns
Return type: S | undefined
find
Returns the value of the first element in the array where predicate is true, and undefined otherwise.
Signature
find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, obj: readonly T[]) => unknown | find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. | |
| thisArg | optional | any | If provided, it will be used as the this value for each invocation of predicate. |
Returns
Return type: T | undefined
findIndex
Returns the index of the first element in the array where predicate is true, and -1 otherwise.
Signature
findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, obj: readonly T[]) => unknown | find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. | |
| thisArg | optional | any | If provided, it will be used as the this value for each invocation of predicate. |
Returns
Return type: number
findLast
Returns the value of the last element in the array where predicate is true, and undefined otherwise.
Signature
findLast<S extends T>(predicate: (value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| S | T |
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, obj: readonly T[]) => value is S | findLast calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. | |
| thisArg | optional | any | If provided, it will be used as the this value for each invocation of predicate. |
Returns
Return type: S | undefined
findLast
Returns the value of the last element in the array where predicate is true, and undefined otherwise.
Signature
findLast(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, obj: readonly T[]) => unknown | findLast calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. | |
| thisArg | optional | any | If provided, it will be used as the this value for each invocation of predicate. |
Returns
Return type: T | undefined
findLastIndex
Returns the index of the last element in the array where predicate is true, and -1 otherwise.
Signature
findLastIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, obj: readonly T[]) => unknown | findLastIndex calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. | |
| thisArg | optional | any | If provided, it will be used as the this value for each invocation of predicate. |
Returns
Return type: number
flat
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.
Signature
flat<A, D extends number = 1>(this: A, depth?: D): FlatArray<A, D>[];
Type Parameters
| Parameter | Constraint | Default | Description |
|---|---|---|---|
| A | |||
| D | number | 1 |
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| this | A | ||
| depth | optional | D | The maximum recursion depth. Defaults to 1. |
Returns
Return type: FlatArray<A, D>[]
flatMap
Calls a defined callback function on each element of an array. Then, flattens the result into a new array.
Signature
flatMap<U, This = undefined>(callback: (this: This, value: T, index: number, array: T[]) => U | readonly U[], thisArg?: This): U[];
Type Parameters
| Parameter | Default | Description |
|---|---|---|
| U | ||
| This | undefined |
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| callback | (this: This, value: T, index: number, array: T[]) => U | readonly U[] | A function that accepts up to three arguments. | |
| thisArg | optional | This | An object to which the this keyword can refer in the callback function. |
Returns
Return type: U[]
forEach
Performs the specified action for each element in an array.
Signature
forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| callbackfn | (value: T, index: number, array: readonly T[]) => void | A function that accepts up to three arguments. | |
| thisArg | optional | any | An object to which the this keyword can refer in the callbackfn function. |
includes
Determines whether an array includes a certain element, returning true or false as appropriate.
Signature
includes(searchElement: T, fromIndex?: number): boolean;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| searchElement | T | The element to search for. | |
| fromIndex | optional | number | The position in this array at which to begin searching for searchElement. |
Returns
Return type: boolean
indexOf
Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
Signature
indexOf(searchElement: T, fromIndex?: number): number;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| searchElement | T | The value to locate in the array. | |
| fromIndex | optional | number | The array index at which to begin the search. |
Returns
Return type: number
join
Adds all the elements of an array into a string, separated by the specified separator string.
Signature
join(separator?: string): string;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| separator | optional | string | A string used to separate one element of the array from the next in the resulting string. |
Returns
Return type: string
keys
Returns an iterable of keys in the array.
Signature
keys(): FluidIterableIterator<number>;
Returns
Return type: FluidIterableIterator<number>
lastIndexOf
Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.
Signature
lastIndexOf(searchElement: T, fromIndex?: number): number;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| searchElement | T | The value to locate in the array. | |
| fromIndex | optional | number | The array index at which to begin searching backward. |
Returns
Return type: number
map
Calls a defined callback function on each element of an array, and returns an array that contains the results.
Signature
map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
Type Parameters
| Parameter | Description |
|---|---|
| U |
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| callbackfn | (value: T, index: number, array: readonly T[]) => U | A function that accepts up to three arguments. | |
| thisArg | optional | any | An object to which the this keyword can refer in the callbackfn function. |
Returns
Return type: U[]
reduce
Executes the provided callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.
Signature
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
Parameters
| Parameter | Type | Description |
|---|---|---|
| callbackfn | (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T | A function that accepts up to four arguments. |
Returns
Return type: T
reduce
Executes the provided callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.
Signature
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
Type Parameters
| Parameter | Description |
|---|---|
| U |
Parameters
| Parameter | Type | Description |
|---|---|---|
| callbackfn | (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U | A function that accepts up to four arguments. |
| initialValue | U | Used as the initial value to start the accumulation. |
Returns
Return type: U
reduceRight
Executes the provided callback function on each element of the array, in descending order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.
Signature
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
Parameters
| Parameter | Type | Description |
|---|---|---|
| callbackfn | (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T | A function that accepts up to four arguments. |
Returns
Return type: T
reduceRight
Executes the provided callback function on each element of the array, in descending order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.
Signature
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
Type Parameters
| Parameter | Description |
|---|---|
| U |
Parameters
| Parameter | Type | Description |
|---|---|---|
| callbackfn | (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U | A function that accepts up to four arguments. |
| initialValue | U | Used as the initial value to start the accumulation. |
Returns
Return type: U
slice
Returns a copy of a section of an array.
Signature
slice(start?: number, end?: number): T[];
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| start | optional | number | The beginning of the specified portion of the array. |
| end | optional | number | The end of the specified portion of the array. |
Returns
Return type: T[]
some
Determines whether the specified callback function returns true for any element of an array.
Signature
some(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, array: readonly T[]) => unknown | A function that accepts up to three arguments. | |
| thisArg | optional | any | An object to which the this keyword can refer in the predicate function. |
Returns
Return type: boolean
toLocaleString
Signature
toLocaleString(): string;
Remarks
Returns a string representation of an array. The elements are converted to string using their toLocaleString methods.
Returns
Return type: string
toString
Returns a string representation of an array.
Signature
toString(): string;
Returns
Return type: string
values
Returns an iterable of values in the array.
Signature
values(): FluidIterableIterator<T>;
Returns
Return type: FluidIterableIterator<T>
Index Signature Details
readonly [n: number]: T
Returns the item located at the specified index.
Signature
readonly [n: number]: T;