/** * @since 1.0.0 */ import type { Either } from "@effect/data/Either"; import * as Equal from "@effect/data/Equal"; import * as Equivalence from "@effect/data/Equivalence"; import type { TypeLambda } from "@effect/data/HKT"; import { type Inspectable } from "@effect/data/Inspectable"; import type { NonEmptyIterable } from "@effect/data/NonEmptyIterable"; import type { Option } from "@effect/data/Option"; import * as Order from "@effect/data/Order"; import type { Pipeable } from "@effect/data/Pipeable"; import type { Predicate, Refinement } from "@effect/data/Predicate"; declare const TypeId: unique symbol; /** * @category symbol * @since 1.0.0 */ export type TypeId = typeof TypeId; /** * @category models * @since 1.0.0 */ export interface Chunk extends Iterable, Equal.Equal, Pipeable, Inspectable { readonly [TypeId]: { readonly _A: (_: never) => A; }; readonly length: number; } /** * @category model * @since 1.0.0 */ export interface NonEmptyChunk extends Chunk, NonEmptyIterable { } /** * @category type lambdas * @since 1.0.0 */ export interface ChunkTypeLambda extends TypeLambda { readonly type: Chunk; } /** * Compares the two chunks of equal length using the specified function * * @category equivalence * @since 1.0.0 */ export declare const getEquivalence: (isEquivalent: Equivalence.Equivalence) => Equivalence.Equivalence>; /** * Checks if `u` is a `Chunk` * * @category constructors * @since 1.0.0 */ export declare const isChunk: { (u: Iterable): u is Chunk; (u: unknown): u is Chunk; }; /** * @category constructors * @since 1.0.0 */ export declare const empty: () => Chunk; /** * Builds a `NonEmptyChunk` from an non-empty collection of elements. * * @category constructors * @since 1.0.0 */ export declare const make: (...as: As) => NonEmptyChunk; /** * Builds a `NonEmptyChunk` from a single element. * * @category constructors * @since 1.0.0 */ export declare const of: (a: A) => NonEmptyChunk; /** * Converts from an `Iterable` * * @category conversions * @since 1.0.0 */ export declare const fromIterable: (self: Iterable) => Chunk; /** * Converts the specified `Chunk` to a `ReadonlyArray`. * * @category conversions * @since 1.0.0 */ export declare const toReadonlyArray: (self: Chunk) => readonly A[]; /** * @since 1.0.0 * @category elements */ export declare const reverse: (self: Chunk) => Chunk; /** * This function provides a safe way to read a value at a particular index from a `Chunk`. * * @category elements * @since 1.0.0 */ export declare const get: { (index: number): (self: Chunk) => Option; (self: Chunk, index: number): Option; }; /** * Wraps an array into a chunk without copying, unsafe on mutable arrays * * @since 1.0.0 * @category unsafe */ export declare const unsafeFromArray: (self: readonly A[]) => Chunk; /** * Wraps an array into a chunk without copying, unsafe on mutable arrays * * @since 1.0.0 * @category unsafe */ export declare const unsafeFromNonEmptyArray: (self: readonly [A, ...A[]]) => NonEmptyChunk; /** * Gets an element unsafely, will throw on out of bounds * * @since 1.0.0 * @category unsafe */ export declare const unsafeGet: { (index: number): (self: Chunk) => A; (self: Chunk, index: number): A; }; /** * Appends the specified element to the end of the `Chunk`. * * @category concatenating * @since 1.0.0 */ export declare const append: { (a: A2): (self: Chunk) => NonEmptyChunk; (self: Chunk, a: A2): NonEmptyChunk; }; /** * Prepend an element to the front of a `Chunk`, creating a new `NonEmptyChunk`. * * @category concatenating * @since 1.0.0 */ export declare const prepend: { (elem: B): (self: Chunk) => NonEmptyChunk; (self: Chunk, elem: B): NonEmptyChunk; }; /** * Takes the first up to `n` elements from the chunk * * @since 1.0.0 */ export declare const take: { (n: number): (self: Chunk) => Chunk; (self: Chunk, n: number): Chunk; }; /** * Drops the first up to `n` elements from the chunk * * @since 1.0.0 */ export declare const drop: { (n: number): (self: Chunk) => Chunk; (self: Chunk, n: number): Chunk; }; /** * Drops the last `n` elements. * * @since 1.0.0 */ export declare const dropRight: { (n: number): (self: Chunk) => Chunk; (self: Chunk, n: number): Chunk; }; /** * Drops all elements so long as the predicate returns true. * * @since 1.0.0 */ export declare const dropWhile: { (f: (a: A) => boolean): (self: Chunk) => Chunk; (self: Chunk, f: (a: A) => boolean): Chunk; }; /** * @category concatenating * @since 1.0.0 */ export declare const prependAll: { (that: Chunk): (self: Chunk) => Chunk; (self: Chunk, that: Chunk): Chunk; }; /** * @category concatenating * @since 1.0.0 */ export declare const prependAllNonEmpty: { (that: NonEmptyChunk): (self: Chunk) => NonEmptyChunk; (that: Chunk): (self: NonEmptyChunk) => NonEmptyChunk; (self: Chunk, that: NonEmptyChunk): NonEmptyChunk; (self: NonEmptyChunk, that: Chunk): NonEmptyChunk; }; /** * Concatenates the two chunks * * @category concatenating * @since 1.0.0 */ export declare const appendAll: { (that: Chunk): (self: Chunk) => Chunk; (self: Chunk, that: Chunk): Chunk; }; /** * @category concatenating * @since 1.0.0 */ export declare const appendAllNonEmpty: { (that: NonEmptyChunk): (self: Chunk) => NonEmptyChunk; (that: Chunk): (self: NonEmptyChunk) => NonEmptyChunk; (self: Chunk, that: NonEmptyChunk): NonEmptyChunk; (self: NonEmptyChunk, that: Chunk): NonEmptyChunk; }; /** * Returns a filtered and mapped subset of the elements. * * @since 1.0.0 * @category filtering */ export declare const filterMap: { (f: (a: A, i: number) => Option): (self: Chunk) => Chunk; (self: Chunk, f: (a: A, i: number) => Option): Chunk; }; /** * Returns a filtered and mapped subset of the elements. * * @since 1.0.0 * @category filtering */ export declare const filter: { (refinement: Refinement): (self: Chunk) => Chunk; (predicate: Predicate): (self: Chunk) => Chunk; (self: Chunk, refinement: Refinement): Chunk; (self: Chunk, predicate: Predicate): Chunk; }; /** * Transforms all elements of the chunk for as long as the specified function returns some value * * @since 1.0.0 * @category filtering */ export declare const filterMapWhile: { (f: (a: A) => Option): (self: Chunk) => Chunk; (self: Chunk, f: (a: A) => Option): Chunk; }; /** * Filter out optional values * * @since 1.0.0 * @category filtering */ export declare const compact: (self: Chunk>) => Chunk; /** * Returns a chunk with the elements mapped by the specified function. * * @since 1.0.0 * @category sequencing */ export declare const flatMap: { (f: (a: A, i: number) => Chunk): (self: Chunk) => Chunk; (self: Chunk, f: (a: A, i: number) => Chunk): Chunk; }; /** * @category sequencing * @since 1.0.0 */ export declare const flatMapNonEmpty: { (f: (a: A, i: number) => NonEmptyChunk): (self: NonEmptyChunk) => NonEmptyChunk; (self: NonEmptyChunk, f: (a: A, i: number) => NonEmptyChunk): NonEmptyChunk; }; /** * Applies the specified function to each element of the `List`. * * @since 1.0.0 * @category combinators */ export declare const forEach: { (f: (a: A) => B): (self: Chunk) => void; (self: Chunk, f: (a: A) => B): void; }; /** * Flattens a chunk of chunks into a single chunk by concatenating all chunks. * * @since 1.0.0 * @category sequencing */ export declare const flatten: (self: Chunk>) => Chunk; /** * @category sequencing * @since 1.0.0 */ export declare const flattenNonEmpty: (self: NonEmptyChunk>) => NonEmptyChunk; /** * Groups elements in chunks of up to `n` elements. * * @since 1.0.0 * @category elements */ export declare const chunksOf: { (n: number): (self: Chunk) => Chunk>; (self: Chunk, n: number): Chunk>; }; /** * Creates a Chunk of unique values that are included in all given Chunks. * * The order and references of result values are determined by the Chunk. * * @since 1.0.0 * @category elements */ export declare const intersection: { (that: Chunk): (self: Chunk) => Chunk; (self: Chunk, that: Chunk): Chunk; }; /** * Determines if the chunk is empty. * * @since 1.0.0 * @category elements */ export declare const isEmpty: (self: Chunk) => boolean; /** * Determines if the chunk is not empty. * * @since 1.0.0 * @category elements */ export declare const isNonEmpty: (self: Chunk) => self is NonEmptyChunk; /** * Returns the first element of this chunk if it exists. * * @since 1.0.0 * @category elements */ export declare const head: (self: Chunk) => Option; /** * Returns the first element of this chunk. * * @since 1.0.0 * @category unsafe */ export declare const unsafeHead: (self: Chunk) => A; /** * Returns the first element of this non empty chunk. * * @since 1.0.0 * @category elements */ export declare const headNonEmpty: (self: NonEmptyChunk) => A; /** * Returns the last element of this chunk if it exists. * * @since 1.0.0 * @category elements */ export declare const last: (self: Chunk) => Option; /** * Returns the last element of this chunk. * * @since 1.0.0 * @category unsafe */ export declare const unsafeLast: (self: Chunk) => A; /** * Returns an effect whose success is mapped by the specified f function. * * @since 1.0.0 * @category mapping */ export declare const map: { (f: (a: A, i: number) => B): (self: Chunk) => Chunk; (self: Chunk, f: (a: A, i: number) => B): Chunk; }; /** * 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: Chunk) => [S, Chunk]; (self: Chunk, s: S, f: (s: S, a: A) => readonly [S, B]): [S, Chunk]; }; /** * Separate elements based on a predicate that also exposes the index of the element. * * @category filtering * @since 1.0.0 */ export declare const partition: { (refinement: Refinement): (self: Chunk) => [Chunk>, Chunk]; (predicate: (a: A) => boolean): (self: Chunk) => [Chunk, Chunk]; (self: Chunk, refinement: Refinement): [Chunk>, Chunk]; (self: Chunk, predicate: (a: A) => boolean): [Chunk, Chunk]; }; /** * Partitions the elements of this chunk into two chunks using f. * * @category filtering * @since 1.0.0 */ export declare const partitionMap: { (f: (a: A) => Either): (self: Chunk) => [Chunk, Chunk]; (self: Chunk, f: (a: A) => Either): [Chunk, Chunk]; }; /** * Partitions the elements of this chunk into two chunks. * * @category filtering * @since 1.0.0 */ export declare const separate: (self: Chunk>) => [Chunk, Chunk]; /** * Retireves the size of the chunk * * @since 1.0.0 * @category elements */ export declare const size: (self: Chunk) => number; /** * Sort the elements of a Chunk in increasing order, creating a new Chunk. * * @since 1.0.0 * @category elements */ export declare const sort: { (O: Order.Order): (self: Chunk) => Chunk; (self: Chunk, O: Order.Order): Chunk; }; /** * @since 1.0.0 * @category elements */ export declare const sortWith: { (f: (a: A) => B, order: Order.Order): (self: Chunk) => Chunk; (self: Chunk, f: (a: A) => B, order: Order.Order): Chunk; }; /** * Returns two splits of this chunk at the specified index. * * @since 1.0.0 * @category elements */ export declare const splitAt: { (n: number): (self: Chunk) => [Chunk, Chunk]; (self: Chunk, n: number): [Chunk, Chunk]; }; /** * Splits this chunk into `n` equally sized chunks. * * @since 1.0.0 * @category elements */ export declare const split: { (n: number): (self: Chunk) => Chunk>; (self: Chunk, n: number): Chunk>; }; /** * Splits this chunk on the first element that matches this predicate. * * @category elements * @since 1.0.0 */ export declare const splitWhere: { (predicate: Predicate): (self: Chunk) => [Chunk, Chunk]; (self: Chunk, predicate: Predicate): [Chunk, Chunk]; }; /** * Returns every elements after the first. * * @since 1.0.0 * @category elements */ export declare const tail: (self: Chunk) => Option>; /** * Returns every elements after the first. * * @since 1.0.0 * @category elements */ export declare const tailNonEmpty: (self: NonEmptyChunk) => Chunk; /** * Takes the last `n` elements. * * @since 1.0.0 * @category elements */ export declare const takeRight: { (n: number): (self: Chunk) => Chunk; (self: Chunk, n: number): Chunk; }; /** * Takes all elements so long as the predicate returns true. * * @since 1.0.0 * @category elements */ export declare const takeWhile: { (predicate: Predicate): (self: Chunk) => Chunk; (self: Chunk, predicate: Predicate): Chunk; }; /** * Creates a Chunks of unique values, in order, from all given Chunks. * * @since 1.0.0 * @category elements */ export declare const union: { (that: Chunk): (self: Chunk) => Chunk; (self: Chunk, that: Chunk): Chunk; }; /** * Remove duplicates from an array, keeping the first occurrence of an element. * * @since 1.0.0 * @category elements */ export declare const dedupe: (self: Chunk) => Chunk; /** * Deduplicates adjacent elements that are identical. * * @since 1.0.0 * @category filtering */ export declare const dedupeAdjacent: (self: Chunk) => Chunk; /** * Takes a `Chunk` of pairs and return two corresponding `Chunk`s. * * Note: The function is reverse of `zip`. * * @since 1.0.0 * @category elements */ export declare const unzip: (self: Chunk) => [Chunk, Chunk]; /** * Zips this chunk pointwise with the specified chunk using the specified combiner. * * @since 1.0.0 * @category elements */ export declare const zipWith: { (that: Chunk, f: (a: A, b: B) => C): (self: Chunk) => Chunk; (self: Chunk, that: Chunk, f: (a: A, b: B) => C): Chunk; }; /** * Zips this chunk pointwise with the specified chunk. * * @since 1.0.0 * @category elements */ export declare const zip: { (that: Chunk): (self: Chunk) => Chunk; (self: Chunk, that: Chunk): Chunk; }; /** * Delete the element at the specified index, creating a new `Chunk`, * or returning the input if the index is out of bounds. * * @since 1.0.0 */ export declare const remove: { (i: number): (self: Chunk) => Chunk; (self: Chunk, i: number): Chunk; }; /** * @since 1.0.0 */ export declare const modifyOption: { (i: number, f: (a: A) => B): (self: Chunk) => Option>; (self: Chunk, i: number, f: (a: A) => B): Option>; }; /** * Apply a function to the element at the specified index, creating a new `Chunk`, * or returning the input if the index is out of bounds. * * @since 1.0.0 */ export declare const modify: { (i: number, f: (a: A) => B): (self: Chunk) => Chunk; (self: Chunk, i: number, f: (a: A) => B): Chunk; }; /** * Change the element at the specified index, creating a new `Chunk`, * or returning the input if the index is out of bounds. * * @since 1.0.0 */ export declare const replace: { (i: number, b: B): (self: Chunk) => Chunk; (self: Chunk, i: number, b: B): Chunk; }; /** * @since 1.0.0 */ export declare const replaceOption: { (i: number, b: B): (self: Chunk) => Option>; (self: Chunk, i: number, b: B): Option>; }; /** * Return a Chunk of length n with element i initialized with f(i). * * **Note**. `n` is normalized to an integer >= 1. * * @category constructors * @since 1.0.0 */ export declare const makeBy: { (f: (i: number) => A): (n: number) => NonEmptyChunk; (n: number, f: (i: number) => A): NonEmptyChunk; }; /** * Create a non empty `Chunk` containing a range of integers, including both endpoints. * * @category constructors * @since 1.0.0 */ export declare const range: (start: number, end: number) => NonEmptyChunk; /** * Returns a function that checks if a `Chunk` contains a given value using the default `Equivalence`. * * @category elements * @since 1.0.0 */ export declare const contains: { (a: A): (self: Chunk) => boolean; (self: Chunk, a: A): boolean; }; /** * Returns a function that checks if a `Chunk` 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: Chunk) => boolean; (self: Chunk, a: A): boolean; }; /** * 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: Chunk) => Option; (predicate: Predicate): (self: Chunk) => Option; (self: Chunk, refinement: Refinement): Option; (self: Chunk, predicate: Predicate): Option; }; /** * Return the first index for which a predicate holds. * * @category elements * @since 1.0.0 */ export declare const findFirstIndex: { (predicate: Predicate): (self: Chunk) => Option; (self: Chunk, 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: Chunk) => Option; (predicate: Predicate): (self: Chunk) => Option; (self: Chunk, refinement: Refinement): Option; (self: Chunk, 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: Chunk) => Option; (self: Chunk, predicate: Predicate): Option; }; /** * Check if a predicate holds true for every `Chunk` element. * * @category elements * @since 1.0.0 */ export declare const every: { (refinement: Refinement): (self: Chunk) => self is Chunk; (predicate: Predicate): (self: Chunk) => boolean; (self: Chunk, refinement: Refinement): self is Chunk; (self: Chunk, predicate: Predicate): boolean; }; /** * Check if a predicate holds true for some `Chunk` element. * * @category elements * @since 1.0.0 */ export declare const some: { (predicate: Predicate): (self: Chunk) => self is NonEmptyChunk; (self: Chunk, predicate: Predicate): self is NonEmptyChunk; }; /** * Joins the elements together with "sep" in the middle. * * @category folding * @since 1.0.0 */ export declare const join: { (sep: string): (self: Chunk) => string; (self: Chunk, sep: string): string; }; /** * @category folding * @since 1.0.0 */ export declare const reduce: { (b: B, f: (b: B, a: A, i: number) => B): (self: Chunk) => B; (self: Chunk, 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: Chunk) => B; (self: Chunk, b: B, f: (b: B, a: A, i: number) => B): B; }; export {}; //# sourceMappingURL=Chunk.d.ts.map