/** * @since 1.0.0 */ import type { Either } from "@fp-ts/core/Either"; import type { TypeLambda } from "@fp-ts/core/HKT"; import type { Option } from "@fp-ts/core/Option"; import type { Predicate, Refinement } from "@fp-ts/core/Predicate"; import type { Order } from "@fp-ts/core/typeclass/Order"; import * as Equal from "@fp-ts/data/Equal"; import type { NonEmptyIterable } from "@fp-ts/data/NonEmpty"; declare const TypeId: unique symbol; /** * @since 1.0.0 * @category symbol */ export type TypeId = typeof TypeId; /** * @category model * @since 1.0.0 */ export interface NonEmptyChunk extends Chunk, NonEmptyIterable { } /** * @since 1.0.0 * @category models */ export interface Chunk extends Iterable, Equal.Equal { readonly _id: TypeId; readonly length: number; get array(): ReadonlyArray; /** * @since 1.0.0 */ toReadonlyArray(this: Chunk): ReadonlyArray; /** * @since 1.0.0 */ isNonEmpty(this: Chunk): this is NonEmptyChunk; /** * @since 1.0.0 */ isEmpty(this: Chunk): boolean; /** * @since 1.0.0 */ map(this: Chunk, f: (a: A) => B): Chunk; /** * @since 1.0.0 */ flatMap(this: Chunk, f: (a: A) => Chunk): Chunk; /** * @since 1.0.0 */ forEach(this: Chunk, f: (a: A) => void): void; /** * @since 1.0.0 */ append(this: Chunk, b: B): Chunk; /** * @since 1.0.0 */ prepend(this: Chunk, b: B): Chunk; /** * @since 1.0.0 */ concat(this: Chunk, that: Chunk): Chunk; /** * @since 1.0.0 */ get(this: Chunk, index: number): Option; /** * @since 1.0.0 */ unsafeGet(this: Chunk, index: number): A; } /** * @since 1.0.0 * @category type lambdas */ export interface ChunkTypeLambda extends TypeLambda { readonly type: Chunk; } /** * Checks if `u` is a `Chunk` * * @since 1.0.0 * @category constructors */ export declare const isChunk: { (u: Iterable): u is Chunk; (u: unknown): u is Chunk; }; /** * @since 1.0.0 * @category constructors */ export declare const empty: () => Chunk; /** * Converts from an `Iterable` * * @since 1.0.0 * @category conversions */ export declare const fromIterable: (self: Iterable) => Chunk; /** * Converts to a `ReadonlyArray` * * @since 1.0.0 * @category conversions */ export declare const toReadonlyArray: (self: Chunk) => readonly A[]; /** * This function provides a safe way to read a value at a particular index from a `Chunk`. * * @since 1.0.0 * @category elements */ export declare const get: ((self: Chunk, index: number) => Option) & ((index: number) => (self: Chunk) => 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; /** * Gets an element unsafely, will throw on out of bounds * * @since 1.0.0 * @category unsafe */ export declare const unsafeGet: ((self: Chunk, index: number) => A) & ((index: number) => (self: Chunk) => A_1); /** * Appends the value to the chunk * * @since 1.0.0 * @category mutations */ export declare const append: ((self: Chunk, a: A2) => Chunk) & ((a: A2_1) => (self: Chunk) => Chunk); /** * Prepends the value to the chunk * * @since 1.0.0 * @category mutations */ export declare const prepend: ((self: Chunk, elem: B) => Chunk) & ((elem: B_1) => (self: Chunk) => Chunk); /** * Takes the first up to `n` elements from the chunk * * @since 1.0.0 * @category mutations */ export declare const take: ((self: Chunk, n: number) => Chunk) & ((n: number) => (self: Chunk) => Chunk); /** * Drops the first up to `n` elements from the chunk * * @since 1.0.0 * @category mutations */ export declare const drop: ((self: Chunk, n: number) => Chunk) & ((n: number) => (self: Chunk) => Chunk); /** * Drops the last `n` elements. * * @since 1.0.0 * @category mutations */ export declare const dropRight: ((self: Chunk, n: number) => Chunk) & ((n: number) => (self: Chunk) => Chunk); /** * Drops all elements so long as the predicate returns true. * * @since 1.0.0 * @category mutations */ export declare const dropWhile: ((self: Chunk, f: (a: A) => boolean) => Chunk) & ((f: (a: A_1) => boolean) => (self: Chunk) => Chunk); /** * @category mutations * @since 1.0.0 */ export declare const prependAllNonEmpty: { (self: Chunk, that: NonEmptyChunk): NonEmptyChunk; (self: NonEmptyChunk, that: Chunk): NonEmptyChunk; } & { (that: NonEmptyChunk): (self: Chunk) => NonEmptyChunk; (that: Chunk): (self: NonEmptyChunk) => NonEmptyChunk; }; /** * Concatenates the two chunks * * @since 1.0.0 * @category mutations */ export declare const concat: ((self: Chunk, that: Chunk) => Chunk) & ((that: Chunk) => (self: Chunk) => Chunk); /** * Compares the two chunks of equal length using the specified function * * @since 1.0.0 * @category elements */ export declare const correspondsTo: ((self: Chunk, that: Chunk, f: (a: A, b: B) => boolean) => boolean) & ((that: Chunk, f: (a: A_1, b: B_1) => boolean) => (self: Chunk) => boolean); /** * Returns a filtered and mapped subset of the elements. * * @since 1.0.0 * @category filtering */ export declare const filterMap: ((self: Iterable, f: (a: A) => Option) => Chunk) & ((f: (a: A_1) => Option) => (self: Iterable) => Chunk); /** * Returns a filtered and mapped subset of the elements. * * @since 1.0.0 * @category filtering */ export declare const filter: { (self: Chunk, refinement: Refinement): Chunk; (self: Chunk, predicate: Predicate): Chunk; } & { (refinement: Refinement): (self: Chunk) => Chunk; (predicate: Predicate): (self: Chunk) => Chunk; }; /** * Returns a filtered and mapped subset of the elements. * * @since 1.0.0 * @category filtering */ export declare const filterMapWithIndex: ((self: Iterable, f: (a: A, i: number) => Option) => Chunk) & ((f: (a: A_1, i: number) => Option) => (self: Iterable) => 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: ((self: Iterable, f: (a: A) => Option) => Chunk) & ((f: (a: A_1) => Option) => (self: Iterable) => Chunk); /** * Tests whether a value is a member of a `Chunk`. * * @since 1.0.0 * @category elements */ export declare const elem: ((self: Chunk, b: B) => boolean) & ((b: B_1) => (self: Chunk) => boolean); /** * Filter out optional values * * @since 1.0.0 * @category filtering */ export declare const compact: (self: Iterable>) => Chunk; /** * Deduplicates adjacent elements that are identical. * * @since 1.0.0 * @category filtering */ export declare const dedupeAdjacent: (self: Chunk) => Chunk; /** * Check if a predicate holds true for any `Chunk` member. * * @since 1.0.0 * @category elements */ export declare const some: ((self: Chunk, f: Predicate) => boolean) & ((f: Predicate) => (self: Chunk) => boolean); /** * Check if a predicate holds true for every `Chunk` member. * * @since 1.0.0 * @category elements */ export declare const every: ((self: Chunk, f: Predicate) => boolean) & ((f: Predicate) => (self: Chunk) => boolean); /** * Find the first element which satisfies a predicate (or a refinement) function. * * @since 1.0.0 * @category elements */ export declare const findFirst: { (self: Chunk, refinement: Refinement): Option; (self: Chunk, predicate: Predicate): Option; } & { (refinement: Refinement): (self: Chunk) => Option; (predicate: Predicate): (self: Chunk) => Option; }; /** * Find the first index for which a predicate holds * * @since 1.0.0 * @category elements */ export declare const findFirstIndex: ((self: Chunk, f: Predicate) => Option) & ((f: Predicate) => (self: Chunk) => Option); /** * Find the first index for which a predicate holds * * @since 1.0.0 * @category elements */ export declare const findLastIndex: ((self: Chunk, f: Predicate) => Option) & ((f: Predicate) => (self: Chunk) => Option); /** * Find the last element which satisfies a predicate function * * @since 1.0.0 * @category elements */ export declare const findLast: { (self: Chunk, f: Refinement): Option; (self: Chunk, f: Predicate): Option; } & { (f: Refinement): (self: Chunk) => Option; (f: Predicate): (self: Chunk) => Option; }; /** * Returns a chunk with the elements mapped by the specified function. * * @since 1.0.0 * @category sequencing */ export declare const flatMap: ((self: Chunk, f: (a: A) => Chunk) => Chunk) & ((f: (a: A_1) => Chunk) => (self: Chunk) => Chunk); /** * 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; /** * Iterate over the chunk applying `f`. * * @since 1.0.0 * @category elements */ export declare const forEach: ((self: Chunk, f: (a: A) => void) => void) & ((f: (a: A_1) => void) => (self: Chunk) => void); /** * Groups elements in chunks of up to `n` elements. * * @since 1.0.0 * @category elements */ export declare const chunksOf: ((self: Chunk, n: number) => Chunk>) & ((n: number) => (self: Chunk) => Chunk>); /** * Returns the first element of this chunk if it exists. * * @since 1.0.0 * @category elements */ export declare const head: (self: Chunk) => Option; /** * 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: ((self: Chunk, that: Chunk) => Chunk) & ((that: Chunk) => (self: 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; /** * Folds over the elements in this chunk from the left. * * @since 1.0.0 * @category folding */ export declare const reduce: ((self: Chunk, b: B, f: (s: B, a: A) => B) => B) & ((b: B_1, f: (s: B_1, a: A_1) => B_1) => (self: Chunk) => B_1); /** * Folds over the elements in this chunk from the left. * * @since 1.0.0 * @category folding */ export declare const reduceWithIndex: ((self: Chunk, b: B, f: (b: B, a: A, i: number) => B) => B) & ((b: B_1, f: (b: B_1, a: A_1, i: number) => B_1) => (self: Chunk) => B_1); /** * Folds over the elements in this chunk from the right. * * @since 1.0.0 * @category folding */ export declare const reduceRight: ((self: Chunk, b: B, f: (b: B, a: A) => B) => B) & ((b: B_1, f: (b: B_1, a: A_1) => B_1) => (self: Chunk) => B_1); /** * Folds over the elements in this chunk from the right. * * @since 1.0.0 * @category folding */ export declare const reduceRightWithIndex: ((self: Chunk, b: B, f: (b: B, a: A, i: number) => B) => B) & ((b: B_1, f: (b: B_1, a: A_1, i: number) => B_1) => (self: Chunk) => B_1); /** * Joins the elements together with "sep" in the middle. * * @since 1.0.0 * @category folding */ export declare const join: ((self: Chunk, sep: string) => string) & ((sep: string) => (self: Chunk) => string); /** * Returns the last element of this chunk if it exists. * * @since 1.0.0 * @category elements */ export declare const last: (self: Chunk) => Option; /** * Builds a `NonEmptyChunk` from an non-empty collection of elements. * * @since 1.0.0 * @category constructors */ export declare const make: (...as: As) => NonEmptyChunk; /** * Builds a `NonEmptyChunk` from a single element. * * @since 1.0.0 * @category constructors */ export declare const of: (a: A) => NonEmptyChunk; /** * Return a Chunk of length n with element i initialized with f(i). * * **Note**. `n` is normalized to an integer >= 1. * * @since 1.0.0 * @category constructors */ export declare const makeBy: ((n: number, f: (i: number) => A) => NonEmptyChunk) & ((f: (i: number) => A_1) => (n: number) => NonEmptyChunk); /** * Returns an effect whose success is mapped by the specified f function. * * @since 1.0.0 * @category mapping */ export declare const map: ((self: Chunk, f: (a: A) => B) => Chunk) & ((f: (a: A_1) => B_1) => (self: Chunk) => Chunk); /** * Returns an effect whose success is mapped by the specified f function. * * @since 1.0.0 * @category mapping */ export declare const mapWithIndex: ((self: Chunk, f: (a: A, i: number) => B) => Chunk) & ((f: (a: A_1, i: number) => B_1) => (self: Chunk) => Chunk); /** * Statefully maps over the chunk, producing new elements of type `B`. * * @since 1.0.0 * @category folding */ export declare const mapAccum: ((self: Chunk, s: S, f: (s: S, a: A) => readonly [S, B]) => readonly [S, Chunk]) & ((s: S_1, f: (s: S_1, a: A_1) => readonly [S_1, B_1]) => (self: Chunk) => readonly [S_1, Chunk]); /** * Separate elements based on a predicate that also exposes the index of the element. * * @category filtering * @since 1.0.0 */ export declare const partitionWithIndex: { (self: Chunk, refinement: (a: A, i: number) => a is B): readonly [Chunk, Chunk]; (self: Chunk, predicate: (a: A_1, i: number) => boolean): readonly [Chunk, Chunk]; } & { (refinement: (a: A_2, i: number) => a is B_2): (self: Chunk) => readonly [Chunk, Chunk]; (predicate: (a: A_3, i: number) => boolean): (self: Chunk) => readonly [Chunk, Chunk]; }; /** * Separate elements based on a predicate. * * @category filtering * @since 1.0.0 */ export declare const partition: { (self: Chunk, refinement: Refinement): readonly [Chunk, Chunk]; (self: Chunk, predicate: Predicate): readonly [Chunk, Chunk]; } & { (refinement: Refinement): (self: Chunk) => readonly [Chunk, Chunk]; (predicate: Predicate): (self: Chunk) => readonly [Chunk, Chunk]; }; /** * Partitions the elements of this chunk into two chunks using f. * * @category filtering * @since 1.0.0 */ export declare const partitionMap: ((self: Chunk, f: (a: A) => Either) => readonly [Chunk, Chunk]) & ((f: (a: A_1) => Either) => (self: Chunk) => readonly [Chunk, Chunk]); /** * Partitions the elements of this chunk into two chunks. * * @category filtering * @since 1.0.0 */ export declare const separate: (self: Chunk>) => readonly [Chunk, Chunk]; /** * 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; /** * Reverse a Chunk, creating a new Chunk. * * @since 1.0.0 * @category elements */ export declare const reverse: (self: 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: ((self: Chunk, O: Order) => Chunk) & ((O: Order) => (self: Chunk) => Chunk); /** * Returns two splits of this chunk at the specified index. * * @since 1.0.0 * @category elements */ export declare const splitAt: ((self: Chunk, n: number) => readonly [Chunk, Chunk]) & ((n: number) => (self: Chunk) => readonly [Chunk, Chunk]); /** * Splits this chunk into `n` equally sized chunks. * * @since 1.0.0 * @category elements */ export declare const split: ((self: Chunk, n: number) => Chunk>) & ((n: number) => (self: Chunk) => Chunk>); /** * Splits this chunk on the first element that matches this predicate. * * @since 1.0.0 * @category elements */ export declare const splitWhere: ((self: Chunk, f: Predicate) => readonly [Chunk, Chunk]) & ((f: Predicate) => (self: Chunk) => readonly [Chunk, Chunk]); /** * Returns every elements after the first. * * @since 1.0.0 * @category elements */ export declare const tail: (self: Chunk) => Option>; /** * Takes the last `n` elements. * * @since 1.0.0 * @category elements */ export declare const takeRight: ((self: Chunk, n: number) => Chunk) & ((n: number) => (self: Chunk) => Chunk); /** * Takes all elements so long as the predicate returns true. * * @since 1.0.0 * @category elements */ export declare const takeWhile: ((self: Chunk, f: Predicate) => Chunk) & ((f: Predicate) => (self: Chunk) => Chunk); /** * Constructs a `Chunk` by repeatedly applying the function `f` as long as it * returns `Some`. * * @since 1.0.0 * @category elements */ export declare const unfold: (s: S, f: (s: S) => Option) => Chunk; /** * Creates a Chunks of unique values, in order, from all given Chunks. * * @since 1.0.0 * @category elements */ export declare const union: ((self: Chunk, that: Chunk) => Chunk) & ((that: Chunk) => (self: 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; /** * Returns the first element of this chunk. * * @since 1.0.0 * @category unsafe */ export declare const unsafeHead: (self: Chunk) => A; /** * Returns the last element of this chunk. * * @since 1.0.0 * @category unsafe */ export declare const unsafeLast: (self: Chunk) => A; /** * Takes an array of pairs and return two corresponding arrays. * * Note: The function is reverse of `zip`. * * @since 1.0.0 * @category elements */ export declare const unzip: (as: Chunk) => readonly [Chunk, Chunk]; /** * Zips this chunk pointwise with the specified chunk. * * @since 1.0.0 * @category elements */ export declare const zip: ((self: Chunk, that: Chunk) => Chunk) & ((that: Chunk) => (self: Chunk) => Chunk); /** * Zips this chunk pointwise with the specified chunk using the specified combiner. * * @since 1.0.0 * @category elements */ export declare const zipWith: ((self: Chunk, that: Chunk, f: (a: A, b: B) => C) => Chunk) & ((that: Chunk, f: (a: A_1, b: B_1) => C_1) => (self: Chunk) => Chunk); /** * Zips this chunk pointwise with the specified chunk to produce a new chunk with * pairs of elements from each chunk, filling in missing values from the * shorter chunk with `None`. The returned chunk will have the length of the * longer chunk. * * @since 1.0.0 * @category elements */ export declare const zipAll: ((self: Chunk, that: Chunk) => Chunk, Option]>) & ((that: Chunk) => (self: Chunk) => Chunk, Option]>); /** * Zips with chunk with the specified chunk to produce a new chunk with * pairs of elements from each chunk combined using the specified function * `both`. If one chunk is shorter than the other uses the specified * function `left` or `right` to map the element that does exist to the * result type. * * @since 1.0.0 * @category elements */ export declare const zipAllWith: ((self: Chunk, that: Chunk, f: (a: A, b: B) => C, left: (a: A) => D, right: (b: B) => E) => Chunk) & ((that: Chunk, f: (a: A_1, b: B_1) => C_1, left: (a: A_1) => D_1, right: (b: B_1) => E_1) => (self: Chunk) => Chunk); /** * Zips this chunk crosswise with the specified chunk using the specified combiner. * * @since 1.0.0 * @category elements */ export declare const crossWith: ((self: Chunk, that: Chunk, f: (a: A, b: B) => C) => Chunk) & ((that: Chunk, f: (a: A_1, b: B_1) => C_1) => (self: Chunk) => Chunk); /** * Zips this chunk crosswise with the specified chunk. * * @since 1.0.0 * @category elements */ export declare const cross: ((self: Chunk, that: Chunk) => Chunk) & ((that: Chunk) => (self: Chunk) => Chunk); /** * Zips this chunk with the index of every element, starting from the initial * index value. * * @category elements * @since 1.0.0 */ export declare const zipWithIndex: (self: Chunk) => Chunk; /** * Zips this chunk with the index of every element, starting from the initial * index value. * * @category elements * @since 1.0.0 */ export declare const zipWithIndexOffset: ((self: Chunk, offset: number) => Chunk<[A, number]>) & ((offset: number) => (self: Chunk) => Chunk<[A_1, number]>); /** * Delete the element at the specified index, creating a new `Chunk`, * or returning the input if the index is out of bounds. * * @category mutations * @since 1.0.0 */ export declare const remove: ((self: Chunk, i: number) => Chunk) & ((i: number) => (self: Chunk) => Chunk); /** * Change the element at the specified index, creating a new `Chunk`, * or returning the input if the index is out of bounds. * * @category mutations * @since 1.0.0 */ export declare const replace: ((self: Chunk, i: number, b: B) => Chunk) & ((i: number, b: B_1) => (self: Chunk) => Chunk); /** * @category mutations * @since 1.0.0 */ export declare const replaceOption: ((self: Chunk, i: number, b: B) => Option>) & ((i: number, b: B_1) => (self: Chunk) => 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. * * @category mutations * @since 1.0.0 */ export declare const modify: ((self: Chunk, i: number, f: (a: A) => B) => Chunk) & ((i: number, f: (a: A_1) => B_1) => (self: Chunk) => Chunk); /** * @category mutations * @since 1.0.0 */ export declare const modifyOption: ((self: Chunk, i: number, f: (a: A) => B) => Option>) & ((i: number, f: (a: A_1) => B_1) => (self: Chunk) => Option>); /** * Returns the first element of this non empty chunk. * * @since 1.0.0 * @category elements */ export declare const headNonEmpty: (self: NonEmptyChunk) => A; /** * Returns every elements after the first. * * @since 1.0.0 * @category elements */ export declare const tailNonEmpty: (self: NonEmptyChunk) => Chunk; export {}; //# sourceMappingURL=Chunk.d.ts.map