/** * This module provides utility functions for working with arrays in TypeScript. * * @since 1.0.0 */ import type { Either } from "@effect/data/Either"; import * as Equivalence from "@effect/data/Equivalence"; import type { LazyArg } from "@effect/data/Function"; import type { TypeLambda } from "@effect/data/HKT"; import type { Option } from "@effect/data/Option"; import * as Order from "@effect/data/Order"; import type { Predicate, Refinement } from "@effect/data/Predicate"; /** * @category type lambdas * @since 1.0.0 */ export interface ReadonlyArrayTypeLambda extends TypeLambda { readonly type: ReadonlyArray; } /** * @category models * @since 1.0.0 */ export type NonEmptyReadonlyArray = readonly [A, ...Array]; /** * @category models * @since 1.0.0 */ export type NonEmptyArray = [A, ...Array]; /** * Builds a `NonEmptyArray` from an non-empty collection of elements. * * @category constructors * @since 1.0.0 */ export declare const make: (...elements: Elements) => [Elements[number], ...Elements[number][]]; /** * Return a `NonEmptyArray` of length `n` with element `i` initialized with `f(i)`. * * **Note**. `n` is normalized to an integer >= 1. * * @example * import { makeBy } from '@effect/data/ReadonlyArray' * * assert.deepStrictEqual(makeBy(5, n => n * 2), [0, 2, 4, 6, 8]) * * @category constructors * @since 1.0.0 */ export declare const makeBy: (n: number, f: (i: number) => A) => [A, ...A[]]; /** * Return a `NonEmptyArray` containing a range of integers, including both endpoints. * * @example * import { range } from '@effect/data/ReadonlyArray' * * assert.deepStrictEqual(range(1, 3), [1, 2, 3]) * * @category constructors * @since 1.0.0 */ export declare const range: (start: number, end: number) => [number, ...number[]]; /** * Return a `NonEmptyArray` containing a value repeated the specified number of times. * * **Note**. `n` is normalized to an integer >= 1. * * @example * import { replicate } from '@effect/data/ReadonlyArray' * * assert.deepStrictEqual(replicate("a", 3), ["a", "a", "a"]) * * @category constructors * @since 1.0.0 */ export declare const replicate: { (n: number): (a: A) => NonEmptyArray; (a: A, n: number): NonEmptyArray; }; /** * @category conversions * @since 1.0.0 */ export declare const fromIterable: (collection: Iterable) => A[]; /** * Takes a record and returns an array of tuples containing its keys and values. * * @param self - The record to transform. * * @example * import { fromRecord } from "@effect/data/ReadonlyArray" * * const x = { a: 1, b: 2, c: 3 } * assert.deepStrictEqual(fromRecord(x), [["a", 1], ["b", 2], ["c", 3]]) * * @category conversions * @since 1.0.0 */ export declare const fromRecord: (self: Readonly>) => Array<[K, A]>; /** * @category conversions * @since 1.0.0 */ export declare const fromOption: (self: Option) => Array; /** * @category pattern matching * @since 1.0.0 */ export declare const match: { (options: { readonly onEmpty: LazyArg; readonly onNonEmpty: (self: NonEmptyReadonlyArray) => C; }): (self: ReadonlyArray) => B | C; (self: ReadonlyArray, options: { readonly onEmpty: LazyArg; readonly onNonEmpty: (self: NonEmptyReadonlyArray) => C; }): B | C; }; /** * @category pattern matching * @since 1.0.0 */ export declare const matchLeft: { (options: { readonly onEmpty: LazyArg; readonly onNonEmpty: (head: A, tail: Array) => C; }): (self: ReadonlyArray) => B | C; (self: ReadonlyArray, options: { readonly onEmpty: LazyArg; readonly onNonEmpty: (head: A, tail: Array) => C; }): B | C; }; /** * @category pattern matching * @since 1.0.0 */ export declare const matchRight: { (options: { readonly onEmpty: LazyArg; readonly onNonEmpty: (init: Array, last: A) => C; }): (self: ReadonlyArray) => B | C; (self: ReadonlyArray, options: { readonly onEmpty: LazyArg; readonly onNonEmpty: (init: Array, last: A) => C; }): B | C; }; /** * Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`. * * @category concatenating * @since 1.0.0 */ export declare const prepend: { (head: B): (self: Iterable) => NonEmptyArray; (self: Iterable, head: B): NonEmptyArray; }; /** * @category concatenating * @since 1.0.0 */ export declare const prependAll: { (that: Iterable): (self: Iterable) => Array; (self: Iterable, that: Iterable): Array; }; /** * @category concatenating * @since 1.0.0 */ export declare const prependAllNonEmpty: { (that: NonEmptyReadonlyArray): (self: Iterable) => NonEmptyArray; (that: Iterable): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: Iterable, that: NonEmptyReadonlyArray): NonEmptyArray; (self: NonEmptyReadonlyArray, that: Iterable): NonEmptyArray; }; /** * Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`. * * @category concatenating * @since 1.0.0 */ export declare const append: { (last: B): (self: Iterable) => NonEmptyArray; (self: Iterable, last: B): NonEmptyArray; }; /** * @category concatenating * @since 1.0.0 */ export declare const appendAll: { (that: Iterable): (self: Iterable) => Array; (self: Iterable, that: Iterable): Array; }; /** * @category concatenating * @since 1.0.0 */ export declare const appendAllNonEmpty: { (that: NonEmptyReadonlyArray): (self: Iterable) => NonEmptyArray; (that: Iterable): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: Iterable, that: NonEmptyReadonlyArray): NonEmptyArray; (self: NonEmptyReadonlyArray, that: Iterable): NonEmptyArray; }; /** * Reduce an `Iterable` from the left, keeping all intermediate results instead of only the final result. * * @category folding * @since 1.0.0 */ export declare const scan: { (b: B, f: (b: B, a: A) => B): (self: Iterable) => NonEmptyArray; (self: Iterable, b: B, f: (b: B, a: A) => B): NonEmptyArray; }; /** * Reduce an `Iterable` from the right, keeping all intermediate results instead of only the final result. * * @category folding * @since 1.0.0 */ export declare const scanRight: { (b: B, f: (b: B, a: A) => B): (self: Iterable) => NonEmptyArray; (self: Iterable, b: B, f: (b: B, a: A) => B): NonEmptyArray; }; /** * Determine if an `Array` is empty narrowing down the type to `[]`. * * @param self - The `Array` to check. * * @example * import { isEmptyArray } from "@effect/data/ReadonlyArray" * * assert.deepStrictEqual(isEmptyArray([]), true); * assert.deepStrictEqual(isEmptyArray([1, 2, 3]), false); * * @category guards * @since 1.0.0 */ export declare const isEmptyArray: (self: A[]) => self is []; /** * Determine if a `ReadonlyArray` is empty narrowing down the type to `readonly []`. * * @param self - The `ReadonlyArray` to check. * * @example * import { isEmptyReadonlyArray } from "@effect/data/ReadonlyArray" * * assert.deepStrictEqual(isEmptyReadonlyArray([]), true); * assert.deepStrictEqual(isEmptyReadonlyArray([1, 2, 3]), false); * * @category guards * @since 1.0.0 */ export declare const isEmptyReadonlyArray: (self: ReadonlyArray) => self is readonly []; /** * Determine if an `Array` is non empty narrowing down the type to `NonEmptyArray`. * * An `Array` is considered to be a `NonEmptyArray` if it contains at least one element. * * @param self - The `Array` to check. * * @example * import { isNonEmptyArray } from "@effect/data/ReadonlyArray" * * assert.deepStrictEqual(isNonEmptyArray([]), false); * assert.deepStrictEqual(isNonEmptyArray([1, 2, 3]), true); * * @category guards * @since 1.0.0 */ export declare const isNonEmptyArray: (self: Array) => self is NonEmptyArray; /** * Determine if a `ReadonlyArray` is non empty narrowing down the type to `NonEmptyReadonlyArray`. * * A `ReadonlyArray` is considered to be a `NonEmptyReadonlyArray` if it contains at least one element. * * @param self - The `ReadonlyArray` to check. * * @example * import { isNonEmptyReadonlyArray } from "@effect/data/ReadonlyArray" * * assert.deepStrictEqual(isNonEmptyReadonlyArray([]), false); * assert.deepStrictEqual(isNonEmptyReadonlyArray([1, 2, 3]), true); * * @category guards * @since 1.0.0 */ export declare const isNonEmptyReadonlyArray: (self: ReadonlyArray) => self is NonEmptyReadonlyArray; /** * Return the number of elements in a `ReadonlyArray`. * * @category getters * @since 1.0.0 */ export declare const length: (self: readonly A[]) => number; /** * This function provides a safe way to read a value at a particular index from a `ReadonlyArray`. * * @category getters * @since 1.0.0 */ export declare const get: { (index: number): (self: ReadonlyArray) => Option; (self: ReadonlyArray, index: number): Option; }; /** * Gets an element unsafely, will throw on out of bounds. * * @since 1.0.0 * @category unsafe */ export declare const unsafeGet: { (index: number): (self: ReadonlyArray) => A; (self: ReadonlyArray, index: number): A; }; /** * Return a tuple containing the first element, and a new `Array` of the remaining elements, if any. * * @category getters * @since 1.0.0 */ export declare const unprepend: (self: readonly [A, ...A[]]) => [A, A[]]; /** * Return a tuple containing a copy of the `NonEmptyReadonlyArray` without its last element, and that last element. * * @category getters * @since 1.0.0 */ export declare const unappend: (self: readonly [A, ...A[]]) => [A[], A]; /** * Get the first element of a `ReadonlyArray`, or `None` if the `ReadonlyArray` is empty. * * @category getters * @since 1.0.0 */ export declare const head: (self: ReadonlyArray) => Option; /** * @category getters * @since 1.0.0 */ export declare const headNonEmpty: (self: NonEmptyReadonlyArray) => A; /** * Get the last element in a `ReadonlyArray`, or `None` if the `ReadonlyArray` is empty. * * @category getters * @since 1.0.0 */ export declare const last: (self: readonly A[]) => Option; /** * @category getters * @since 1.0.0 */ export declare const lastNonEmpty: (self: readonly [A, ...A[]]) => A; /** * Get all but the first element of an `Iterable`, creating a new `Array`, or `None` if the `Iterable` is empty. * * @category getters * @since 1.0.0 */ export declare const tail: (self: Iterable) => Option; /** * @category getters * @since 1.0.0 */ export declare const tailNonEmpty: (self: readonly [A, ...A[]]) => A[]; /** * Get all but the last element of an `Iterable`, creating a new `Array`, or `None` if the `Iterable` is empty. * * @category getters * @since 1.0.0 */ export declare const init: (self: Iterable) => Option; /** * Get all but the last element of a non empty array, creating a new array. * * @category getters * @since 1.0.0 */ export declare const initNonEmpty: (self: readonly [A, ...A[]]) => A[]; /** * Keep only a max number of elements from the start of an `Iterable`, creating a new `Array`. * * **Note**. `n` is normalized to a non negative integer. * * @category getters * @since 1.0.0 */ export declare const take: { (n: number): (self: Iterable) => Array; (self: Iterable, n: number): Array; }; /** * Keep only a max number of elements from the end of an `Iterable`, creating a new `Array`. * * **Note**. `n` is normalized to a non negative integer. * * @category getters * @since 1.0.0 */ export declare const takeRight: { (n: number): (self: Iterable) => Array; (self: Iterable, n: number): Array; }; /** * Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`. * * @category getters * @since 1.0.0 */ export declare const takeWhile: { (refinement: Refinement): (self: Iterable) => Array; (predicate: Predicate): (self: Iterable) => Array; (self: Iterable, refinement: Refinement): Array; (self: Iterable, predicate: Predicate): Array; }; /** * Split an `Iterable` into two parts: * * 1. the longest initial subarray for which all elements satisfy the specified predicate * 2. the remaining elements * * @category filtering * @since 1.0.0 */ export declare const span: { (refinement: Refinement): (self: Iterable) => [init: Array, rest: Array]; (predicate: Predicate): (self: Iterable) => [init: Array, rest: Array]; (self: Iterable, refinement: Refinement): [init: Array, rest: Array]; (self: Iterable, predicate: Predicate): [init: Array, rest: Array]; }; /** * Drop a max number of elements from the start of an `Iterable`, creating a new `Array`. * * **Note**. `n` is normalized to a non negative integer. * * @category getters * @since 1.0.0 */ export declare const drop: { (n: number): (self: Iterable) => Array; (self: Iterable, n: number): Array; }; /** * Drop a max number of elements from the end of an `Iterable`, creating a new `Array`. * * **Note**. `n` is normalized to a non negative integer. * * @category getters * @since 1.0.0 */ export declare const dropRight: { (n: number): (self: Iterable) => Array; (self: Iterable, n: number): Array; }; /** * Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`. * * @category getters * @since 1.0.0 */ export declare const dropWhile: { (refinement: Refinement): (self: Iterable) => Array; (predicate: Predicate): (self: Iterable) => Array; (self: Iterable, refinement: Refinement): Array; (self: Iterable, predicate: Predicate): Array; }; /** * Return the first index for which a predicate holds. * * @category elements * @since 1.0.0 */ export declare const findFirstIndex: { (predicate: Predicate): (self: Iterable) => Option; (self: Iterable, predicate: Predicate): Option; }; /** * Return the last index for which a predicate holds. * * @category elements * @since 1.0.0 */ export declare const findLastIndex: { (predicate: Predicate): (self: Iterable) => Option; (self: Iterable, predicate: Predicate): Option; }; /** * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * * @category elements * @since 1.0.0 */ export declare const findFirst: { (refinement: Refinement): (self: Iterable) => Option; (predicate: Predicate): (self: Iterable) => Option; (self: Iterable, refinement: Refinement): Option; (self: Iterable, predicate: Predicate): Option; }; /** * Find the last element for which a predicate holds. * * @category elements * @since 1.0.0 */ export declare const findLast: { (refinement: Refinement): (self: Iterable) => Option; (predicate: Predicate): (self: Iterable) => Option; (self: Iterable, refinement: Refinement): Option; (self: Iterable, predicate: Predicate): Option; }; /** * Insert an element at the specified index, creating a new `NonEmptyArray`, * or return `None` if the index is out of bounds. * * @since 1.0.0 */ export declare const insertAt: { (i: number, b: B): (self: Iterable) => Option>; (self: Iterable, i: number, b: B): Option>; }; /** * Change the element at the specified index, creating a new `Array`, * or return a copy of the input if the index is out of bounds. * * @since 1.0.0 */ export declare const replace: { (i: number, b: B): (self: Iterable) => Array; (self: Iterable, i: number, b: B): Array; }; /** * @since 1.0.0 */ export declare const replaceOption: { (i: number, b: B): (self: Iterable) => Option>; (self: Iterable, i: number, b: B): Option>; }; /** * Apply a function to the element at the specified index, creating a new `Array`, * or return a copy of the input if the index is out of bounds. * * @since 1.0.0 */ export declare const modify: { (i: number, f: (a: A) => B): (self: Iterable) => Array; (self: Iterable, i: number, f: (a: A) => B): Array; }; /** * Apply a function to the element at the specified index, creating a new `Array`, * or return `None` if the index is out of bounds. * * @since 1.0.0 */ export declare const modifyOption: { (i: number, f: (a: A) => B): (self: Iterable) => Option>; (self: Iterable, i: number, f: (a: A) => B): Option>; }; /** * Delete the element at the specified index, creating a new `Array`, * or return a copy of the input if the index is out of bounds. * * @since 1.0.0 */ export declare const remove: { (i: number): (self: Iterable) => Array; (self: Iterable, i: number): Array; }; /** * Reverse an `Iterable`, creating a new `Array`. * * @category elements * @since 1.0.0 */ export declare const reverse: (self: Iterable) => A[]; /** * @category elements * @since 1.0.0 */ export declare const reverseNonEmpty: (self: readonly [A, ...A[]]) => [A, ...A[]]; /** * Sort the elements of an `Iterable` in increasing order, creating a new `Array`. * * @category sorting * @since 1.0.0 */ export declare const sort: { (O: Order.Order): (self: Iterable) => Array; (self: Iterable, O: Order.Order): Array; }; /** * @since 1.0.0 * @category elements */ export declare const sortWith: { (f: (a: A) => B, order: Order.Order): (self: ReadonlyArray) => Array; (self: ReadonlyArray, f: (a: A) => B, order: Order.Order): Array; }; /** * Sort the elements of a `NonEmptyReadonlyArray` in increasing order, creating a new `NonEmptyArray`. * * @category sorting * @since 1.0.0 */ export declare const sortNonEmpty: { (O: Order.Order): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, O: Order.Order): NonEmptyArray; }; /** * Sort the elements of an `Iterable` in increasing order, where elements are compared * using first `orders[0]`, then `orders[1]`, etc... * * @category sorting * @since 1.0.0 */ export declare const sortBy: (...orders: readonly Order.Order[]) => (self: Iterable) => A[]; /** * @category sorting * @since 1.0.0 */ export declare const sortByNonEmpty: (...orders: readonly Order.Order[]) => (as: readonly [A, ...A[]]) => [A, ...A[]]; /** * Takes two `Iterable`s and returns an `Array` of corresponding pairs. * If one input `Iterable` is short, excess elements of the * longer `Iterable` are discarded. * * @since 1.0.0 */ export declare const zip: { (that: Iterable): (self: Iterable) => Array<[A, B]>; (self: Iterable, that: Iterable): Array<[A, B]>; }; /** * Apply a function to pairs of elements at the same index in two `Iterable`s, collecting the results in a new `Array`. If one * input `Iterable` is short, excess elements of the longer `Iterable` are discarded. * * @since 1.0.0 */ export declare const zipWith: { (that: Iterable, f: (a: A, b: B) => C): (self: Iterable) => Array; (self: Iterable, that: Iterable, f: (a: A, b: B) => C): Array; }; /** * @since 1.0.0 */ export declare const zipNonEmpty: { (that: NonEmptyReadonlyArray): (self: NonEmptyReadonlyArray) => NonEmptyArray<[A, B]>; (self: NonEmptyReadonlyArray, that: NonEmptyReadonlyArray): NonEmptyArray<[A, B]>; }; /** * @since 1.0.0 */ export declare const zipNonEmptyWith: { (that: NonEmptyReadonlyArray, f: (a: A, b: B) => C): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, that: NonEmptyReadonlyArray, f: (a: A, b: B) => C): NonEmptyArray; }; /** * This function is the inverse of `zip`. Takes an `Iterable` of pairs and return two corresponding `Array`s. * * @since 1.0.0 */ export declare const unzip: (self: Iterable) => [A[], B[]]; /** * @since 1.0.0 */ export declare const unzipNonEmpty: (self: readonly [readonly [A, B], ...(readonly [A, B])[]]) => [[A, ...A[]], [B, ...B[]]]; /** * Places an element in between members of an `Iterable` * * @since 1.0.0 */ export declare const intersperse: { (middle: B): (self: Iterable) => Array; (self: Iterable, middle: B): Array; }; /** * Places an element in between members of a `NonEmptyReadonlyArray` * * @since 1.0.0 */ export declare const intersperseNonEmpty: { (middle: B): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, middle: B): NonEmptyArray; }; /** * Apply a function to the head, creating a new `NonEmptyReadonlyArray`. * * @since 1.0.0 */ export declare const modifyNonEmptyHead: { (f: (a: A) => B): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, f: (a: A) => B): NonEmptyArray; }; /** * Change the head, creating a new `NonEmptyReadonlyArray`. * * @since 1.0.0 */ export declare const setNonEmptyHead: { (b: B): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, b: B): NonEmptyArray; }; /** * Apply a function to the last element, creating a new `NonEmptyReadonlyArray`. * * @since 1.0.0 */ export declare const modifyNonEmptyLast: { (f: (a: A) => B): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, f: (a: A) => B): NonEmptyArray; }; /** * Change the last element, creating a new `NonEmptyReadonlyArray`. * * @since 1.0.0 */ export declare const setNonEmptyLast: { (b: B): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, b: B): NonEmptyArray; }; /** * Rotate an `Iterable` by `n` steps. * * @since 1.0.0 */ export declare const rotate: { (n: number): (self: Iterable) => Array; (self: Iterable, n: number): Array; }; /** * Rotate a `NonEmptyReadonlyArray` by `n` steps. * * @since 1.0.0 */ export declare const rotateNonEmpty: { (n: number): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, n: number): NonEmptyArray; }; /** * Returns a function that checks if a `ReadonlyArray` contains a given value using a provided `isEquivalent` function. * * @category elements * @since 1.0.0 */ export declare const containsWith: (isEquivalent: (self: A, that: A) => boolean) => { (a: A): (self: Iterable) => boolean; (self: Iterable, a: A): boolean; }; /** * Returns a function that checks if a `ReadonlyArray` contains a given value using the default `Equivalence`. * * @category elements * @since 1.0.0 */ export declare const contains: { (a: A): (self: Iterable) => boolean; (self: Iterable, a: A): boolean; }; /** * Remove duplicates from a `NonEmptyReadonlyArray`, keeping the first occurrence of an element using the provided `isEquivalent` function. * * @since 1.0.0 */ export declare const dedupeNonEmptyWith: { (isEquivalent: (self: A, that: A) => boolean): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, isEquivalent: (self: A, that: A) => boolean): NonEmptyArray; }; /** * Remove duplicates from a `NonEmptyReadonlyArray`, keeping the first occurrence of an element. * * @since 1.0.0 */ export declare const dedupeNonEmpty: (self: NonEmptyReadonlyArray) => NonEmptyArray; /** * A useful recursion pattern for processing an `Iterable` to produce a new `Array`, often used for "chopping" up the input * `Iterable`. Typically chop is called with some function that will consume an initial prefix of the `Iterable` and produce a * value and the rest of the `Array`. * * @since 1.0.0 */ export declare const chop: { (f: (as: NonEmptyReadonlyArray) => readonly [B, ReadonlyArray]): (self: Iterable) => Array; (self: Iterable, f: (as: NonEmptyReadonlyArray) => readonly [B, ReadonlyArray]): Array; }; /** * A useful recursion pattern for processing a `NonEmptyReadonlyArray` to produce a new `NonEmptyReadonlyArray`, often used for "chopping" up the input * `NonEmptyReadonlyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `NonEmptyReadonlyArray` and produce a * value and the tail of the `NonEmptyReadonlyArray`. * * @since 1.0.0 */ export declare const chopNonEmpty: { (f: (as: NonEmptyReadonlyArray) => readonly [B, ReadonlyArray]): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, f: (as: NonEmptyReadonlyArray) => readonly [B, ReadonlyArray]): NonEmptyArray; }; /** * Splits an `Iterable` into two pieces, the first piece has max `n` elements. * * @category getters * @since 1.0.0 */ export declare const splitAt: { (n: number): (self: Iterable) => [Array, Array]; (self: Iterable, n: number): [Array, Array]; }; /** * @since 1.0.0 */ export declare const copy: { (self: NonEmptyReadonlyArray): NonEmptyArray; (self: ReadonlyArray): Array; }; /** * Splits a `NonEmptyReadonlyArray` into two pieces, the first piece has max `n` elements. * * @category getters * @since 1.0.0 */ export declare const splitNonEmptyAt: { (n: number): (self: NonEmptyReadonlyArray) => [NonEmptyArray, Array]; (self: NonEmptyReadonlyArray, n: number): [NonEmptyArray, Array]; }; /** * Splits an `Iterable` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of * the `Iterable`. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive * definition of `chunksOf`; it satisfies the property that * * ```ts * chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys))) * ``` * * whenever `n` evenly divides the length of `self`. * * @category getters * @since 1.0.0 */ export declare const chunksOf: { (n: number): (self: Iterable) => Array>; (self: Iterable, n: number): Array>; }; /** * Splits a `NonEmptyReadonlyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of * the `NonEmptyReadonlyArray`. * * @category getters * @since 1.0.0 */ export declare const chunksOfNonEmpty: { (n: number): (self: NonEmptyReadonlyArray) => NonEmptyArray>; (self: NonEmptyReadonlyArray, n: number): NonEmptyArray>; }; /** * Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s using the provided `isEquivalent` function. * * @category grouping * @since 1.0.0 */ export declare const groupWith: { (isEquivalent: (self: A, that: A) => boolean): (self: NonEmptyReadonlyArray) => NonEmptyArray>; (self: NonEmptyReadonlyArray, isEquivalent: (self: A, that: A) => boolean): NonEmptyArray>; }; /** * Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s. * * @category grouping * @since 1.0.0 */ export declare const group: (self: NonEmptyReadonlyArray) => NonEmptyArray>; /** * Splits an `Iterable` into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning * function on each element, and grouping the results according to values returned * * @category grouping * @since 1.0.0 */ export declare const groupBy: { (f: (a: A) => string): (self: Iterable) => Record>; (self: Iterable, f: (a: A) => string): Record>; }; /** * @since 1.0.0 */ export declare const unionWith: (isEquivalent: (self: A, that: A) => boolean) => { (that: Iterable): (self: Iterable) => A[]; (self: Iterable, that: Iterable): A[]; }; /** * @since 1.0.0 */ export declare const union: { (that: Iterable): (self: Iterable) => Array; (self: Iterable, that: Iterable): Array; }; /** * @since 1.0.0 */ export declare const unionNonEmptyWith: (isEquivalent: (self: A, that: A) => boolean) => { (that: readonly [A, ...A[]]): (self: readonly A[]) => [A, ...A[]]; (that: readonly A[]): (self: readonly [A, ...A[]]) => [A, ...A[]]; (self: readonly A[], that: readonly [A, ...A[]]): [A, ...A[]]; (self: readonly [A, ...A[]], that: readonly A[]): [A, ...A[]]; }; /** * @since 1.0.0 */ export declare const unionNonEmpty: { (that: NonEmptyReadonlyArray): (self: ReadonlyArray) => NonEmptyArray; (that: ReadonlyArray): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: ReadonlyArray, that: NonEmptyReadonlyArray): NonEmptyArray; (self: NonEmptyReadonlyArray, that: ReadonlyArray): NonEmptyArray; }; /** * Creates an `Array` of unique values that are included in all given `Iterable`s using the provided `isEquivalent` function. * The order and references of result values are determined by the first `Iterable`. * * @since 1.0.0 */ export declare const intersectionWith: (isEquivalent: (self: A, that: A) => boolean) => { (that: Iterable): (self: Iterable) => A[]; (self: Iterable, that: Iterable): A[]; }; /** * Creates an `Array` of unique values that are included in all given `Iterable`s. * The order and references of result values are determined by the first `Iterable`. * * @since 1.0.0 */ export declare const intersection: { (that: Iterable): (self: Iterable) => Array; (self: Iterable, that: Iterable): Array; }; /** * Creates a `Array` of values not included in the other given `Iterable` using the provided `isEquivalent` function. * The order and references of result values are determined by the first `Iterable`. * * @since 1.0.0 */ export declare const differenceWith: (isEquivalent: (self: A, that: A) => boolean) => { (that: Iterable): (self: Iterable) => A[]; (self: Iterable, that: Iterable): A[]; }; /** * Creates a `Array` of values not included in the other given `Iterable` using the provided `isEquivalent` function. * The order and references of result values are determined by the first `Iterable`. * * @since 1.0.0 */ export declare const difference: { (that: Iterable): (self: Iterable) => Array; (self: Iterable, that: Iterable): Array; }; /** * @category constructors * @since 1.0.0 */ export declare const empty: () => Array; /** * Constructs a new `NonEmptyArray` from the specified value. * * @category constructors * @since 1.0.0 */ export declare const of: (a: A) => [A, ...A[]]; /** * @category mapping * @since 1.0.0 */ export declare const map: { (f: (a: A, i: number) => B): (self: ReadonlyArray) => Array; (self: ReadonlyArray, f: (a: A, i: number) => B): Array; }; /** * @category mapping * @since 1.0.0 */ export declare const mapNonEmpty: { (f: (a: A, i: number) => B): (self: readonly [A, ...Array]) => [B, ...Array]; (self: readonly [A, ...Array], f: (a: A, i: number) => B): [B, ...Array]; }; /** * @category sequencing * @since 1.0.0 */ export declare const flatMap: { (f: (a: A, i: number) => ReadonlyArray): (self: ReadonlyArray) => Array; (self: ReadonlyArray, f: (a: A, i: number) => ReadonlyArray): Array; }; /** * @category sequencing * @since 1.0.0 */ export declare const flatMapNonEmpty: { (f: (a: A, i: number) => NonEmptyReadonlyArray): (self: NonEmptyReadonlyArray) => NonEmptyArray; (self: NonEmptyReadonlyArray, f: (a: A, i: number) => NonEmptyReadonlyArray): NonEmptyArray; }; /** * @category sequencing * @since 1.0.0 */ export declare const flatten: (self: ReadonlyArray>) => Array; /** * @category sequencing * @since 1.0.0 */ export declare const flattenNonEmpty: (self: NonEmptyReadonlyArray>) => NonEmptyArray; /** * @category filtering * @since 1.0.0 */ export declare const filterMap: { (f: (a: A, i: number) => Option): (self: Iterable) => Array; (self: Iterable, f: (a: A, i: number) => Option): Array; }; /** * Transforms all elements of the `readonlyArray` for as long as the specified function returns some value * * @category filtering * @since 1.0.0 */ export declare const filterMapWhile: { (f: (a: A) => Option): (self: Iterable) => Array; (self: Iterable, f: (a: A) => Option): Array; }; /** * @category filtering * @since 1.0.0 */ export declare const partitionMap: { (f: (a: A, i: number) => Either): (self: Iterable) => [Array, Array]; (self: Iterable, f: (a: A, i: number) => Either): [Array, Array]; }; /** * @category filtering * @since 1.0.0 */ export declare const compact: (self: Iterable>) => Array; /** * @category filtering * @since 1.0.0 */ export declare const filter: { (refinement: (a: A, i: number) => a is B): (self: Iterable) => Array; (predicate: (a: A, i: number) => boolean): (self: Iterable) => Array; (self: Iterable, refinement: (a: A, i: number) => a is B): Array; (self: Iterable, predicate: (a: A, i: number) => boolean): Array; }; /** * @category filtering * @since 1.0.0 */ export declare const partition: { (refinement: (a: A, i: number) => a is B): (self: Iterable) => [Array, Array]; (predicate: (a: A, i: number) => boolean): (self: Iterable) => [Array, Array]; (self: Iterable, refinement: (a: A, i: number) => a is B): [Array, Array]; (self: Iterable, predicate: (a: A, i: number) => boolean): [Array, Array]; }; /** * @category filtering * @since 1.0.0 */ export declare const separate: (self: Iterable>) => [Array, Array]; /** * @category folding * @since 1.0.0 */ export declare const reduce: { (b: B, f: (b: B, a: A, i: number) => B): (self: Iterable) => B; (self: Iterable, b: B, f: (b: B, a: A, i: number) => B): B; }; /** * @category folding * @since 1.0.0 */ export declare const reduceRight: { (b: B, f: (b: B, a: A, i: number) => B): (self: Iterable) => B; (self: Iterable, b: B, f: (b: B, a: A, i: number) => B): B; }; /** * @category lifting * @since 1.0.0 */ export declare const liftPredicate: { (refinement: Refinement): (c: C) => Array; (predicate: Predicate): (b: B) => Array; }; /** * @category lifting * @since 1.0.0 */ export declare const liftOption: (f: (...a: A) => Option) => (...a: A) => B[]; /** * @category conversions * @since 1.0.0 */ export declare const fromNullable: (a: A) => NonNullable[]; /** * @category lifting * @since 1.0.0 */ export declare const liftNullable: (f: (...a: A) => B | null | undefined) => (...a: A) => NonNullable[]; /** * @category combining * @since 1.0.0 */ export declare const flatMapNullable: { (f: (a: A) => B | null | undefined): (self: ReadonlyArray) => Array>; (self: ReadonlyArray, f: (a: A) => B | null | undefined): Array>; }; /** * @category lifting * @since 1.0.0 */ export declare const liftEither: (f: (...a: A) => Either) => (...a: A) => B[]; /** * Check if a predicate holds true for every `ReadonlyArray` element. * * @category elements * @since 1.0.0 */ export declare const every: { (refinement: Refinement): (self: ReadonlyArray) => self is ReadonlyArray; (predicate: Predicate): (self: ReadonlyArray) => boolean; (self: ReadonlyArray, refinement: Refinement): self is ReadonlyArray; (self: ReadonlyArray, predicate: Predicate): boolean; }; /** * Check if a predicate holds true for some `ReadonlyArray` element. * * @category elements * @since 1.0.0 */ export declare const some: { (predicate: Predicate): (self: ReadonlyArray) => self is NonEmptyReadonlyArray; (self: ReadonlyArray, predicate: Predicate): self is NonEmptyReadonlyArray; }; /** * @since 1.0.0 */ export declare const extend: { (f: (as: ReadonlyArray) => B): (self: ReadonlyArray) => Array; (self: ReadonlyArray, f: (as: ReadonlyArray) => B): Array; }; /** * @since 1.0.0 */ export declare const min: { (O: Order.Order): (self: NonEmptyReadonlyArray) => A; (self: NonEmptyReadonlyArray, O: Order.Order): A; }; /** * @since 1.0.0 */ export declare const max: { (O: Order.Order): (self: NonEmptyReadonlyArray) => A; (self: NonEmptyReadonlyArray, O: Order.Order): A; }; /** * @category constructors * @since 1.0.0 */ export declare const unfold: (b: B, f: (b: B) => Option) => A[]; /** * This function creates and returns a new `Order` for an array of values based on a given `Order` for the elements of the array. * The returned `Order` compares two arrays by applying the given `Order` to each element in the arrays. * If all elements are equal, the arrays are then compared based on their length. * It is useful when you need to compare two arrays of the same type and you have a specific way of comparing each element of the array. * * @category instances * @since 1.0.0 */ export declare const getOrder: (O: Order.Order) => Order.Order>; /** * @category instances * @since 1.0.0 */ export declare const getEquivalence: (isEquivalent: Equivalence.Equivalence) => Equivalence.Equivalence>; /** * Iterate over the `Iterable` applying `f`. * * @since 1.0.0 */ export declare const forEach: { (f: (a: A, i: number) => void): (self: Iterable) => void; (self: Iterable, f: (a: A, i: number) => void): void; }; /** * Remove duplicates from am `Iterable` using the provided `isEquivalent` function, keeping the first occurrence of an element. * * @since 1.0.0 */ export declare const dedupeWith: { (isEquivalent: (self: A, that: A) => boolean): (self: Iterable) => Array; (self: Iterable, isEquivalent: (self: A, that: A) => boolean): Array; }; /** * Remove duplicates from am `Iterable`, keeping the first occurrence of an element. * * @since 1.0.0 */ export declare const dedupe: (self: Iterable) => Array; /** * Deduplicates adjacent elements that are identical using the provided `isEquivalent` function. * * @since 1.0.0 */ export declare const dedupeAdjacentWith: { (isEquivalent: (self: A, that: A) => boolean): (self: Iterable) => Array; (self: Iterable, isEquivalent: (self: A, that: A) => boolean): Array; }; /** * Deduplicates adjacent elements that are identical. * * @since 1.0.0 */ export declare const dedupeAdjacent: (self: Iterable) => Array; /** * Joins the elements together with "sep" in the middle. * * @since 1.0.0 * @category folding */ export declare const join: { (sep: string): (self: Iterable) => string; (self: Iterable, sep: string): string; }; /** * Statefully maps over the chunk, producing new elements of type `B`. * * @since 1.0.0 * @category folding */ export declare const mapAccum: { (s: S, f: (s: S, a: A) => readonly [S, B]): (self: Iterable) => [S, Array]; (self: Iterable, s: S, f: (s: S, a: A) => readonly [S, B]): [S, Array]; }; /** * Zips this chunk crosswise with the specified chunk using the specified combiner. * * @since 1.0.0 * @category elements */ export declare const cartesianWith: { (that: ReadonlyArray, f: (a: A, b: B) => C): (self: ReadonlyArray) => Array; (self: ReadonlyArray, that: ReadonlyArray, f: (a: A, b: B) => C): Array; }; /** * Zips this chunk crosswise with the specified chunk. * * @since 1.0.0 * @category elements */ export declare const cartesian: { (that: ReadonlyArray): (self: ReadonlyArray) => Array<[A, B]>; (self: ReadonlyArray, that: ReadonlyArray): Array<[A, B]>; }; //# sourceMappingURL=ReadonlyArray.d.ts.map