<S, A, B, I extends Iterable<A> = Iterable<A>>(
s: S,
f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]
): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]
<S, A, B, I extends Iterable<A> = Iterable<A>>(
self: I,
s: S,
f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]
): [state: S, mappedArray: ReadonlyArray.With<I, B>]Maps over an array while threading an accumulator through each step, returning both the final state and the mapped array.
When to use
Use when you need to map while threading state through each element and keep the final state.
Details
Combines map and reduce in a single pass. The callback receives the
current state, element, and index, and returns [nextState, mappedValue].
The result is [finalState, mappedArray]. This can be used in both
data-first and data-last style.
Example (Running sum alongside mapped values)
import { Array } from "effect"
const result = Array.mapAccum([1, 2, 3], 0, (acc, n) => [acc + n, acc + n])
console.log(result) // [6, [1, 3, 6]]export const const mapAccum: {
<S, A, B, I extends Iterable<A> = Iterable<A>>(
s: S,
f: (
s: S,
a: ReadonlyArray.Infer<I>,
i: number
) => readonly [S, B]
): (
self: I
) => [
state: S,
mappedArray: ReadonlyArray.With<I, B>
]
<S, A, B, I extends Iterable<A> = Iterable<A>>(
self: I,
s: S,
f: (
s: S,
a: ReadonlyArray.Infer<I>,
i: number
) => readonly [S, B]
): [
state: S,
mappedArray: ReadonlyArray.With<I, B>
]
}
Maps over an array while threading an accumulator through each step, returning both the final state and the mapped array.
When to use
Use when you need to map while threading state through each element and keep
the final state.
Details
Combines map and reduce in a single pass. The callback receives the
current state, element, and index, and returns [nextState, mappedValue].
The result is [finalState, mappedArray]. This can be used in both
data-first and data-last style.
Example (Running sum alongside mapped values)
import { Array } from "effect"
const result = Array.mapAccum([1, 2, 3], 0, (acc, n) => [acc + n, acc + n])
console.log(result) // [6, [1, 3, 6]]
mapAccum: {
<function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]S, function (type parameter) A in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]A, function (type parameter) B in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]B, function (type parameter) I in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]I extends interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]A> = interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]A>>(
s: Ss: function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]S,
f: (
s: S,
a: ReadonlyArray.Infer<I>,
i: number
) => readonly [S, B]
f: (s: Ss: function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]S, a: ReadonlyArray.Infer<I>a: ReadonlyArray.type ReadonlyArray.Infer<S extends Iterable<any>> = S extends readonly (infer A)[] ? A : S extends Iterable<infer A> ? A : neverInfers the element type of an iterable.
Example (Inferring an element type)
import type { Array } from "effect"
type StringArrayType = Array.ReadonlyArray.Infer<ReadonlyArray<string>>
// StringArrayType is string
Infer<function (type parameter) I in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]I>, i: numberi: number) => readonly [function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]S, function (type parameter) B in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]B]
): (self: I extends Iterable<A> = Iterable<A>self: function (type parameter) I in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]I) => [Sstate: function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]S, ReadonlyArray.With<I, B>mappedArray: ReadonlyArray.type ReadonlyArray.With<S extends Iterable<any>, A> = S extends readonly [any, ...any[]] ? [A, ...A[]] : A[]Constructs an array type preserving non-emptiness.
Example (Preserving non-emptiness)
import type { Array } from "effect"
type Result = Array.ReadonlyArray.With<readonly [number], string>
// Result is NonEmptyArray<string>
With<function (type parameter) I in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]I, function (type parameter) B in <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>]B>]
<function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]S, function (type parameter) A in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]A, function (type parameter) B in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]B, function (type parameter) I in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]I extends interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]A> = interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]A>>(
self: I extends Iterable<A> = Iterable<A>self: function (type parameter) I in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]I,
s: Ss: function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]S,
f: (
s: S,
a: ReadonlyArray.Infer<I>,
i: number
) => readonly [S, B]
f: (s: Ss: function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]S, a: ReadonlyArray.Infer<I>a: ReadonlyArray.type ReadonlyArray.Infer<S extends Iterable<any>> = S extends readonly (infer A)[] ? A : S extends Iterable<infer A> ? A : neverInfers the element type of an iterable.
Example (Inferring an element type)
import type { Array } from "effect"
type StringArrayType = Array.ReadonlyArray.Infer<ReadonlyArray<string>>
// StringArrayType is string
Infer<function (type parameter) I in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]I>, i: numberi: number) => readonly [function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]S, function (type parameter) B in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]B]
): [Sstate: function (type parameter) S in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]S, ReadonlyArray.With<I, B>mappedArray: ReadonlyArray.type ReadonlyArray.With<S extends Iterable<any>, A> = S extends readonly [any, ...any[]] ? [A, ...A[]] : A[]Constructs an array type preserving non-emptiness.
Example (Preserving non-emptiness)
import type { Array } from "effect"
type Result = Array.ReadonlyArray.With<readonly [number], string>
// Result is NonEmptyArray<string>
With<function (type parameter) I in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]I, function (type parameter) B in <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>]B>]
} = dual<(...args: Array<any>) => any, <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]) => [state: S, mappedArray: Array<B>]>(arity: 3, body: <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]) => [state: S, mappedArray: Array<B>]): ((...args: Array<any>) => any) & (<S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]) => [state: S, mappedArray: Array<B>]) (+1 overload)Creates a function that can be called in data-first style or data-last
(pipe-friendly) style.
When to use
Use to expose one implementation through both direct and pipe-friendly
call styles.
Details
Pass either the arity of the uncurried function or a predicate that decides
whether the current call is data-first. Arity is the common case. Use a
predicate when optional arguments make arity ambiguous.
Example (Selecting data-first or data-last style by arity)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(2, (self, that) => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Defining overloads with call signatures)
import { Function, pipe } from "effect"
const sum: {
(that: number): (self: number) => number
(self: number, that: number): number
} = Function.dual(2, (self: number, that: number): number => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Selecting data-first or data-last style with a predicate)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(
(args) => args.length === 2,
(self, that) => self + that
)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
dual(
3,
<function (type parameter) S in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]S, function (type parameter) A in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]A, function (type parameter) B in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]B>(self: Iterable<A>self: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]A>, s: Ss: function (type parameter) S in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]S, f: (s: S, a: A, i: number) => [S, B]f: (s: Ss: function (type parameter) S in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]S, a: Aa: function (type parameter) A in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]A, i: numberi: number) => [function (type parameter) S in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]S, function (type parameter) B in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]B]): [Sstate: function (type parameter) S in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]S, B[]mappedArray: interface Array<T>Array<function (type parameter) B in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]B>] => {
let let i: numberi = 0
let let s1: Ss1 = s: Ss
const const out: B[]out: interface Array<T>Array<function (type parameter) B in <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => [S, B]): [state: S, mappedArray: Array<B>]B> = []
for (const const a: Aa of self: Iterable<A>self) {
const const r: [S, B]const r: {
0: S;
1: B;
length: 2;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => S | B | undefined;
push: (...items: Array<S | B>) => number;
concat: { (...items: Array<ConcatArray<S | B>>): Array<S | B>; (...items: Array<S | B | ConcatArray<S | B>>): Array<S | B> };
join: (separator?: string) => string;
reverse: () => Array<S | B>;
shift: () => S | B | undefined;
slice: (start?: number, end?: number) => Array<S | B>;
sort: (compareFn?: ((a: S | B, b: S | B) => number) | undefined) => [S, B];
splice: { (start: number, deleteCount?: number): Array<S | B>; (start: number, deleteCount: number, ...items: Array<S | B>): Array<S | B> };
unshift: (...items: Array<S | B>) => number;
indexOf: (searchElement: S | B, fromIndex?: number) => number;
lastIndexOf: (searchElement: S | B, fromIndex?: number) => number;
every: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): this is S[]; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: S | B, index: number, array: Array<S | B>) => void, thisArg?: any) => void;
map: (callbackfn: (value: S | B, index: number, array: Array<S | B>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): Array<S>; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): Array<S | B> };
reduce: { (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B): S | B; (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B, initialVa…;
reduceRight: { (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B): S | B; (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B, initialVa…;
find: { (predicate: (value: S | B, index: number, obj: Array<S | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: S | B, index: number, obj: Array<S | B>) => unknown, thisArg?: any): S | B | undefined };
findIndex: (predicate: (value: S | B, index: number, obj: Array<S | B>) => unknown, thisArg?: any) => number;
fill: (value: S | B, start?: number, end?: number) => [S, B];
copyWithin: (target: number, start: number, end?: number) => [S, B];
entries: () => ArrayIterator<[number, S | B]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<S | B>;
includes: (searchElement: S | B, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: S | B, index: number, array: Array<S | B>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => S | B | undefined;
findLast: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): S | B | undefined };
findLastIndex: (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any) => number;
toReversed: () => Array<S | B>;
toSorted: (compareFn?: ((a: S | B, b: S | B) => number) | undefined) => Array<S | B>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<S | B>): Array<S | B>; (start: number, deleteCount?: number): Array<S | B> };
with: (index: number, value: S | B) => Array<S | B>;
}
r = f: (s: S, a: A, i: number) => [S, B]f(let s1: Ss1, const a: Aa, let i: numberi)
let s1: Ss1 = const r: [S, B]const r: {
0: S;
1: B;
length: 2;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => S | B | undefined;
push: (...items: Array<S | B>) => number;
concat: { (...items: Array<ConcatArray<S | B>>): Array<S | B>; (...items: Array<S | B | ConcatArray<S | B>>): Array<S | B> };
join: (separator?: string) => string;
reverse: () => Array<S | B>;
shift: () => S | B | undefined;
slice: (start?: number, end?: number) => Array<S | B>;
sort: (compareFn?: ((a: S | B, b: S | B) => number) | undefined) => [S, B];
splice: { (start: number, deleteCount?: number): Array<S | B>; (start: number, deleteCount: number, ...items: Array<S | B>): Array<S | B> };
unshift: (...items: Array<S | B>) => number;
indexOf: (searchElement: S | B, fromIndex?: number) => number;
lastIndexOf: (searchElement: S | B, fromIndex?: number) => number;
every: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): this is S[]; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: S | B, index: number, array: Array<S | B>) => void, thisArg?: any) => void;
map: (callbackfn: (value: S | B, index: number, array: Array<S | B>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): Array<S>; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): Array<S | B> };
reduce: { (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B): S | B; (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B, initialVa…;
reduceRight: { (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B): S | B; (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B, initialVa…;
find: { (predicate: (value: S | B, index: number, obj: Array<S | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: S | B, index: number, obj: Array<S | B>) => unknown, thisArg?: any): S | B | undefined };
findIndex: (predicate: (value: S | B, index: number, obj: Array<S | B>) => unknown, thisArg?: any) => number;
fill: (value: S | B, start?: number, end?: number) => [S, B];
copyWithin: (target: number, start: number, end?: number) => [S, B];
entries: () => ArrayIterator<[number, S | B]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<S | B>;
includes: (searchElement: S | B, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: S | B, index: number, array: Array<S | B>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => S | B | undefined;
findLast: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): S | B | undefined };
findLastIndex: (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any) => number;
toReversed: () => Array<S | B>;
toSorted: (compareFn?: ((a: S | B, b: S | B) => number) | undefined) => Array<S | B>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<S | B>): Array<S | B>; (start: number, deleteCount?: number): Array<S | B> };
with: (index: number, value: S | B) => Array<S | B>;
}
r[0]
const out: B[]out.Array<B>.push(...items: B[]): numberAppends new elements to the end of an array, and returns the new length of the array.
push(const r: [S, B]const r: {
0: S;
1: B;
length: 2;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => S | B | undefined;
push: (...items: Array<S | B>) => number;
concat: { (...items: Array<ConcatArray<S | B>>): Array<S | B>; (...items: Array<S | B | ConcatArray<S | B>>): Array<S | B> };
join: (separator?: string) => string;
reverse: () => Array<S | B>;
shift: () => S | B | undefined;
slice: (start?: number, end?: number) => Array<S | B>;
sort: (compareFn?: ((a: S | B, b: S | B) => number) | undefined) => [S, B];
splice: { (start: number, deleteCount?: number): Array<S | B>; (start: number, deleteCount: number, ...items: Array<S | B>): Array<S | B> };
unshift: (...items: Array<S | B>) => number;
indexOf: (searchElement: S | B, fromIndex?: number) => number;
lastIndexOf: (searchElement: S | B, fromIndex?: number) => number;
every: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): this is S[]; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: S | B, index: number, array: Array<S | B>) => void, thisArg?: any) => void;
map: (callbackfn: (value: S | B, index: number, array: Array<S | B>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): Array<S>; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): Array<S | B> };
reduce: { (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B): S | B; (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B, initialVa…;
reduceRight: { (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B): S | B; (callbackfn: (previousValue: S | B, currentValue: S | B, currentIndex: number, array: Array<S | B>) => S | B, initialVa…;
find: { (predicate: (value: S | B, index: number, obj: Array<S | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: S | B, index: number, obj: Array<S | B>) => unknown, thisArg?: any): S | B | undefined };
findIndex: (predicate: (value: S | B, index: number, obj: Array<S | B>) => unknown, thisArg?: any) => number;
fill: (value: S | B, start?: number, end?: number) => [S, B];
copyWithin: (target: number, start: number, end?: number) => [S, B];
entries: () => ArrayIterator<[number, S | B]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<S | B>;
includes: (searchElement: S | B, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: S | B, index: number, array: Array<S | B>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => S | B | undefined;
findLast: { (predicate: (value: S | B, index: number, array: Array<S | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any): S | B | undefined };
findLastIndex: (predicate: (value: S | B, index: number, array: Array<S | B>) => unknown, thisArg?: any) => number;
toReversed: () => Array<S | B>;
toSorted: (compareFn?: ((a: S | B, b: S | B) => number) | undefined) => Array<S | B>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<S | B>): Array<S | B>; (start: number, deleteCount?: number): Array<S | B> };
with: (index: number, value: S | B) => Array<S | B>;
}
r[1])
let i: numberi++
}
return [let s1: Ss1, const out: B[]out]
}
)