<B>(middle: B): <S extends Iterable<any>>(
self: S
) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
<A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>
<A, B>(self: Iterable<A>, middle: B): Array<A | B>Places a separator element between every pair of elements.
When to use
Use to insert a separator between elements, for example when preparing data for display or concatenation.
Details
The return type preserves NonEmptyArray. Empty inputs produce an empty
result.
Example (Interspersing a separator)
import { Array } from "effect"
console.log(Array.intersperse([1, 2, 3], 0)) // [1, 0, 2, 0, 3]export const const intersperse: {
<B>(middle: B): <S extends Iterable<any>>(
self: S
) => ReadonlyArray.With<
S,
ReadonlyArray.Infer<S> | B
>
<A, B>(
self: NonEmptyReadonlyArray<A>,
middle: B
): NonEmptyArray<A | B>
<A, B>(self: Iterable<A>, middle: B): Array<
A | B
>
}
Places a separator element between every pair of elements.
When to use
Use to insert a separator between elements, for example when preparing data for display or concatenation.
Details
The return type preserves NonEmptyArray. Empty inputs produce an empty
result.
Example (Interspersing a separator)
import { Array } from "effect"
console.log(Array.intersperse([1, 2, 3], 0)) // [1, 0, 2, 0, 3]
intersperse: {
<function (type parameter) B in <B>(middle: B): <S extends Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>B>(
middle: Bmiddle: function (type parameter) B in <B>(middle: B): <S extends Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>B
): <function (type parameter) S in <S extends Iterable<any>>(self: S): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>S extends interface Iterable<T, TReturn = any, TNext = any>Iterable<any>>(self: S extends Iterable<any>self: function (type parameter) S in <S extends Iterable<any>>(self: S): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>S) => 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) S in <S extends Iterable<any>>(self: S): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>S, 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) S in <S extends Iterable<any>>(self: S): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>S> | function (type parameter) B in <B>(middle: B): <S extends Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>B>
<function (type parameter) A in <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>A, function (type parameter) B in <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>B>(self: NonEmptyReadonlyArray<A>(parameter) self: {
0: A;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<A>>): Array<A>; (...items: Array<A | ConcatArray<A>>): Array<A> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<A>;
indexOf: (searchElement: A, fromIndex?: number) => number;
lastIndexOf: (searchElement: A, fromIndex?: number) => number;
every: { (predicate: (value: A, index: number, array: ReadonlyArray<A>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: A, index: number, array: ReadonlyArray<A>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: A, index: number, array: ReadonlyArray<A>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: A, index: number, array: ReadonlyArray<A>) => void, thisArg?: any) => void;
map: (callbackfn: (value: A, index: number, array: ReadonlyArray<A>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: A, index: number, array: ReadonlyArray<A>) => value is S, thisArg?: any): Array<S>; (predicate: (value: A, index: number, array: ReadonlyArray<A>) => unknown, thisArg?: any): Array<A> };
reduce: { (callbackfn: (previousValue: A, currentValue: A, currentIndex: number, array: ReadonlyArray<A>) => A): A; (callbackfn: (previousValue: A, currentValue: A, currentIndex: number, array: ReadonlyArray<A>) => A, initialValue: A): A; (callbac…;
reduceRight: { (callbackfn: (previousValue: A, currentValue: A, currentIndex: number, array: ReadonlyArray<A>) => A): A; (callbackfn: (previousValue: A, currentValue: A, currentIndex: number, array: ReadonlyArray<A>) => A, initialValue: A): A; (callbac…;
find: { (predicate: (value: A, index: number, obj: ReadonlyArray<A>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A, index: number, obj: ReadonlyArray<A>) => unknown, thisArg?: any): A | undefined };
findIndex: (predicate: (value: A, index: number, obj: ReadonlyArray<A>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, A]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<A>;
includes: (searchElement: A, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: A, index: number, array: Array<A>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => A | undefined;
findLast: { (predicate: (value: A, index: number, array: ReadonlyArray<A>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A, index: number, array: ReadonlyArray<A>) => unknown, thisArg?: any): A | undefined };
findLastIndex: (predicate: (value: A, index: number, array: ReadonlyArray<A>) => unknown, thisArg?: any) => number;
toReversed: () => Array<A>;
toSorted: (compareFn?: ((a: A, b: A) => number) | undefined) => Array<A>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<A>): Array<A>; (start: number, deleteCount?: number): Array<A> };
with: (index: number, value: A) => Array<A>;
}
self: type NonEmptyReadonlyArray<A> = readonly [
A,
...A[]
]
A readonly array guaranteed to have at least one element.
When to use
Use when non-emptiness must be tracked at the type level while preventing mutation.
Many Array module functions accept or return this type.
Example (Typing a non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyReadonlyArray<number> = [1, 2, 3]
const head: number = nonEmpty[0] // guaranteed to exist
NonEmptyReadonlyArray<function (type parameter) A in <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>A>, middle: Bmiddle: function (type parameter) B in <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>B): type NonEmptyArray<A> = [A, ...A[]]A mutable array guaranteed to have at least one element.
When to use
Use when mutation is acceptable and non-emptiness must be tracked at the type
level.
Details
This is the mutable counterpart of
NonEmptyReadonlyArray
. Most Array
module functions return NonEmptyArray when the result is guaranteed
non-empty.
Example (Typing a mutable non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyArray<number> = [1, 2, 3]
nonEmpty.push(4)
NonEmptyArray<function (type parameter) A in <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>A | function (type parameter) B in <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>B>
<function (type parameter) A in <A, B>(self: Iterable<A>, middle: B): Array<A | B>A, function (type parameter) B in <A, B>(self: Iterable<A>, middle: B): Array<A | B>B>(self: Iterable<A>self: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <A, B>(self: Iterable<A>, middle: B): Array<A | B>A>, middle: Bmiddle: function (type parameter) B in <A, B>(self: Iterable<A>, middle: B): Array<A | B>B): interface Array<T>Array<function (type parameter) A in <A, B>(self: Iterable<A>, middle: B): Array<A | B>A | function (type parameter) B in <A, B>(self: Iterable<A>, middle: B): Array<A | B>B>
} = dual<(...args: Array<any>) => any, <A, B>(self: Iterable<A>, middle: B) => Array<A | B>>(arity: 2, body: <A, B>(self: Iterable<A>, middle: B) => Array<A | B>): ((...args: Array<any>) => any) & (<A, B>(self: Iterable<A>, middle: B) => Array<A | 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(2, <function (type parameter) A in <A, B>(self: Iterable<A>, middle: B): Array<A | B>A, function (type parameter) B in <A, B>(self: Iterable<A>, middle: B): Array<A | B>B>(self: Iterable<A>self: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <A, B>(self: Iterable<A>, middle: B): Array<A | B>A>, middle: Bmiddle: function (type parameter) B in <A, B>(self: Iterable<A>, middle: B): Array<A | B>B): interface Array<T>Array<function (type parameter) A in <A, B>(self: Iterable<A>, middle: B): Array<A | B>A | function (type parameter) B in <A, B>(self: Iterable<A>, middle: B): Array<A | B>B> => {
const const input: A[]input = const fromIterable: <A>(
collection: Iterable<A>
) => A[]
Converts an Iterable to an Array.
When to use
Use to convert any Iterable (Set, Generator, etc.) into an array.
Details
If the input is already an array, this returns it by reference without
copying. Otherwise, it creates a new array from the iterable. Use copy if
you need a fresh array even when the input is already an array.
Example (Converting a Set to an array)
import { Array } from "effect"
const result = Array.fromIterable(new Set([1, 2, 3]))
console.log(result) // [1, 2, 3]
fromIterable(self: Iterable<A>self)
if (const isReadonlyArrayNonEmpty: <A>(
self: ReadonlyArray<A>
) => self is NonEmptyReadonlyArray<A>
Checks whether a ReadonlyArray is non-empty, narrowing the type to
NonEmptyReadonlyArray.
When to use
Use when you need to prove a readonly array has at least one element without
requiring mutable array methods afterward.
Example (Checking for a non-empty readonly array)
import { Array } from "effect"
console.log(Array.isReadonlyArrayNonEmpty([])) // false
console.log(Array.isReadonlyArrayNonEmpty([1, 2, 3])) // true
isReadonlyArrayNonEmpty(const input: A[]input)) {
const const out: NonEmptyArray<A | B>const out: {
0: A | B;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => A | B | undefined;
push: (...items: Array<A | B>) => number;
concat: { (...items: Array<ConcatArray<A | B>>): Array<A | B>; (...items: Array<A | B | ConcatArray<A | B>>): Array<A | B> };
join: (separator?: string) => string;
reverse: () => Array<A | B>;
shift: () => A | B | undefined;
slice: (start?: number, end?: number) => Array<A | B>;
sort: (compareFn?: ((a: A | B, b: A | B) => number) | undefined) => [A | B, ...(A | B)[]];
splice: { (start: number, deleteCount?: number): Array<A | B>; (start: number, deleteCount: number, ...items: Array<A | B>): Array<A | B> };
unshift: (...items: Array<A | B>) => number;
indexOf: (searchElement: A | B, fromIndex?: number) => number;
lastIndexOf: (searchElement: A | B, fromIndex?: number) => number;
every: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): this is S[]; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: A | B, index: number, array: Array<A | B>) => void, thisArg?: any) => void;
map: (callbackfn: (value: A | B, index: number, array: Array<A | B>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): Array<S>; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): Array<A | B> };
reduce: { (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B): A | B; (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B, initialVa…;
reduceRight: { (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B): A | B; (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B, initialVa…;
find: { (predicate: (value: A | B, index: number, obj: Array<A | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | B, index: number, obj: Array<A | B>) => unknown, thisArg?: any): A | B | undefined };
findIndex: (predicate: (value: A | B, index: number, obj: Array<A | B>) => unknown, thisArg?: any) => number;
fill: (value: A | B, start?: number, end?: number) => [A | B, ...(A | B)[]];
copyWithin: (target: number, start: number, end?: number) => [A | B, ...(A | B)[]];
entries: () => ArrayIterator<[number, A | B]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<A | B>;
includes: (searchElement: A | B, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: A | B, index: number, array: Array<A | B>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => A | B | undefined;
findLast: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): A | B | undefined };
findLastIndex: (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any) => number;
toReversed: () => Array<A | B>;
toSorted: (compareFn?: ((a: A | B, b: A | B) => number) | undefined) => Array<A | B>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<A | B>): Array<A | B>; (start: number, deleteCount?: number): Array<A | B> };
with: (index: number, value: A | B) => Array<A | B>;
}
out: type NonEmptyArray<A> = [A, ...A[]]A mutable array guaranteed to have at least one element.
When to use
Use when mutation is acceptable and non-emptiness must be tracked at the type
level.
Details
This is the mutable counterpart of
NonEmptyReadonlyArray
. Most Array
module functions return NonEmptyArray when the result is guaranteed
non-empty.
Example (Typing a mutable non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyArray<number> = [1, 2, 3]
nonEmpty.push(4)
NonEmptyArray<function (type parameter) A in <A, B>(self: Iterable<A>, middle: B): Array<A | B>A | function (type parameter) B in <A, B>(self: Iterable<A>, middle: B): Array<A | B>B> = [const headNonEmpty: <A>(
self: NonEmptyReadonlyArray<A>
) => A
Returns the first element of a NonEmptyReadonlyArray directly (no Option
wrapper).
When to use
Use to get the first element without Option wrapping when the array is known
to be non-empty.
Example (Getting the head of a non-empty array)
import { Array } from "effect"
console.log(Array.headNonEmpty([1, 2, 3, 4])) // 1
headNonEmpty(const input: A[] & readonly [A, ...A[]]input)]
const const tail: A[]tail = const tailNonEmpty: <A>(
self: NonEmptyReadonlyArray<A>
) => Array<A>
Returns all elements except the first of a NonEmptyReadonlyArray.
When to use
Use to get all elements after the first when the array is known to be non-empty.
Example (Getting the tail of a non-empty array)
import { Array } from "effect"
console.log(Array.tailNonEmpty([1, 2, 3, 4])) // [2, 3, 4]
tailNonEmpty(const input: A[] & readonly [A, ...A[]]input)
for (let let i: numberi = 0; let i: numberi < const tail: A[]tail.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length; let i: numberi++) {
if (let i: numberi < const tail: A[]tail.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length) {
const out: NonEmptyArray<A | B>const out: {
0: A | B;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => A | B | undefined;
push: (...items: Array<A | B>) => number;
concat: { (...items: Array<ConcatArray<A | B>>): Array<A | B>; (...items: Array<A | B | ConcatArray<A | B>>): Array<A | B> };
join: (separator?: string) => string;
reverse: () => Array<A | B>;
shift: () => A | B | undefined;
slice: (start?: number, end?: number) => Array<A | B>;
sort: (compareFn?: ((a: A | B, b: A | B) => number) | undefined) => [A | B, ...(A | B)[]];
splice: { (start: number, deleteCount?: number): Array<A | B>; (start: number, deleteCount: number, ...items: Array<A | B>): Array<A | B> };
unshift: (...items: Array<A | B>) => number;
indexOf: (searchElement: A | B, fromIndex?: number) => number;
lastIndexOf: (searchElement: A | B, fromIndex?: number) => number;
every: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): this is S[]; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: A | B, index: number, array: Array<A | B>) => void, thisArg?: any) => void;
map: (callbackfn: (value: A | B, index: number, array: Array<A | B>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): Array<S>; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): Array<A | B> };
reduce: { (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B): A | B; (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B, initialVa…;
reduceRight: { (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B): A | B; (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B, initialVa…;
find: { (predicate: (value: A | B, index: number, obj: Array<A | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | B, index: number, obj: Array<A | B>) => unknown, thisArg?: any): A | B | undefined };
findIndex: (predicate: (value: A | B, index: number, obj: Array<A | B>) => unknown, thisArg?: any) => number;
fill: (value: A | B, start?: number, end?: number) => [A | B, ...(A | B)[]];
copyWithin: (target: number, start: number, end?: number) => [A | B, ...(A | B)[]];
entries: () => ArrayIterator<[number, A | B]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<A | B>;
includes: (searchElement: A | B, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: A | B, index: number, array: Array<A | B>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => A | B | undefined;
findLast: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): A | B | undefined };
findLastIndex: (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any) => number;
toReversed: () => Array<A | B>;
toSorted: (compareFn?: ((a: A | B, b: A | B) => number) | undefined) => Array<A | B>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<A | B>): Array<A | B>; (start: number, deleteCount?: number): Array<A | B> };
with: (index: number, value: A | B) => Array<A | B>;
}
out.Array<A | B>.push(...items: (A | B)[]): numberAppends new elements to the end of an array, and returns the new length of the array.
push(middle: Bmiddle)
}
const out: NonEmptyArray<A | B>const out: {
0: A | B;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => A | B | undefined;
push: (...items: Array<A | B>) => number;
concat: { (...items: Array<ConcatArray<A | B>>): Array<A | B>; (...items: Array<A | B | ConcatArray<A | B>>): Array<A | B> };
join: (separator?: string) => string;
reverse: () => Array<A | B>;
shift: () => A | B | undefined;
slice: (start?: number, end?: number) => Array<A | B>;
sort: (compareFn?: ((a: A | B, b: A | B) => number) | undefined) => [A | B, ...(A | B)[]];
splice: { (start: number, deleteCount?: number): Array<A | B>; (start: number, deleteCount: number, ...items: Array<A | B>): Array<A | B> };
unshift: (...items: Array<A | B>) => number;
indexOf: (searchElement: A | B, fromIndex?: number) => number;
lastIndexOf: (searchElement: A | B, fromIndex?: number) => number;
every: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): this is S[]; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: A | B, index: number, array: Array<A | B>) => void, thisArg?: any) => void;
map: (callbackfn: (value: A | B, index: number, array: Array<A | B>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): Array<S>; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): Array<A | B> };
reduce: { (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B): A | B; (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B, initialVa…;
reduceRight: { (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B): A | B; (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B, initialVa…;
find: { (predicate: (value: A | B, index: number, obj: Array<A | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | B, index: number, obj: Array<A | B>) => unknown, thisArg?: any): A | B | undefined };
findIndex: (predicate: (value: A | B, index: number, obj: Array<A | B>) => unknown, thisArg?: any) => number;
fill: (value: A | B, start?: number, end?: number) => [A | B, ...(A | B)[]];
copyWithin: (target: number, start: number, end?: number) => [A | B, ...(A | B)[]];
entries: () => ArrayIterator<[number, A | B]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<A | B>;
includes: (searchElement: A | B, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: A | B, index: number, array: Array<A | B>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => A | B | undefined;
findLast: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): A | B | undefined };
findLastIndex: (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any) => number;
toReversed: () => Array<A | B>;
toSorted: (compareFn?: ((a: A | B, b: A | B) => number) | undefined) => Array<A | B>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<A | B>): Array<A | B>; (start: number, deleteCount?: number): Array<A | B> };
with: (index: number, value: A | B) => Array<A | B>;
}
out.Array<A | B>.push(...items: (A | B)[]): numberAppends new elements to the end of an array, and returns the new length of the array.
push(const tail: A[]tail[let i: numberi])
}
return const out: NonEmptyArray<A | B>const out: {
0: A | B;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => A | B | undefined;
push: (...items: Array<A | B>) => number;
concat: { (...items: Array<ConcatArray<A | B>>): Array<A | B>; (...items: Array<A | B | ConcatArray<A | B>>): Array<A | B> };
join: (separator?: string) => string;
reverse: () => Array<A | B>;
shift: () => A | B | undefined;
slice: (start?: number, end?: number) => Array<A | B>;
sort: (compareFn?: ((a: A | B, b: A | B) => number) | undefined) => [A | B, ...(A | B)[]];
splice: { (start: number, deleteCount?: number): Array<A | B>; (start: number, deleteCount: number, ...items: Array<A | B>): Array<A | B> };
unshift: (...items: Array<A | B>) => number;
indexOf: (searchElement: A | B, fromIndex?: number) => number;
lastIndexOf: (searchElement: A | B, fromIndex?: number) => number;
every: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): this is S[]; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: A | B, index: number, array: Array<A | B>) => void, thisArg?: any) => void;
map: (callbackfn: (value: A | B, index: number, array: Array<A | B>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): Array<S>; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): Array<A | B> };
reduce: { (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B): A | B; (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B, initialVa…;
reduceRight: { (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B): A | B; (callbackfn: (previousValue: A | B, currentValue: A | B, currentIndex: number, array: Array<A | B>) => A | B, initialVa…;
find: { (predicate: (value: A | B, index: number, obj: Array<A | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | B, index: number, obj: Array<A | B>) => unknown, thisArg?: any): A | B | undefined };
findIndex: (predicate: (value: A | B, index: number, obj: Array<A | B>) => unknown, thisArg?: any) => number;
fill: (value: A | B, start?: number, end?: number) => [A | B, ...(A | B)[]];
copyWithin: (target: number, start: number, end?: number) => [A | B, ...(A | B)[]];
entries: () => ArrayIterator<[number, A | B]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<A | B>;
includes: (searchElement: A | B, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: A | B, index: number, array: Array<A | B>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => A | B | undefined;
findLast: { (predicate: (value: A | B, index: number, array: Array<A | B>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any): A | B | undefined };
findLastIndex: (predicate: (value: A | B, index: number, array: Array<A | B>) => unknown, thisArg?: any) => number;
toReversed: () => Array<A | B>;
toSorted: (compareFn?: ((a: A | B, b: A | B) => number) | undefined) => Array<A | B>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<A | B>): Array<A | B>; (start: number, deleteCount?: number): Array<A | B> };
with: (index: number, value: A | B) => Array<A | B>;
}
out
}
return []
})