@arthurgubaidullin/nx-embed-dependencies
Version:
This plugin for [Nx](https://nx.dev) helps injecting local dependencies into a package.
1,490 lines • 71 kB
TypeScript
/**
* The Array module provides tools for working with Typescript's Array<T> type in a functional way.
*
* In functional jargon, this module provides a monadic interface over Typescript's Array<T>.
*
* @since 2.0.0
*/
import { Alt1 } from './Alt'
import { Alternative1 } from './Alternative'
import { Applicative1 } from './Applicative'
import { Apply1 } from './Apply'
import { Chain1 } from './Chain'
import { ChainRec1 } from './ChainRec'
import { Compactable1 } from './Compactable'
import { Either } from './Either'
import { Eq } from './Eq'
import { Extend1 } from './Extend'
import { Filterable1 } from './Filterable'
import { FilterableWithIndex1, PredicateWithIndex, RefinementWithIndex } from './FilterableWithIndex'
import { Foldable1 } from './Foldable'
import { FoldableWithIndex1 } from './FoldableWithIndex'
import { FromEither1 } from './FromEither'
import { Lazy } from './function'
import { Functor1 } from './Functor'
import { FunctorWithIndex1 } from './FunctorWithIndex'
import { Magma } from './Magma'
import { Monad1 } from './Monad'
import { Monoid } from './Monoid'
import * as NEA from './NonEmptyArray'
import { Option } from './Option'
import { Ord } from './Ord'
import { Pointed1 } from './Pointed'
import { Predicate } from './Predicate'
import { Refinement } from './Refinement'
import { Semigroup } from './Semigroup'
import { Separated } from './Separated'
import { Show } from './Show'
import { PipeableTraverse1, Traversable1 } from './Traversable'
import { PipeableTraverseWithIndex1, TraversableWithIndex1 } from './TraversableWithIndex'
import { Unfoldable1 } from './Unfoldable'
import { PipeableWilt1, PipeableWither1, Witherable1 } from './Witherable'
import { Zero1 } from './Zero'
import NonEmptyArray = NEA.NonEmptyArray
/**
* Test whether an array is empty
*
* @example
* import { isEmpty } from 'fp-ts/Array'
*
* assert.strictEqual(isEmpty([]), true)
* assert.strictEqual(isEmpty(['a']), false)
*
* @category refinements
* @since 2.0.0
*/
export declare const isEmpty: <A>(as: A[]) => as is []
/**
* Test whether an array is non empty narrowing down the type to `NonEmptyArray<A>`
*
* @example
* import { isNonEmpty } from 'fp-ts/Array'
*
* assert.strictEqual(isNonEmpty([]), false)
* assert.strictEqual(isNonEmpty(['a']), true)
*
* @category refinements
* @since 2.0.0
*/
export declare const isNonEmpty: <A>(as: Array<A>) => as is NonEmptyArray<A>
/**
* Prepend an element to the front of a `Array`, creating a new `NonEmptyArray`.
*
* @example
* import { prepend } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4])
*
* @since 2.10.0
*/
export declare const prepend: <A>(head: A) => (tail: Array<A>) => NEA.NonEmptyArray<A>
/**
* Less strict version of [`prepend`](#prepend).
*
* @example
* import { prependW } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([2, 3, 4], prependW("a")), ["a", 2, 3, 4]);
*
* @since 2.11.0
*/
export declare const prependW: <A, B>(head: B) => (tail: Array<A>) => NEA.NonEmptyArray<A | B>
/**
* Append an element to the end of a `Array`, creating a new `NonEmptyArray`.
*
* @example
* import { append } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4])
*
* @since 2.10.0
*/
export declare const append: <A>(end: A) => (init: Array<A>) => NEA.NonEmptyArray<A>
/**
* Less strict version of [`append`](#append).
*
* @example
* import { appendW } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2, 3], appendW("d")), [1, 2, 3, "d"]);
*
* @since 2.11.0
*/
export declare const appendW: <A, B>(end: B) => (init: Array<A>) => NEA.NonEmptyArray<A | B>
/**
* Return a `Array` of length `n` with element `i` initialized with `f(i)`.
*
* **Note**. `n` is normalized to a non negative integer.
*
* @example
* import { makeBy } from 'fp-ts/Array'
*
* const double = (i: number): number => i * 2
* assert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8])
* assert.deepStrictEqual(makeBy(-3, double), [])
* assert.deepStrictEqual(makeBy(4.32164, double), [0, 2, 4, 6])
*
* @category constructors
* @since 2.0.0
*/
export declare const makeBy: <A>(n: number, f: (i: number) => A) => A[]
/**
* Create a `Array` containing a value repeated the specified number of times.
*
* **Note**. `n` is normalized to a non negative integer.
*
* @example
* import { replicate } from 'fp-ts/Array'
*
* assert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a'])
* assert.deepStrictEqual(replicate(-3, 'a'), [])
* assert.deepStrictEqual(replicate(2.985647, 'a'), ['a', 'a'])
*
* @category constructors
* @since 2.0.0
*/
export declare const replicate: <A>(n: number, a: A) => A[]
/**
* Create an array with one element, if the element satisfies the predicate, otherwise
* it returns an empty array.
*
* @example
* import { fromPredicate } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
* import { isString } from "fp-ts/lib/string";
*
* assert.deepStrictEqual(pipe("a", fromPredicate(isString)), ["a"]);
* assert.deepStrictEqual(pipe(7, fromPredicate(isString)), []);
*
* assert.deepStrictEqual(pipe(7, fromPredicate((x)=> x > 0)), [7]);
* assert.deepStrictEqual(pipe(-3, fromPredicate((x)=> x > 0)), []);
*
* @category lifting
* @since 2.11.0
*/
export declare function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => Array<B>
export declare function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => Array<B>
export declare function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Array<A>
/**
* Create an array from an `Option`. The resulting array will contain the content of the
* `Option` if it is `Some` and it will be empty if the `Option` is `None`.
*
* @example
* import { fromOption } from 'fp-ts/Array'
* import { option } from "fp-ts";
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe(option.some("a"), fromOption),["a"])
* assert.deepStrictEqual(pipe(option.none, fromOption),[])
*
* @category conversions
* @since 2.11.0
*/
export declare const fromOption: <A>(fa: Option<A>) => Array<A>
/**
* Create an array from an `Either`. The resulting array will contain the content of the
* `Either` if it is `Right` and it will be empty if the `Either` is `Left`.
*
* @example
* import { fromEither } from 'fp-ts/Array'
* import { either } from "fp-ts";
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe(either.right("r"), fromEither), ["r"]);
* assert.deepStrictEqual(pipe(either.left("l"), fromEither), []);
*
* @category conversions
* @since 2.11.0
*/
export declare const fromEither: <A>(fa: Either<unknown, A>) => Array<A>
/**
* Less strict version of [`match`](#match).
*
* The `W` suffix (short for **W**idening) means that the handler return types will be merged.
*
* @example
* import { matchW } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* const matcherW = matchW(
* () => "No elements",
* (as) => as.length
* );
* assert.deepStrictEqual(pipe([1, 2, 3, 4], matcherW), 4);
* assert.deepStrictEqual(pipe([], matcherW), "No elements");
*
* @category pattern matching
* @since 2.11.0
*/
export declare const matchW: <B, A, C>(
onEmpty: Lazy<B>,
onNonEmpty: (as: NEA.NonEmptyArray<A>) => C
) => (as: A[]) => B | C
/**
* Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise
* it passes the array to `onNonEmpty` and returns the result.
*
* @example
* import { match } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* const matcher = match(
* () => "No elements",
* (as) => `Found ${as.length} element(s)`
* );
* assert.deepStrictEqual(pipe([1, 2, 3, 4], matcher), "Found 4 element(s)");
* assert.deepStrictEqual(pipe([], matcher), "No elements");
*
* @category pattern matching
* @since 2.11.0
*/
export declare const match: <B, A>(onEmpty: Lazy<B>, onNonEmpty: (as: NonEmptyArray<A>) => B) => (as: Array<A>) => B
/**
* Less strict version of [`matchLeft`](#matchleft). It will work when `onEmpty` and
* `onNonEmpty` have different return types.
*
* @example
* import { matchLeftW } from 'fp-ts/Array'
*
* const f = matchLeftW(
* () => 0,
* (head: string, tail: string[]) => `Found "${head}" followed by ${tail.length} elements`
* );
* assert.strictEqual(f(["a", "b", "c"]), 'Found "a" followed by 2 elements');
* assert.strictEqual(f([]), 0);
*
* @category pattern matching
* @since 2.11.0
*/
export declare const matchLeftW: <B, A, C>(
onEmpty: Lazy<B>,
onNonEmpty: (head: A, tail: A[]) => C
) => (as: A[]) => B | C
/**
* Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise
* it passes the array to `onNonEmpty` broken into its first element and remaining elements.
*
* @example
* import { matchLeft } from 'fp-ts/Array'
*
* const len: <A>(as: Array<A>) => number = matchLeft(() => 0, (_, tail) => 1 + len(tail))
* assert.strictEqual(len([1, 2, 3]), 3)
*
* @category pattern matching
* @since 2.10.0
*/
export declare const matchLeft: <B, A>(
onEmpty: Lazy<B>,
onNonEmpty: (head: A, tail: Array<A>) => B
) => (as: Array<A>) => B
/**
* Alias of [`matchLeft`](#matchleft).
*
* @category pattern matching
* @since 2.0.0
*/
export declare const foldLeft: <A, B>(
onEmpty: Lazy<B>,
onNonEmpty: (head: A, tail: Array<A>) => B
) => (as: Array<A>) => B
/**
* Less strict version of [`matchRight`](#matchright). It will work when `onEmpty` and
* `onNonEmpty` have different return types.
*
* @example
* import { matchRightW } from 'fp-ts/Array'
*
* const f = matchRightW(
* () => 0,
* (head: string[], tail: string) => `Found ${head.length} elements folllowed by "${tail}"`
* );
* assert.strictEqual(f(["a", "b", "c"]), 'Found 2 elements folllowed by "c"');
* assert.strictEqual(f([]), 0);
*
* @category pattern matching
* @since 2.11.0
*/
export declare const matchRightW: <B, A, C>(
onEmpty: Lazy<B>,
onNonEmpty: (init: A[], last: A) => C
) => (as: A[]) => B | C
/**
* Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise
* it passes the array to `onNonEmpty` broken into its initial elements and the last element.
*
* @example
* import { matchRight } from 'fp-ts/Array'
*
* const len: <A>(as: Array<A>) => number = matchRight(
* () => 0,
* (head, _) => 1 + len(head)
* );
* assert.strictEqual(len([1, 2, 3]), 3);
*
* @category pattern matching
* @since 2.10.0
*/
export declare const matchRight: <B, A>(
onEmpty: Lazy<B>,
onNonEmpty: (init: Array<A>, last: A) => B
) => (as: Array<A>) => B
/**
* Alias of [`matchRight`](#matchright).
*
* @category pattern matching
* @since 2.0.0
*/
export declare const foldRight: <A, B>(
onEmpty: Lazy<B>,
onNonEmpty: (init: Array<A>, last: A) => B
) => (as: Array<A>) => B
/**
* Same as [`chain`](#chain), but passing also the index to the iterating function.
*
* @example
* import { chainWithIndex, replicate } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* const f = (index: number, x: string) => replicate(2, `${x}${index}`);
* assert.deepStrictEqual(pipe(["a", "b", "c"], chainWithIndex(f)), ["a0", "a0", "b1", "b1", "c2", "c2"]);
*
* @category sequencing
* @since 2.7.0
*/
export declare const chainWithIndex: <A, B>(f: (i: number, a: A) => B[]) => (as: A[]) => B[]
/**
* Same as `reduce` but it carries over the intermediate steps
*
* @example
* import { scanLeft } from 'fp-ts/Array'
*
* assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4])
*
* @since 2.0.0
*/
export declare const scanLeft: <A, B>(b: B, f: (b: B, a: A) => B) => (as: A[]) => NEA.NonEmptyArray<B>
/**
* Fold an array from the right, keeping all intermediate results instead of only the final result
*
* @example
* import { scanRight } from 'fp-ts/Array'
*
* assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10])
*
* @since 2.0.0
*/
export declare const scanRight: <A, B>(b: B, f: (a: A, b: B) => B) => (as: A[]) => NEA.NonEmptyArray<B>
/**
* Calculate the number of elements in a `Array`.
*
* @example
* import { size } from 'fp-ts/Array'
*
* assert.strictEqual(size(["a","b","c"]),3)
*
* @since 2.10.0
*/
export declare const size: <A>(as: A[]) => number
/**
* Test whether an array contains a particular index
*
* @example
* import { isOutOfBound } from 'fp-ts/Array'
*
* assert.strictEqual(isOutOfBound(1,["a","b","c"]),false)
* assert.strictEqual(isOutOfBound(-1,["a","b","c"]),true)
* assert.strictEqual(isOutOfBound(3,["a","b","c"]),true)
*
* @since 2.0.0
*/
export declare const isOutOfBound: <A>(i: number, as: Array<A>) => boolean
/**
* This function provides a safe way to read a value at a particular index from an array.
* It returns a `none` if the index is out of bounds, and a `some` of the element if the
* index is valid.
*
* @example
* import { lookup } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2))
* assert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none)
*
* @since 2.0.0
*/
export declare const lookup: {
(i: number): <A>(as: Array<A>) => Option<A>
<A>(i: number, as: Array<A>): Option<A>
}
/**
* Get the first element in an array, or `None` if the array is empty
*
* @example
* import { head } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(head([1, 2, 3]), some(1))
* assert.deepStrictEqual(head([]), none)
*
* @since 2.0.0
*/
export declare const head: <A>(as: Array<A>) => Option<A>
/**
* Get the last element in an array, or `None` if the array is empty
*
* @example
* import { last } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(last([1, 2, 3]), some(3))
* assert.deepStrictEqual(last([]), none)
*
* @since 2.0.0
*/
export declare const last: <A>(as: Array<A>) => Option<A>
/**
* Get all but the first element of an array, creating a new array, or `None` if the array is empty
*
* @example
* import { tail } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(tail([1, 2, 3]), some([2, 3]))
* assert.deepStrictEqual(tail([]), none)
*
* @since 2.0.0
*/
export declare const tail: <A>(as: A[]) => Option<A[]>
/**
* Get all but the last element of an array, creating a new array, or `None` if the array is empty
*
* @example
* import { init } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(init([1, 2, 3]), some([1, 2]))
* assert.deepStrictEqual(init([]), none)
*
* @since 2.0.0
*/
export declare const init: <A>(as: A[]) => Option<A[]>
/**
* Keep only a max number of elements from the start of an `Array`, creating a new `Array`.
*
* **Note**. `n` is normalized to a non negative integer.
*
* @example
* import { takeLeft } from 'fp-ts/Array'
*
* assert.deepStrictEqual(takeLeft(2)([1, 2, 3, 4, 5]), [1, 2]);
* assert.deepStrictEqual(takeLeft(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);
* assert.deepStrictEqual(takeLeft(0)([1, 2, 3, 4, 5]), []);
* assert.deepStrictEqual(takeLeft(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);
*
* @since 2.0.0
*/
export declare const takeLeft: (n: number) => <A>(as: A[]) => A[]
/**
* Keep only a max number of elements from the end of an `Array`, creating a new `Array`.
*
* **Note**. `n` is normalized to a non negative integer.
*
* @example
* import { takeRight } from 'fp-ts/Array'
*
* assert.deepStrictEqual(takeRight(2)([1, 2, 3, 4, 5]), [4, 5]);
* assert.deepStrictEqual(takeRight(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);
* assert.deepStrictEqual(takeRight(0)([1, 2, 3, 4, 5]), []);
* assert.deepStrictEqual(takeRight(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);
*
* @since 2.0.0
*/
export declare const takeRight: (n: number) => <A>(as: A[]) => A[]
/**
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new array
*
* @example
* import { takeLeftWhile } from 'fp-ts/Array'
*
* assert.deepStrictEqual(takeLeftWhile((n: number) => n % 2 === 0)([2, 4, 3, 6]), [2, 4])
*
* @since 2.0.0
*/
export declare function takeLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>
export declare function takeLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>
export declare function takeLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>
/**
* Type returned by [`spanLeft`](#spanLeft) composed of an `init` array and a `rest` array.
*
* @since 2.10.0
*/
export interface Spanned<I, R> {
init: Array<I>
rest: Array<R>
}
/**
* Split an array into two parts:
* 1. the longest initial subarray for which all elements satisfy the specified predicate
* 2. the remaining elements
*
* @example
* import { spanLeft } from 'fp-ts/Array'
*
* const isOdd = (n: number) => n % 2 === 1;
* assert.deepStrictEqual(spanLeft(isOdd)([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] });
* assert.deepStrictEqual(spanLeft(isOdd)([0, 2, 4, 5]), { init: [], rest: [0, 2, 4, 5] });
* assert.deepStrictEqual(spanLeft(isOdd)([1, 3, 5]), { init: [1, 3, 5], rest: [] });
*
* @since 2.0.0
*/
export declare function spanLeft<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Spanned<B, A>
export declare function spanLeft<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Spanned<B, B>
export declare function spanLeft<A>(predicate: Predicate<A>): (as: Array<A>) => Spanned<A, A>
/**
* Creates a new `Array` which is a copy of the input dropping a max number of elements from the start.
*
* **Note**. `n` is normalized to a non negative integer.
*
* @example
* import { dropLeft } from 'fp-ts/Array'
*
* assert.deepStrictEqual(dropLeft(2)([1, 2, 3]), [3]);
* assert.deepStrictEqual(dropLeft(5)([1, 2, 3]), []);
* assert.deepStrictEqual(dropLeft(0)([1, 2, 3]), [1, 2, 3]);
* assert.deepStrictEqual(dropLeft(-2)([1, 2, 3]), [1, 2, 3]);
*
* @since 2.0.0
*/
export declare const dropLeft: (n: number) => <A>(as: A[]) => A[]
/**
* Creates a new `Array` which is a copy of the input dropping a max number of elements from the end.
*
* **Note**. `n` is normalized to a non negative integer.
*
* @example
* import { dropRight } from 'fp-ts/Array'
*
* assert.deepStrictEqual(dropRight(2)([1, 2, 3]), [1]);
* assert.deepStrictEqual(dropRight(5)([1, 2, 3]), []);
* assert.deepStrictEqual(dropRight(0)([1, 2, 3]), [1, 2, 3]);
* assert.deepStrictEqual(dropRight(-2)([1, 2, 3]), [1, 2, 3]);
*
* @since 2.0.0
*/
export declare const dropRight: (n: number) => <A>(as: A[]) => A[]
/**
* Creates a new `Array` which is a copy of the input dropping the longest initial subarray for
* which all element satisfy the specified predicate.
*
* @example
* import { dropLeftWhile } from 'fp-ts/Array'
*
* assert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5])
*
* @since 2.0.0
*/
export declare function dropLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>
export declare function dropLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>
export declare function dropLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>
/**
* `findIndex` returns an `Option` containing the first index for which a predicate holds.
* It returns `None` if no element satisfies the predicate.
* Similar to [`findFirst`](#findFirst) but returning the index instead of the element.
*
* @example
* import { findIndex } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1))
* assert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none)
*
* @since 2.0.0
*/
export declare const findIndex: <A>(predicate: Predicate<A>) => (as: Array<A>) => Option<number>
/**
* Find the first element which satisfies a predicate (or a refinement) function.
* It returns an `Option` containing the element or `None` if not found.
*
* @example
* import { findFirst } from 'fp-ts/Array'
* import { some } from 'fp-ts/Option'
*
* type X = {
* readonly a: number
* readonly b: number
* }
*
* assert.deepStrictEqual(findFirst((x: X) => x.a === 1)([{ a: 1, b: 1 }, { a: 1, b: 2 }]), some({ a: 1, b: 1 }))
*
* @since 2.0.0
*/
export declare function findFirst<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Option<B>
export declare function findFirst<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Option<B>
export declare function findFirst<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A>
/**
* Given a selector function which takes an element and returns an option,
* this function applies the selector to each element of the array and
* returns the first `Some` result. Otherwise it returns `None`.
*
* @example
* import { findFirstMap } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* interface Person {
* readonly name: string;
* readonly age: number;
* }
*
* const persons: Array<Person> = [
* { name: "John", age: 16 },
* { name: "Mary", age: 45 },
* { name: "Joey", age: 28 },
* ];
*
* const nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name));
* const nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name));
* assert.deepStrictEqual(findFirstMap(nameOfPersonAbove18)(persons), some("Mary"));
* assert.deepStrictEqual(findFirstMap(nameOfPersonAbove70)(persons), none);
*
* @since 2.0.0
*/
export declare const findFirstMap: <A, B>(f: (a: A) => Option<B>) => (as: Array<A>) => Option<B>
/**
* Find the last element which satisfies a predicate function.
* It returns an `Option` containing the element or `None` if not found.
*
* @example
* import { findLast } from 'fp-ts/Array'
* import { some } from 'fp-ts/Option'
*
* type X = {
* readonly a: number
* readonly b: number
* }
*
* assert.deepStrictEqual(findLast((x: X) => x.a === 1)([{ a: 1, b: 1 }, { a: 1, b: 2 }]), some({ a: 1, b: 2 }))
*
* @since 2.0.0
*/
export declare function findLast<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Option<B>
export declare function findLast<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Option<B>
export declare function findLast<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A>
/**
* Given a selector function which takes an element and returns an option,
* this function applies the selector to each element of the array starting from the
* end and returns the last `Some` result. Otherwise it returns `None`.
*
* @example
* import { findLastMap } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* interface Person {
* readonly name: string;
* readonly age: number;
* }
*
* const persons: Array<Person> = [
* { name: "John", age: 16 },
* { name: "Mary", age: 45 },
* { name: "Joey", age: 28 },
* ];
*
* const nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name));
* const nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name));
* assert.deepStrictEqual(findLastMap(nameOfPersonAbove18)(persons), some("Joey"));
* assert.deepStrictEqual(findLastMap(nameOfPersonAbove70)(persons), none);
*
* @since 2.0.0
*/
export declare const findLastMap: <A, B>(f: (a: A) => Option<B>) => (as: Array<A>) => Option<B>
/**
* Returns the index of the last element of the list which matches the predicate.
* It returns an `Option` containing the index or `None` if not found.
*
* @example
* import { findLastIndex } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* interface X {
* readonly a: number
* readonly b: number
* }
* const xs: Array<X> = [{ a: 1, b: 0 }, { a: 1, b: 1 }]
* assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1))
* assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none)
*
* @since 2.0.0
*/
export declare const findLastIndex: <A>(predicate: Predicate<A>) => (as: Array<A>) => Option<number>
/**
* This function takes an array and makes a new array containing the same elements.
*
* @since 2.0.0
*/
export declare const copy: <A>(as: A[]) => A[]
/**
* Insert an element at the specified index, creating a new array,
* or returning `None` if the index is out of bounds.
*
* @example
* import { insertAt } from 'fp-ts/Array'
* import { some } from 'fp-ts/Option'
*
* assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4]))
*
* @since 2.0.0
*/
export declare const insertAt: <A>(i: number, a: A) => (as: A[]) => Option<NEA.NonEmptyArray<A>>
/**
* Change the element at the specified index, creating a new array,
* or returning `None` if the index is out of bounds.
*
* @example
* import { updateAt } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3]))
* assert.deepStrictEqual(updateAt(1, 1)([]), none)
*
* @since 2.0.0
*/
export declare const updateAt: <A>(i: number, a: A) => (as: A[]) => Option<A[]>
/**
* Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds.
*
* @example
* import { deleteAt } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3]))
* assert.deepStrictEqual(deleteAt(1)([]), none)
*
* @since 2.0.0
*/
export declare const deleteAt: (i: number) => <A>(as: A[]) => Option<A[]>
/**
* Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out
* of bounds.
*
* @example
* import { modifyAt } from 'fp-ts/Array'
* import { some, none } from 'fp-ts/Option'
*
* const double = (x: number): number => x * 2
* assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3]))
* assert.deepStrictEqual(modifyAt(1, double)([]), none)
*
* @since 2.0.0
*/
export declare const modifyAt: <A>(i: number, f: (a: A) => A) => (as: A[]) => Option<A[]>
/**
* Reverse an array, creating a new array
*
* @example
* import { reverse } from 'fp-ts/Array'
*
* assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1])
*
* @since 2.0.0
*/
export declare const reverse: <A>(as: A[]) => A[]
/**
* Takes an `Array` of `Either` and produces a new `Array` containing
* the values of all the `Right` elements in the same order.
*
* @example
* import { rights } from 'fp-ts/Array'
* import { right, left } from 'fp-ts/Either'
*
* assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2])
*
* @since 2.0.0
*/
export declare const rights: <E, A>(as: Either<E, A>[]) => A[]
/**
* Takes an `Array` of `Either` and produces a new `Array` containing
* the values of all the `Left` elements in the same order.
*
* @example
* import { lefts } from 'fp-ts/Array'
* import { left, right } from 'fp-ts/Either'
*
* assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo'])
*
* @since 2.0.0
*/
export declare const lefts: <E, A>(as: Either<E, A>[]) => E[]
/**
* Sort the elements of an array in increasing order, creating a new array
*
* @example
* import { sort } from 'fp-ts/Array'
* import * as N from 'fp-ts/number'
*
* assert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3])
*
* @since 2.0.0
*/
export declare const sort: <B>(O: Ord<B>) => <A extends B>(as: A[]) => A[]
/**
* Apply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one
* input array is short, excess elements of the longer array are discarded.
*
* @example
* import { zipWith } from 'fp-ts/Array'
*
* assert.deepStrictEqual(zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n), ['a1', 'b2', 'c3'])
*
* @since 2.0.0
*/
export declare const zipWith: <A, B, C>(fa: A[], fb: B[], f: (a: A, b: B) => C) => C[]
/**
* Takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the
* longer array are discarded
*
* @example
* import { zip } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [[1, 'a'], [2, 'b'], [3, 'c']])
*
* @since 2.0.0
*/
export declare function zip<B>(bs: Array<B>): <A>(as: Array<A>) => Array<[A, B]>
export declare function zip<A, B>(as: Array<A>, bs: Array<B>): Array<[A, B]>
/**
* The function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays
*
* @example
* import { unzip } from 'fp-ts/Array'
*
* assert.deepStrictEqual(unzip([[1, 'a'], [2, 'b'], [3, 'c']]), [[1, 2, 3], ['a', 'b', 'c']])
*
* @since 2.0.0
*/
export declare const unzip: <A, B>(as: [A, B][]) => [A[], B[]]
/**
* Creates a new `Array`, prepending an element to every member of the input `Array`.
*
* @example
* import { prependAll } from 'fp-ts/Array'
*
* assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])
*
* @since 2.10.0
*/
export declare const prependAll: <A>(middle: A) => (as: A[]) => A[]
/**
* Creates a new `Array` placing an element in between members of the input `Array`.
*
* @example
* import { intersperse } from 'fp-ts/Array'
*
* assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])
*
* @since 2.9.0
*/
export declare const intersperse: <A>(middle: A) => (as: A[]) => A[]
/**
* Creates a new `Array` rotating the input `Array` by `n` steps.
*
* @example
* import { rotate } from 'fp-ts/Array'
*
* assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])
*
* @since 2.0.0
*/
export declare const rotate: (n: number) => <A>(as: A[]) => A[]
/**
* Test if a value is a member of an `Array`. Takes a `Eq<A>` as a single
* argument which returns the function to use to search for a value of type `A` in
* an `Array<A>`.
*
* @example
* import { elem } from 'fp-ts/Array'
* import * as N from 'fp-ts/number'
* import { pipe } from 'fp-ts/function'
*
* assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(2)), true)
* assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(0)), false)
*
* @since 2.0.0
*/
export declare const elem: <A>(E: Eq<A>) => {
(a: A): (as: Array<A>) => boolean
(a: A, as: Array<A>): boolean
}
/**
* Creates a new `Array` removing duplicate elements, keeping the first occurrence of an element,
* based on a `Eq<A>`.
*
* @example
* import { uniq } from 'fp-ts/Array'
* import * as N from 'fp-ts/number'
*
* assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])
*
* @since 2.0.0
*/
export declare const uniq: <A>(E: Eq<A>) => (as: A[]) => A[]
/**
* Sort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,
* etc...
*
* @example
* import { sortBy } from 'fp-ts/Array'
* import { contramap } from 'fp-ts/Ord'
* import * as S from 'fp-ts/string'
* import * as N from 'fp-ts/number'
* import { pipe } from 'fp-ts/function'
*
* interface Person {
* readonly name: string
* readonly age: number
* }
* const byName = pipe(S.Ord, contramap((p: Person) => p.name))
* const byAge = pipe(N.Ord, contramap((p: Person) => p.age))
*
* const sortByNameByAge = sortBy([byName, byAge])
*
* const persons = [{ name: 'a', age: 1 }, { name: 'b', age: 3 }, { name: 'c', age: 2 }, { name: 'b', age: 2 }]
* assert.deepStrictEqual(sortByNameByAge(persons), [
* { name: 'a', age: 1 },
* { name: 'b', age: 2 },
* { name: 'b', age: 3 },
* { name: 'c', age: 2 }
* ])
*
* @since 2.0.0
*/
export declare const sortBy: <B>(ords: Ord<B>[]) => <A extends B>(as: A[]) => A[]
/**
* A useful recursion pattern for processing an array to produce a new array, often used for "chopping" up the input
* array. Typically chop is called with some function that will consume an initial prefix of the array and produce a
* value and the rest of the array.
*
* @example
* import { Eq } from 'fp-ts/Eq'
* import * as A from 'fp-ts/Array'
* import * as N from 'fp-ts/number'
* import { pipe } from 'fp-ts/function'
*
* const group = <A>(S: Eq<A>): ((as: Array<A>) => Array<Array<A>>) => {
* return A.chop(as => {
* const { init, rest } = pipe(as, A.spanLeft((a: A) => S.equals(a, as[0])))
* return [init, rest]
* })
* }
* assert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])
*
* @since 2.0.0
*/
export declare const chop: <A, B>(f: (as: NEA.NonEmptyArray<A>) => [B, A[]]) => (as: A[]) => B[]
/**
* Splits an `Array` into two pieces, the first piece has max `n` elements.
*
* @example
* import { splitAt } from 'fp-ts/Array'
*
* assert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4, 5]])
*
* @since 2.0.0
*/
export declare const splitAt: (n: number) => <A>(as: A[]) => [A[], A[]]
/**
* Splits an array into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of
* the array. 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 `xs`.
*
* @example
* import { chunksOf } from 'fp-ts/Array'
*
* assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])
*
* @since 2.0.0
*/
export declare const chunksOf: (n: number) => <A>(as: A[]) => NEA.NonEmptyArray<A>[]
/**
* @category lifting
* @since 2.11.0
*/
export declare const fromOptionK: <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => B[]
/**
* `Array` comprehension.
*
* ```
* [ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ]
* ```
*
* @example
* import { comprehension } from 'fp-ts/Array'
* import { tuple } from 'fp-ts/function'
*
* assert.deepStrictEqual(comprehension([[1, 2, 3], ['a', 'b']], tuple, (a, b) => (a + b.length) % 2 === 0), [
* [1, 'a'],
* [1, 'b'],
* [3, 'a'],
* [3, 'b']
* ])
*
* @since 2.0.0
*/
export declare function comprehension<A, B, C, D, R>(
input: [Array<A>, Array<B>, Array<C>, Array<D>],
f: (a: A, b: B, c: C, d: D) => R,
g?: (a: A, b: B, c: C, d: D) => boolean
): Array<R>
export declare function comprehension<A, B, C, R>(
input: [Array<A>, Array<B>, Array<C>],
f: (a: A, b: B, c: C) => R,
g?: (a: A, b: B, c: C) => boolean
): Array<R>
export declare function comprehension<A, B, R>(
input: [Array<A>, Array<B>],
f: (a: A, b: B) => R,
g?: (a: A, b: B) => boolean
): Array<R>
export declare function comprehension<A, R>(input: [Array<A>], f: (a: A) => R, g?: (a: A) => boolean): Array<R>
/**
* @since 2.11.0
*/
export declare const concatW: <B>(second: B[]) => <A>(first: A[]) => (B | A)[]
/**
* @since 2.11.0
*/
export declare const concat: <A>(second: Array<A>) => (first: Array<A>) => Array<A>
/**
* Creates an array of unique values, in order, from all given arrays using a `Eq` for equality comparisons
*
* @example
* import { union } from 'fp-ts/Array'
* import * as N from 'fp-ts/number'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2], union(N.Eq)([2, 3])), [1, 2, 3])
*
* @since 2.0.0
*/
export declare function union<A>(E: Eq<A>): {
(xs: Array<A>): (ys: Array<A>) => Array<A>
(xs: Array<A>, ys: Array<A>): Array<A>
}
/**
* Creates an array of unique values that are included in all given arrays using a `Eq` for equality
* comparisons. The order and references of result values are determined by the first array.
*
* @example
* import { intersection } from 'fp-ts/Array'
* import * as N from 'fp-ts/number'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2], intersection(N.Eq)([2, 3])), [2])
*
* @since 2.0.0
*/
export declare function intersection<A>(E: Eq<A>): {
(xs: Array<A>): (ys: Array<A>) => Array<A>
(xs: Array<A>, ys: Array<A>): Array<A>
}
/**
* Creates an array of array values not included in the other given array using a `Eq` for equality
* comparisons. The order and references of result values are determined by the first array.
*
* @example
* import { difference } from 'fp-ts/Array'
* import * as N from 'fp-ts/number'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2], difference(N.Eq)([2, 3])), [1])
*
* @since 2.0.0
*/
export declare function difference<A>(E: Eq<A>): {
(xs: Array<A>): (ys: Array<A>) => Array<A>
(xs: Array<A>, ys: Array<A>): Array<A>
}
/**
* Given an element of the base type, `of` builds an `Array` containing just that
* element of the base type (this is useful for building a `Monad`).
*
* @example
* import { of } from 'fp-ts/Array'
*
* assert.deepStrictEqual(of("a"), ["a"]);
*
* @category constructors
* @since 2.0.0
*/
export declare const of: <A>(a: A) => Array<A>
/**
* Makes an empty `Array`, useful for building a [`Monoid`](#Monoid)
*
* @since 2.7.0
*/
export declare const zero: <A>() => Array<A>
/**
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: Array<A>) => Array<B>`.
* In practice it applies the base function to each element of the array and collects the
* results in a new array.
*
* @example
* import { map } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* const f = (n: number) => n * 2;
* assert.deepStrictEqual(pipe([1, 2, 3], map(f)), [2, 4, 6]);
*
* @category mapping
* @since 2.0.0
*/
export declare const map: <A, B>(f: (a: A) => B) => (fa: Array<A>) => Array<B>
/**
* @example
* import { ap, map, of } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* // a curried function with 3 input parameteres
* const f = (s1: string) => (n: number) => (s2: string) => s1 + n + s2;
*
* // let's use `ap` to iterate `f` over an array for each input parameter
* assert.deepStrictEqual(pipe(["a", "b"], map(f), ap([1, 2]), ap(["😀", "😫", "😎"])), [
* "a1😀", "a1😫", "a1😎",
* "a2😀", "a2😫", "a2😎",
* "b1😀", "b1😫", "b1😎",
* "b2😀", "b2😫", "b2😎",
* ]);
*
* // given Array implements the Applicative interface with the `of` method,
* // we can write exactly the same thing in a more symmetric way
* // using `of` on `f` and `ap` on each array in input
* assert.deepStrictEqual(
* pipe(of(f), ap(["a", "b"]), ap([1, 2]), ap(["😀", "😫", "😎"])),
* pipe(["a", "b"], map(f), ap([1, 2]), ap(["😀", "😫", "😎"]))
* );
*
* @since 2.0.0
*/
export declare const ap: <A>(fa: Array<A>) => <B>(fab: Array<(a: A) => B>) => Array<B>
/**
* Composes computations in sequence, using the return value of one computation to
* determine the next computation.
*
* In other words it takes a function `f` that produces an array from a single element of
* the base type `A` and returns a new function which applies `f` to each element of the
* input array (like [`map`](#map)) and, instead of returning an array of arrays, concatenates the
* results into a single array (like [`flatten`](#flatten)).
*
* This is the `chain` component of the array `Monad`.
*
* @example
* import { chain, map, replicate } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* const f = (n: number) => replicate(n, `${n}`);
* assert.deepStrictEqual(pipe([1, 2, 3], map(f)), [["1"], ["2", "2"], ["3", "3", "3"]]);
* assert.deepStrictEqual(pipe([1, 2, 3], chain(f)), ["1", "2", "2", "3", "3", "3"]);
*
* @category sequencing
* @since 2.0.0
*/
export declare const chain: <A, B>(f: (a: A) => Array<B>) => (ma: Array<A>) => Array<B>
/**
* Takes an array of arrays of `A` and flattens them into an array of `A`
* by concatenating the elements of each array in order.
*
* @example
* import { flatten } from 'fp-ts/Array'
*
* assert.deepStrictEqual(flatten([["a"], ["b", "c"], ["d", "e", "f"]]), ["a", "b", "c", "d", "e", "f"]);
*
* @category sequencing
* @since 2.5.0
*/
export declare const flatten: <A>(mma: Array<Array<A>>) => Array<A>
/**
* Same as [`map`](#map), but the iterating function takes both the index and the value
* of the element.
*
* @example
* import { mapWithIndex } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* const f = (i: number, s: string) => `${s} - ${i}`;
* assert.deepStrictEqual(pipe(["a", "b", "c"], mapWithIndex(f)), ["a - 0", "b - 1", "c - 2"]);
*
* @category mapping
* @since 2.0.0
*/
export declare const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (fa: Array<A>) => Array<B>
/**
* Maps an array with an iterating function that takes the index and the value of
* each element and returns an `Option`. It keeps only the `Some` values discarding
* the `None`s.
*
* Same as [`filterMap`](#filterMap), but with an iterating function which takes also
* the index as input.
*
* @example
* import { filterMapWithIndex } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
* import { option } from "fp-ts";
*
* const f = (i: number, s: string) => (i % 2 === 1 ? option.some(s.toUpperCase()) : option.none);
* assert.deepStrictEqual(pipe(["a", "no", "neither", "b"], filterMapWithIndex(f)), ["NO", "B"]);
*
* @category filtering
* @since 2.0.0
*/
export declare const filterMapWithIndex: <A, B>(f: (i: number, a: A) => Option<B>) => (fa: A[]) => B[]
/**
* Maps an array with an iterating function that returns an `Option`
* and it keeps only the `Some` values discarding the `None`s.
*
* @example
* import { filterMap } from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
* import { option } from "fp-ts";
*
* const f = (s: string) => s.length === 1 ? option.some(s.toUpperCase()) : option.none;
* assert.deepStrictEqual(pipe(["a", "no", "neither", "b"], filterMap(f)), ["A", "B"]);
*
* @category filtering
* @since 2.0.0
*/
export declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Array<A>) => Array<B>
/**
* Compact an array of `Option`s discarding the `None` values and
* keeping the `Some` values. It returns a new array containing the values of
* the `Some` options.
*
* @example
* import { compact } from 'fp-ts/Array'
* import { option } from "fp-ts";
*
* assert.deepStrictEqual(compact([option.some("a"), option.none, option.some("b")]), ["a", "b"]);
*
* @category filtering
* @since 2.0.0
*/
export declare const compact: <A>(fa: Array<Option<A>>) => Array<A>
/**
* Separate an array of `Either`s into `Left`s and `Right`s, creating two new arrays:
* one containing all the left values and one containing all the right values.
*
* @example
* import { separate } from 'fp-ts/Array'
* import { either } from "fp-ts";
*
* assert.deepStrictEqual(separate([either.right("r1"), either.left("l1"), either.right("r2")]), {
* left: ["l1"],
* right: ["r1", "r2"],
* });
*
* @category filtering
* @since 2.0.0
*/
export declare const separate: <A, B>(fa: Either<A, B>[]) => Separated<A[], B[]>
/**
* Given an iterating function that is a `Predicate` or a `Refinement`,
* `filter` creates a new `Array` containing the elements of the original
* `Array` for which the iterating function is `true`.
*
* @example
* import { filter } from 'fp-ts/Array'
* import { isString } from "fp-ts/lib/string";
*
* assert.deepStrictEqual(filter(isString)(["a", 1, {}, "b", 5]), ["a", "b"]);
* assert.deepStrictEqual(filter((x:number) => x > 0)([-3, 1, -2, 5]), [1, 5]);
*
* @category filtering
* @since 2.0.0
*/
export declare const filter: {
<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>
<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>
<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>
}
/**
* Given an iterating function that is a `Predicate` or a `Refinement`,
* `partition` creates two new `Array`s: `right` containing the elements of the original
* `Array` for which the iterating function is `true`, `left` containing the elements
* for which it is false.
*
* @example
* import { partition } from 'fp-ts/Array'
* import { isString } from "fp-ts/lib/string";
*
* assert.deepStrictEqual(partition(isString)(["a", 1, {}, "b", 5]), { left: [1, {}, 5], right: ["a", "b"] });
* assert.deepStrictEqual(partition((x: number) => x > 0)([-3, 1, -2, 5]), { left: [-3, -2], right: [1, 5] });
*
* @category filtering
* @since 2.0.0
*/
export declare const partition: {
<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Separated<Array<A>, Array<B>>
<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Separated<Array<B>, Array<B>>
<A>(predicate: Predicate<A>): (as: Array<A>) => Separated<Array<A>, Array<A>>
}
/**
* Same as [`partition`](#partition), but passing also the index to the iterating function.
*
* @example
* import { partitionWithIndex } from 'fp-ts/Array'
*
* assert.deepStrictEqual(partitionWithIndex((index, x: number) => index < 3 && x > 0)([-2, 5, 6, 7]), {
* left: [-2, 7],
* right: [5, 6],
* });
*
* @category filtering
* @since 2.0.0
*/
export declare const partitionWithIndex: {
<A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (
as: Array<A>
) => Separated<Array<A>, Array<B>>
<A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: Array<B>) => Separated<Array<B>, Array<B>>
<A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: Array<A>) => Separated<Array<A>, Array<A>>
}
/**
* Given an iterating function that returns an `Either`,
* `partitionMap` applies the iterating function to each element and it creates two `Array`s:
* `right` containing the values of `Right` results, `left` containing the values of `Left` results.
*
* @example
* import { partitionMap } from 'fp-ts/Array'
* import { Either, left, right } from "fp-ts/lib/Either";
*
* const upperIfString = <B>(x: B): Either<B, string> =>
* typeof x === "string" ? right(x.toUpperCase()) : left(x);
* assert.deepStrictEqual(partitionMap(upperIfString)([-2, "hello", 6, 7, "world"]), {
* left: [-2, 6, 7],
* right: [ 'HELLO', 'WORLD' ],
* });
*
* @category filtering
* @since 2.0.0
*/
export declare const partitionMap: <A, B, C>(
f: (a: A) => Either<B, C>
) => (fa: Array<A>) => Separated<Array<B>, Array<C>>
/**
* Same as [`partitionMap`](#partitionMap), but passing also the index to the iterating function.
*
* @example
* import { partitionMapWithIndex } from 'fp-ts/Array'
* import { Either, left, right } from "fp-ts/lib/Either";
*
* const upperIfStringBefore3 = <B>(index: number, x: B): Either<B, string> =>
* index < 3 && typeof x === "string" ? right(x.toUpperCase()) : left(x);
* assert.deepStrictEqual(partitionMapWithIndex(upperIfStringBefore3)([-2, "hello", 6, 7, "world"]), {
* left: [-2, 6, 7, "world"],
* right: ["HELLO"],
* });
*
* @category filtering
* @since 2.0.0
*/
export declare const partitionMapWithIndex: <A, B, C>(
f: (i: number, a: A) => Either<B, C>
) => (fa: A[]) => Separated<B[], C[]>
/**
* Less strict version of [`alt`](#alt).
*
* The `W` suffix (short for **W**idening) means that the return types will be merged.
*
* @example
* import * as A from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(
* pipe(
* [1, 2, 3],
* A.altW(() => ['a', 'b'])
* ),
* [1, 2, 3, 'a', 'b']
* )
*
* @category error handling
* @since 2.9.0
*/
export declare const altW: <B>(that: Lazy<B[]>) => <A>(fa: A[]) => (B | A)[]
/**
* Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
* types of kind `* -> *`.
*
* In case of `Array` concatenates the inputs into a single array.
*
* @example
* import * as A from 'fp-ts/Array'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(
* pipe(
* [1, 2, 3],
* A.alt(() => [4, 5])
* ),
* [1, 2, 3, 4, 5]
* )
*
* @category error handling
* @since 2.0.0
*/
export declare const alt: <A>(that: Lazy<Array<A>>) => (fa: Array<A>) => Array<A>
/**
* Same as [`filter`](#filter), but passing also the index to the iterating function.
*
* @example
* import { filterWithIndex } from 'fp-ts/Array';
*
* const f = (index: number, x: number) => x > 0 && index <= 2;
* assert.deepStrictEqual(filterWithIndex(f)([-3, 1, -2, 5]), [1]);
*
* @category filtering
* @since 2.0.0
*/
export declare const filterWithIndex: {
<A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: Array<A>) => Array<B>
<A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: Array<B>) => Array<B>
<A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: Array<A>) => Array<A>
}
/**
* Given an iterating function that takes `Array<A>` as input, `extend` returns
* an array containing the results of the iterating function applied to the whole input
* `Array`, then to the input `Array` without the first element, then to the input
* `Array` without the first two elements, etc.
*
* @example
* import { extend } from 'fp-ts/Array'
*
* const f = (a: string[]) => a.join(",");
* assert.deepStrictEqual(extend(f)(["a", "b", "c"]), ["a,b,c", "b,c", "c"]);
*
* @since 2.0.0
*/
export declare const extend: <A, B>(f: (as: Array<A>) => B) => (as: Array<A>) => Array<B>
/**
* `duplicate` returns an array containing the whole input `Array`,
* then to the input `Array` dropping the first element, then to the input
* `Array` dropping the first two elements, etc.
*
* @example
* import { duplicate } from 'fp-ts/Array'
*
* assert.deepStrictEqual(duplicate(["a", "b", "c"]), [["a", "b", "c"], ["b", "c"], ["c"]]);
*
* @since 2.0.0
*/
ex