/** * This module provides utility functions for working with arrays in TypeScript. * * @since 1.0.0 */ import type { Either } from "@fp-ts/core/Either"; import type { LazyArg } from "@fp-ts/core/Function"; import type { Kind, TypeLambda } from "@fp-ts/core/HKT"; import type { Option } from "@fp-ts/core/Option"; import type { Predicate, Refinement } from "@fp-ts/core/Predicate"; import * as applicative from "@fp-ts/core/typeclass/Applicative"; import * as chainable from "@fp-ts/core/typeclass/Chainable"; import type { Coproduct } from "@fp-ts/core/typeclass/Coproduct"; import * as covariant from "@fp-ts/core/typeclass/Covariant"; import type * as filterable from "@fp-ts/core/typeclass/Filterable"; import * as flatMap_ from "@fp-ts/core/typeclass/FlatMap"; import * as foldable from "@fp-ts/core/typeclass/Foldable"; import * as invariant from "@fp-ts/core/typeclass/Invariant"; import type * as monad from "@fp-ts/core/typeclass/Monad"; import type { Monoid } from "@fp-ts/core/typeclass/Monoid"; import * as of_ from "@fp-ts/core/typeclass/Of"; import * as order from "@fp-ts/core/typeclass/Order"; import type { Order } from "@fp-ts/core/typeclass/Order"; import type * as pointed from "@fp-ts/core/typeclass/Pointed"; import type * as product_ from "@fp-ts/core/typeclass/Product"; import * as semiApplicative from "@fp-ts/core/typeclass/SemiApplicative"; import type { Semigroup } from "@fp-ts/core/typeclass/Semigroup"; import * as semiProduct from "@fp-ts/core/typeclass/SemiProduct"; import * as traversable from "@fp-ts/core/typeclass/Traversable"; import * as traversableFilterable from "@fp-ts/core/typeclass/TraversableFilterable"; /** * @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 '@fp-ts/core/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 '@fp-ts/core/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 '@fp-ts/core/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) => Array; /** * @category conversions * @since 1.0.0 */ export declare const fromOption: (self: Option) => Array; /** * @category conversions * @since 1.0.0 */ export declare const fromEither: (self: Either) => Array; /** * @category pattern matching * @since 1.0.0 */ export declare const match: { (onEmpty: LazyArg, onNonEmpty: (self: NonEmptyReadonlyArray) => C): (self: ReadonlyArray) => B | C; (self: ReadonlyArray, onEmpty: LazyArg, onNonEmpty: (self: NonEmptyReadonlyArray) => C): B | C; }; /** * @category pattern matching * @since 1.0.0 */ export declare const matchLeft: { (onEmpty: LazyArg, onNonEmpty: (head: A, tail: Array) => C): (self: ReadonlyArray) => B | C; (self: ReadonlyArray, onEmpty: LazyArg, onNonEmpty: (head: A, tail: Array) => C): B | C; }; /** * @category pattern matching * @since 1.0.0 */ export declare const matchRight: { (onEmpty: LazyArg, onNonEmpty: (init: Array, last: A) => C): (self: ReadonlyArray) => B | C; (self: ReadonlyArray, onEmpty: LazyArg, onNonEmpty: (init: Array, last: A) => C): B | C; }; /** * Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`. * * @since 1.0.0 */ export declare const prepend: { (head: B): (self: Iterable) => NonEmptyArray; (self: Iterable, head: B): NonEmptyArray; }; /** * @since 1.0.0 */ export declare const prependAll: { (that: Iterable): (self: Iterable) => Array; (self: Iterable, that: Iterable): Array; }; /** * @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`. * * @since 1.0.0 */ export declare const append: { (last: B): (self: Iterable) => NonEmptyArray; (self: Iterable, last: B): NonEmptyArray; }; /** * @since 1.0.0 */ export declare const appendAll: { (that: Iterable): (self: Iterable) => Array; (self: Iterable, that: Iterable): Array; }; /** * @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 a `ReadonlyArray` is empty narrowing down the type to `[]`. * * @param self - The `ReadonlyArray` to check. * * @example * import { isEmpty } from "@fp-ts/core/ReadonlyArray" * * assert.deepStrictEqual(isEmpty([]), true); * assert.deepStrictEqual(isEmpty([1, 2, 3]), false); * * @category guards * @since 1.0.0 */ export declare function isEmpty(self: Array): self is []; export declare function isEmpty(self: ReadonlyArray): self is readonly []; /** * Determine if a `ReadonlyArray` is non empty narrowing down the type to `NonEmptyArray`. * * A `ReadonlyArray` is considered to be a `NonEmptyReadonlyArray` if it contains at least one element. * * @param self - The `ReadonlyArray` to check. * * @example * import { isNonEmpty } from "@fp-ts/core/ReadonlyArray" * * assert.deepStrictEqual(isNonEmpty([]), false); * assert.deepStrictEqual(isNonEmpty([1, 2, 3]), true); * * @category guards * @since 1.0.0 */ export declare const isNonEmpty: { (self: Array): self is NonEmptyArray; (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 getters * @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 getters * @since 1.0.0 */ export declare const findLastIndex: { (predicate: Predicate): (self: Iterable) => Option; (self: Iterable, predicate: Predicate): Option; }; /** * Find the first element for which a predicate holds. * * @category getters * @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 getters * @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`. * * @since 1.0.0 */ export declare const reverse: (self: Iterable) => A[]; /** * @since 1.0.0 */ export declare const reverseNonEmpty: (self: readonly [A, ...A[]]) => [A, ...A[]]; /** * Return all the `Right` elements from an `Interable` of `Either`s. * * @category getters * @since 1.0.0 */ export declare const rights: (self: Iterable>) => Array; /** * Return all the `Left` elements from an `Interable` of `Either`s. * * @category getters * @since 1.0.0 */ export declare const lefts: (self: Iterable>) => Array; /** * 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) => A[]; /** * 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: readonly [A, ...A[]]) => [A, ...A[]]; /** * 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]>) => [A[], B[]]; /** * @since 1.0.0 */ export declare const unzipNonEmpty: (self: readonly [[A, B], ...[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 `equivalence` function. * * @category predicates * @since 1.0.0 */ export declare const contains: (isEquivalent: (self: A, that: A) => boolean) => { (a: A): (self: Iterable) => boolean; (self: Iterable, a: A): boolean; }; /** * Remove duplicates from am `Iterable`, keeping the first occurrence of an element. * * @since 1.0.0 */ export declare const uniq: (isEquivalent: (self: A, that: A) => boolean) => (self: Iterable) => A[]; /** * Remove duplicates from a `NonEmptyReadonlyArray`, keeping the first occurrence of an element. * * @since 1.0.0 */ export declare const uniqNonEmpty: (isEquivalent: (self: A, that: A) => boolean) => (self: readonly [A, ...A[]]) => [A, ...A[]]; /** * 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. * * @category grouping * @since 1.0.0 */ export declare const group: (isEquivalent: (self: A, that: A) => boolean) => (self: readonly [A, ...A[]]) => [[A, ...A[]], ...[A, ...A[]][]]; /** * 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 union: (isEquivalent: (self: A, that: A) => boolean) => { (that: readonly A[]): (self: readonly A[]) => A[]; (self: readonly A[], that: readonly A[]): A[]; }; /** * @since 1.0.0 */ export declare const unionNonEmpty: (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[]]; }; /** * 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: (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`. * The order and references of result values are determined by the first `Iterable`. * * @since 1.0.0 */ export declare const difference: (isEquivalent: (self: A, that: A) => boolean) => { (that: Iterable): (self: Iterable) => A[]; (self: Iterable, that: Iterable): A[]; }; /** * @category constructors * @since 1.0.0 */ export declare const of: (a: A) => [A, ...A[]]; /** * @category constructors * @since 1.0.0 */ export declare const empty: () => Array; /** * @category instances * @since 1.0.0 */ export declare const Of: of_.Of; /** * @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 instances * @since 1.0.0 */ export declare const Covariant: covariant.Covariant; /** * @category instances * @since 1.0.0 */ export declare const Invariant: invariant.Invariant; /** * @category mapping * @since 1.0.0 */ export declare const tupled: (self: ReadonlyArray) => Array<[A]>; /** * @category mapping * @since 1.0.0 */ export declare const flap: { (a: A, self: ReadonlyArray<(a: A) => B>): Array; (self: ReadonlyArray<(a: A) => B>): (a: A) => Array; }; /** * Maps the success value of this effect to the specified constant value. * * @category mapping * @since 1.0.0 */ export declare const as: { <_, B>(self: ReadonlyArray<_>, b: B): Array; (b: B): <_>(self: ReadonlyArray<_>) => Array; }; /** * @category instances * @since 1.0.0 */ export declare const Pointed: pointed.Pointed; /** * @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 instances * @since 1.0.0 */ export declare const FlatMap: flatMap_.FlatMap; /** * @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; /** * @since 1.0.0 */ export declare const composeKleisliArrow: { (afb: (a: A) => ReadonlyArray, bfc: (b: B) => ReadonlyArray): (a: A) => ReadonlyArray; (bfc: (b: B) => ReadonlyArray): (afb: (a: A) => ReadonlyArray) => (a: A) => ReadonlyArray; }; /** * @category instances * @since 1.0.0 */ export declare const Chainable: chainable.Chainable; /** * @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; }; /** * @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 instances * @since 1.0.0 */ export declare const Filterable: filterable.Filterable; /** * @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 traversing * @since 1.0.0 */ export declare const traverseNonEmpty: (F: semiApplicative.SemiApplicative) => { (f: (a: A, i: number) => Kind): (self: readonly [A, ...A[]]) => Kind; (self: readonly [A_1, ...A_1[]], f: (a: A_1, i: number) => Kind): Kind; }; /** * @category traversing * @since 1.0.0 */ export declare const traverse: (F: applicative.Applicative) => { (f: (a: A, i: number) => Kind): (self: Iterable) => Kind; (self: Iterable, f: (a: A_1, i: number) => Kind): Kind; }; /** * @category traversing * @since 1.0.0 */ export declare const sequence: (F: applicative.Applicative) => (self: readonly Kind[]) => Kind; /** * @category instances * @since 1.0.0 */ export declare const Traversable: traversable.Traversable; /** * @category traversing * @since 1.0.0 */ export declare const traverseTap: (F: applicative.Applicative) => { (self: ReadonlyArray, f: (a: A) => Kind): Kind>; (f: (a: A) => Kind): (self: ReadonlyArray) => Kind>; }; /** * @category traversing * @since 1.0.0 */ export declare const sequenceNonEmpty: (F: semiApplicative.SemiApplicative) => (self: readonly [Kind, ...Kind[]]) => Kind; /** * @category instances * @since 1.0.0 */ export declare const SemiProduct: semiProduct.SemiProduct; /** * @category instances * @since 1.0.0 */ export declare const SemiApplicative: semiApplicative.SemiApplicative; /** * @since 1.0.0 */ export declare const ap: { (self: ReadonlyArray<(a: A) => B>, that: ReadonlyArray): Array; (that: ReadonlyArray): (self: ReadonlyArray<(a: A) => B>) => Array; }; /** * Lifts a binary function into `ReadonlyArray`. * * @param f - The function to lift. * * @category lifting * @since 1.0.0 */ export declare const lift2: (f: (a: A, b: B) => C) => { (self: ReadonlyArray, that: ReadonlyArray): Array; (that: ReadonlyArray): (self: ReadonlyArray) => Array; }; /** * @category instances * @since 1.0.0 */ export declare const Product: product_.Product; /** * @category instances * @since 1.0.0 */ export declare const Applicative: applicative.Applicative; /** * @category lifting * @since 1.0.0 */ export declare const liftMonoid: (M: Monoid) => Monoid>; /** * @category instances * @since 1.0.0 */ export declare const Monad: monad.Monad; /** * @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 instances * @since 1.0.0 */ export declare const Foldable: foldable.Foldable; /** * @category folding * @since 1.0.0 */ export declare const combineMap: (Monoid: Monoid) => { (f: (a: A, i: number) => M): (self: Iterable) => M; (self: Iterable, f: (a: A_1, i: number) => M): M; }; /** * @category folding * @since 1.0.0 */ export declare const combineMapNonEmpty: (S: Semigroup) => { (f: (a: A, i: number) => S): (self: readonly [A, ...A[]]) => S; (self: readonly [A_1, ...A_1[]], f: (a: A_1, i: number) => S): S; }; /** * @category folding * @since 1.0.0 */ export declare const reduceKind: (G: monad.Monad) => { (b: B, f: (b: B, a: A) => Kind): (self: ReadonlyArray) => Kind; (self: ReadonlyArray, b: B, f: (b: B, a: A) => Kind): Kind; }; /** * @category folding * @since 1.0.0 */ export declare const coproductMapKind: (G: Coproduct) => { (f: (a: A) => Kind): (self: ReadonlyArray) => Kind; (self: ReadonlyArray, f: (a: A) => Kind): Kind; }; /** * @category filtering * @since 1.0.0 */ export declare const traversePartitionMap: (F: applicative.Applicative) => { (f: (a: A) => Kind>): (self: readonly A[]) => Kind; (self: readonly A_1[], f: (a: A_1) => Kind>): Kind; }; /** * @category filtering * @since 1.0.0 */ export declare const traverseFilterMap: (F: applicative.Applicative) => { (f: (a: A) => Kind>): (self: readonly A[]) => Kind; (self: readonly A_1[], f: (a: A_1) => Kind>): Kind; }; /** * @category instances * @since 1.0.0 */ export declare const TraversableFilterable: traversableFilterable.TraversableFilterable; /** * Filter values inside a context. * * @since 1.0.0 */ export declare const traverseFilter: (F: applicative.Applicative) => { (predicate: (a: A) => Kind): (self: ReadonlyArray) => Kind>; (self: ReadonlyArray, predicate: (a: A) => Kind): Kind>; }; /** * @since 1.0.0 */ export declare const traversePartition: (F: applicative.Applicative) => { (predicate: (a: A) => Kind): (self: ReadonlyArray) => Kind, Array]>; (self: ReadonlyArray, predicate: (a: A) => Kind): Kind, Array]>; }; /** * @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 sequencing * @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` member. * * @category lifting * @since 1.0.0 */ export declare function every(refinement: Refinement): Refinement, ReadonlyArray>; export declare function every(predicate: Predicate): Predicate>; /** * Check if a predicate holds true for any `ReadonlyArray` member. * * @category predicates * @since 1.0.0 */ export declare const some: (predicate: Predicate) => (self: readonly A[]) => self is readonly [A, ...A[]]; /** * Fold an `Iterable`, accumulating values in some `Monoid`, combining adjacent elements * using the specified separator. * * @since 1.0.0 */ export declare const intercalate: (M: Monoid) => { (middle: A): (self: Iterable) => A; (self: Iterable, middle: A): A; }; /** * Places an element in between members of a `NonEmptyReadonlyArray`, then folds the results using the provided `Semigroup`. * * @since 1.0.0 */ export declare const intercalateNonEmpty: (S: Semigroup) => { (middle: A): (self: readonly [A, ...A[]]) => A; (self: readonly [A, ...A[]], middle: A): A; }; /** * @since 1.0.0 */ export declare const join: { (middle: string): (self: ReadonlyArray) => string; (self: ReadonlyArray, middle: string): string; }; /** * @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: readonly [A, ...A[]]) => A; /** * @since 1.0.0 */ export declare const max: (O: order.Order) => (self: readonly [A, ...A[]]) => A; /** * @category constructors * @since 1.0.0 */ export declare const unfold: (b: B, f: (b: B) => Option) => A[]; /** * @category instances * @since 1.0.0 */ export declare const getUnionSemigroup: (isEquivalent: (self: A, that: A) => boolean) => Semigroup; /** * @category instances * @since 1.0.0 */ export declare const getUnionMonoid: (isEquivalent: (self: A, that: A) => boolean) => Monoid; /** * @category instances * @since 1.0.0 */ export declare const getIntersectionSemigroup: (isEquivalent: (self: A, that: A) => boolean) => Semigroup; /** * Returns a `Semigroup` for `ReadonlyArray`. * * @category instances * @since 1.0.0 */ export declare const getSemigroup: () => Semigroup>; /** * Returns a `Monoid` for `ReadonlyArray`. * * @category instances * @since 1.0.0 */ export declare const getMonoid: () => Monoid>; /** * 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 lifting * @since 1.0.0 */ export declare const getOrder: (O: Order) => Order>; /** * @category do notation * @since 1.0.0 */ export declare const bindTo: { (name: N): (self: ReadonlyArray) => Array<{ [K in N]: A; }>; (self: ReadonlyArray, name: N): Array<{ [K in N]: A; }>; }; declare const let_: { (name: Exclude, f: (a: A) => B): (self: ReadonlyArray) => Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; (self: ReadonlyArray, name: Exclude, f: (a: A) => B): Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; }; export { /** * @category do notation * @since 1.0.0 */ let_ as let }; /** * @category do notation * @since 1.0.0 */ export declare const Do: ReadonlyArray<{}>; /** * @category do notation * @since 1.0.0 */ export declare const bind: { (name: Exclude, f: (a: A) => ReadonlyArray): (self: ReadonlyArray) => Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; (self: ReadonlyArray, name: Exclude, f: (a: A) => ReadonlyArray): Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; }; /** * A variant of `bind` that sequentially ignores the scope. * * @category do notation * @since 1.0.0 */ export declare const andThenBind: { (name: Exclude, that: ReadonlyArray): (self: ReadonlyArray) => Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; (self: ReadonlyArray, name: Exclude, that: ReadonlyArray): Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; }; //# sourceMappingURL=ReadonlyArray.d.ts.map