Skip to main content

FluidReadonlyArray Interface

Like TypeScript's built-in ReadonlyArray type, but independent of TypeScript lib.

Sealed

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

ParameterDescription
T

Properties

PropertyModifiersTypeDescription
[Symbol.unscopables]readonly{ [K in keyof (readonly any[])]?: boolean; }See Symbol.unscopables
lengthreadonlynumberGets the length of the array.

Methods

MethodReturn TypeDescription
[Symbol.iterator]()FluidIterableIterator<T>Returns an iterator over the elements in this array.
at(index)T | undefinedReturns 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)booleanDetermines 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 | undefinedReturns the value of the first element in the array where predicate is true, and undefined otherwise.
find(predicate, thisArg)T | undefinedReturns the value of the first element in the array where predicate is true, and undefined otherwise.
findIndex(predicate, thisArg)numberReturns the index of the first element in the array where predicate is true, and -1 otherwise.
findLast(predicate, thisArg)S | undefinedReturns the value of the last element in the array where predicate is true, and undefined otherwise.
findLast(predicate, thisArg)T | undefinedReturns the value of the last element in the array where predicate is true, and undefined otherwise.
findLastIndex(predicate, thisArg)numberReturns 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)voidPerforms the specified action for each element in an array.
includes(searchElement, fromIndex)booleanDetermines whether an array includes a certain element, returning true or false as appropriate.
indexOf(searchElement, fromIndex)numberReturns the index of the first occurrence of a value in an array, or -1 if it is not present.
join(separator)stringAdds 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)numberReturns 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)TExecutes 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)UExecutes 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)TExecutes 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)UExecutes 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)booleanDetermines whether the specified callback function returns true for any element of an array.
toLocaleString()string
toString()stringReturns a string representation of an array.
values()FluidIterableIterator<T>Returns an iterable of values in the array.

Index Signatures

Index SignatureModifiersDescription
readonly [n: number]: TreadonlyReturns the item located at the specified index.

Property Details

[Symbol.unscopables]

See 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

ParameterTypeDescription
indexnumberThe 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

ParameterTypeDescription
itemsConcatArray<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

ParameterTypeDescription
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
ParameterConstraintDescription
ST

Parameters

ParameterModifiersTypeDescription
predicate(value: T, index: number, array: readonly T[]) => value is SA function that accepts up to three arguments.
thisArgoptionalanyAn 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

ParameterModifiersTypeDescription
predicate(value: T, index: number, array: readonly T[]) => unknownA function that accepts up to three arguments.
thisArgoptionalanyAn 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
ParameterConstraintDescription
ST

Parameters

ParameterModifiersTypeDescription
predicate(value: T, index: number, array: readonly T[]) => value is SA function that accepts up to three arguments.
thisArgoptionalanyAn 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

ParameterModifiersTypeDescription
predicate(value: T, index: number, array: readonly T[]) => unknownA function that accepts up to three arguments.
thisArgoptionalanyAn 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
ParameterConstraintDescription
ST

Parameters

ParameterModifiersTypeDescription
predicate(value: T, index: number, obj: readonly T[]) => value is Sfind calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true.
thisArgoptionalanyIf 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

ParameterModifiersTypeDescription
predicate(value: T, index: number, obj: readonly T[]) => unknownfind calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true.
thisArgoptionalanyIf 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

ParameterModifiersTypeDescription
predicate(value: T, index: number, obj: readonly T[]) => unknownfind calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true.
thisArgoptionalanyIf 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
ParameterConstraintDescription
ST

Parameters

ParameterModifiersTypeDescription
predicate(value: T, index: number, obj: readonly T[]) => value is SfindLast calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true.
thisArgoptionalanyIf 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

ParameterModifiersTypeDescription
predicate(value: T, index: number, obj: readonly T[]) => unknownfindLast calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true.
thisArgoptionalanyIf 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

ParameterModifiersTypeDescription
predicate(value: T, index: number, obj: readonly T[]) => unknownfindLastIndex calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true.
thisArgoptionalanyIf 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
ParameterConstraintDefaultDescription
A
Dnumber1

Parameters

ParameterModifiersTypeDescription
thisA
depthoptionalDThe 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
ParameterDefaultDescription
U
Thisundefined

Parameters

ParameterModifiersTypeDescription
callback(this: This, value: T, index: number, array: T[]) => U | readonly U[]A function that accepts up to three arguments.
thisArgoptionalThisAn 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

ParameterModifiersTypeDescription
callbackfn(value: T, index: number, array: readonly T[]) => voidA function that accepts up to three arguments.
thisArgoptionalanyAn 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

ParameterModifiersTypeDescription
searchElementTThe element to search for.
fromIndexoptionalnumberThe 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

ParameterModifiersTypeDescription
searchElementTThe value to locate in the array.
fromIndexoptionalnumberThe 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

ParameterModifiersTypeDescription
separatoroptionalstringA 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

ParameterModifiersTypeDescription
searchElementTThe value to locate in the array.
fromIndexoptionalnumberThe 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
ParameterDescription
U

Parameters

ParameterModifiersTypeDescription
callbackfn(value: T, index: number, array: readonly T[]) => UA function that accepts up to three arguments.
thisArgoptionalanyAn 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

ParameterTypeDescription
callbackfn(previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => TA 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
ParameterDescription
U

Parameters

ParameterTypeDescription
callbackfn(previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => UA function that accepts up to four arguments.
initialValueUUsed 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

ParameterTypeDescription
callbackfn(previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => TA 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
ParameterDescription
U

Parameters

ParameterTypeDescription
callbackfn(previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => UA function that accepts up to four arguments.
initialValueUUsed 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

ParameterModifiersTypeDescription
startoptionalnumberThe beginning of the specified portion of the array.
endoptionalnumberThe 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

ParameterModifiersTypeDescription
predicate(value: T, index: number, array: readonly T[]) => unknownA function that accepts up to three arguments.
thisArgoptionalanyAn 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;