Options
All
  • Public
  • Public/Protected
  • All
Menu

Package list

@typed/list

Everything you need to work with lists/arrays.

Index

Type aliases

ArrayLikeValue

ArrayLikeValue<A>: A extends ArrayLike<infer R> ? R : never

Type parameters

  • A

NestedArray

NestedArray<A>: ReadonlyArray<A | ReadonlyArray<A>>

Type parameters

  • A

NoInfer

NoInfer<A>: A & {}

Type parameters

  • A

ReduceByArity1

ReduceByArity1<A, B>: (list: ReadonlyArray<A>) => {}

Type parameters

  • A

  • B

Type declaration

    • (list: ReadonlyArray<A>): {}
    • Parameters

      • list: ReadonlyArray<A>

      Returns {}

      • [key: string]: B

SortFn

SortFn<A>: (a: A, b: A) => ComparisonNumbers

Type parameters

  • A

Type declaration

Variables

Const ap

ap: { <A, B>(fn: ReadonlyArray<Arity1<A, B>>, value: ReadonlyArray<A>): B[]; <A, B>(fn: ReadonlyArray<Arity1<A, B>>): (value: ReadonlyArray<A>) => B[] } = curry(<A, B>(fn: ReadonlyArray<Arity1<A, B>>, value: ReadonlyArray<A>): B[] =>chain((f) => map(f, value), fn),) as {<A, B>(fn: ReadonlyArray<Arity1<A, B>>, value: ReadonlyArray<A>): B[]<A, B>(fn: ReadonlyArray<Arity1<A, B>>): (value: ReadonlyArray<A>) => B[]}

Apply a list of functions to a list of values.

Type declaration

    • <A, B>(fn: ReadonlyArray<Arity1<A, B>>, value: ReadonlyArray<A>): B[]
    • <A, B>(fn: ReadonlyArray<Arity1<A, B>>): (value: ReadonlyArray<A>) => B[]
    • Type parameters

      • A

      • B

      Parameters

      • fn: ReadonlyArray<Arity1<A, B>>
      • value: ReadonlyArray<A>

      Returns B[]

    • Type parameters

      • A

      • B

      Parameters

      • fn: ReadonlyArray<Arity1<A, B>>

      Returns (value: ReadonlyArray<A>) => B[]

        • (value: ReadonlyArray<A>): B[]
        • Parameters

          • value: ReadonlyArray<A>

          Returns B[]

Const append

append: { <A>(value: A, list: ReadonlyArray<A>): A[]; <A>(value: A): (list: ReadonlyArray<A>) => A[] } = curry(_append) as {<A>(value: A, list: ReadonlyArray<A>): A[]<A>(value: A): (list: ReadonlyArray<A>) => A[]}

Append a value to the end of a list

param

:: a

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(value: A, list: ReadonlyArray<A>): A[]
    • <A>(value: A): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • value: A
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • value: A

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const appendOrRemove

appendOrRemove: { <A>(item: A, items: ReadonlyArray<A>): A[]; <A>(item: A): (items: ReadonlyArray<A>) => A[] } = curry(<A>(item: A, items: ReadonlyArray<A>): A[] =>__appendOrRemove(item, items, id),) as {<A>(item: A, items: ReadonlyArray<A>): A[]<A>(item: A): (items: ReadonlyArray<A>) => A[]}

Append a value to a list if it does not exist or remove if it does exist. Useful for toggling things on/off.

param

:: a

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(item: A, items: ReadonlyArray<A>): A[]
    • <A>(item: A): (items: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • item: A
      • items: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • item: A

      Returns (items: ReadonlyArray<A>) => A[]

        • (items: ReadonlyArray<A>): A[]
        • Parameters

          • items: ReadonlyArray<A>

          Returns A[]

Const appendOrRemoveBy

appendOrRemoveBy: { <A, B>(item: A, items: ReadonlyArray<A>, comparison: (value: A) => B): A[]; <A>(item: A, items: ReadonlyArray<A>): <B>(comparison: (value: A) => B) => A[]; <A>(item: A): { <B>(items: ReadonlyArray<A>, comparison: (value: A) => B): A[]; (items: ReadonlyArray<A>): <B>(comparison: (value: A) => B) => A[] } } = curry(__appendOrRemove) as {<A, B = A>(item: A, items: ReadonlyArray<A>, comparison: (value: A) => B): A[]<A>(item: A, items: ReadonlyArray<A>): <B = A>(comparison: (value: A) => B) => A[]<A>(item: A): {<B = A>(items: ReadonlyArray<A>, comparison: (value: A) => B): A[](items: ReadonlyArray<A>): <B = A>(comparison: (value: A) => B) => A[]}}

Append a value to a list if it does not exist or remove if it does exist. Allows providing a custom comparison function.

param

:: a

param

:: [a]

param

:: (a -> b)

returns

:: [a]

Type declaration

    • <A, B>(item: A, items: ReadonlyArray<A>, comparison: (value: A) => B): A[]
    • <A>(item: A, items: ReadonlyArray<A>): <B>(comparison: (value: A) => B) => A[]
    • <A>(item: A): { <B>(items: ReadonlyArray<A>, comparison: (value: A) => B): A[]; (items: ReadonlyArray<A>): <B>(comparison: (value: A) => B) => A[] }
    • Type parameters

      • A

      • B

      Parameters

      • item: A
      • items: ReadonlyArray<A>
      • comparison: (value: A) => B
          • (value: A): B
          • Parameters

            • value: A

            Returns B

      Returns A[]

    • Type parameters

      • A

      Parameters

      • item: A
      • items: ReadonlyArray<A>

      Returns <B>(comparison: (value: A) => B) => A[]

        • <B>(comparison: (value: A) => B): A[]
        • Type parameters

          • B

          Parameters

          • comparison: (value: A) => B
              • (value: A): B
              • Parameters

                • value: A

                Returns B

          Returns A[]

    • Type parameters

      • A

      Parameters

      • item: A

      Returns { <B>(items: ReadonlyArray<A>, comparison: (value: A) => B): A[]; (items: ReadonlyArray<A>): <B>(comparison: (value: A) => B) => A[] }

        • <B>(items: ReadonlyArray<A>, comparison: (value: A) => B): A[]
        • (items: ReadonlyArray<A>): <B>(comparison: (value: A) => B) => A[]
        • Type parameters

          • B

          Parameters

          • items: ReadonlyArray<A>
          • comparison: (value: A) => B
              • (value: A): B
              • Parameters

                • value: A

                Returns B

          Returns A[]

        • Parameters

          • items: ReadonlyArray<A>

          Returns <B>(comparison: (value: A) => B) => A[]

            • <B>(comparison: (value: A) => B): A[]
            • Type parameters

              • B

              Parameters

              • comparison: (value: A) => B
                  • (value: A): B
                  • Parameters

                    • value: A

                    Returns B

              Returns A[]

Const ascend

ascend: { <A, B>(f: (a: A) => B, a: A, b: A): ComparisonNumbers; <A, B>(f: (a: A) => B, a: A): (b: A) => ComparisonNumbers; <A, B>(f: (a: A) => B): { (a: A, b: A): ComparisonNumbers; (a: A): (b: A) => ComparisonNumbers } } = curry(function ascend<A, B extends ComparableValues>(f: (a: A) => B,a: A,b: A,): ComparisonNumbers {const aa = f(a)const bb = f(b)if (aa < bb) {return -1}if (aa > bb) {return 1}return 0}) as {<A, B extends ComparableValues>(f: (a: A) => B, a: A, b: A): ComparisonNumbers<A, B extends ComparableValues>(f: (a: A) => B, a: A): (b: A) => ComparisonNumbers<A, B extends ComparableValues>(f: (a: A) => B): {(a: A, b: A): ComparisonNumbers(a: A): (b: A) => ComparisonNumbers}}

Sort a function in ascending order given a comparison function.

param

:: (a -> b)

param

:: a

param

:: a

returns

:: int

Type declaration

Const chain

chain: { <A, B>(fn: Arity2<A, number, ReadonlyArray<B>>, list: ReadonlyArray<A>): B[]; <A, B>(fn: Arity2<A, number, ReadonlyArray<B>>): (list: ReadonlyArray<A>) => B[] } = curry((f, list) => unnest(list.map(f))) as {<A, B>(fn: Arity2<A, number, ReadonlyArray<B>>, list: ReadonlyArray<A>): B[]<A, B>(fn: Arity2<A, number, ReadonlyArray<B>>): (list: ReadonlyArray<A>) => B[]}

Combine a list of lists together by applying a function to the values contained in a list.

param

:: (a -> [b])

param

:: [a]

returns

:: [b]

Type declaration

    • <A, B>(fn: Arity2<A, number, ReadonlyArray<B>>, list: ReadonlyArray<A>): B[]
    • <A, B>(fn: Arity2<A, number, ReadonlyArray<B>>): (list: ReadonlyArray<A>) => B[]
    • Type parameters

      • A

      • B

      Parameters

      • fn: Arity2<A, number, ReadonlyArray<B>>
      • list: ReadonlyArray<A>

      Returns B[]

    • Type parameters

      • A

      • B

      Parameters

      • fn: Arity2<A, number, ReadonlyArray<B>>

      Returns (list: ReadonlyArray<A>) => B[]

        • (list: ReadonlyArray<A>): B[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns B[]

Const concat

concat: { <A>(head: ReadonlyArray<A>, tail: ReadonlyArray<A>): A[]; <A>(head: ReadonlyArray<A>): (tail: ReadonlyArray<A>) => A[] } = curry((a, b) => a.concat(b)) as {<A>(head: ReadonlyArray<A>, tail: ReadonlyArray<A>): A[]<A>(head: ReadonlyArray<A>): (tail: ReadonlyArray<A>) => A[]}

Concatenate two lists together into one.

param

:: [a]

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(head: ReadonlyArray<A>, tail: ReadonlyArray<A>): A[]
    • <A>(head: ReadonlyArray<A>): (tail: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • head: ReadonlyArray<A>
      • tail: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • head: ReadonlyArray<A>

      Returns (tail: ReadonlyArray<A>) => A[]

        • (tail: ReadonlyArray<A>): A[]
        • Parameters

          • tail: ReadonlyArray<A>

          Returns A[]

Const contains

contains: { <A>(value: A, list: ArrayLike<A>): boolean; <A>(value: A): (list: ArrayLike<A>) => boolean } = curry((value, list) => isJust(indexOf(value, list))) as {<A>(value: A, list: ArrayLike<A>): boolean<A>(value: A): (list: ArrayLike<A>) => boolean}

Returns true if a value is contained in a given list otherwise false.

param

:: a

param

:: [a]

returns

:: boolean

Type declaration

    • <A>(value: A, list: ArrayLike<A>): boolean
    • <A>(value: A): (list: ArrayLike<A>) => boolean
    • Type parameters

      • A

      Parameters

      • value: A
      • list: ArrayLike<A>

      Returns boolean

    • Type parameters

      • A

      Parameters

      • value: A

      Returns (list: ArrayLike<A>) => boolean

        • (list: ArrayLike<A>): boolean
        • Parameters

          • list: ArrayLike<A>

          Returns boolean

Const descend

descend: { <A, B>(f: (a: A) => B, a: A, b: A): ComparisonNumbers; <A, B>(f: (a: A) => B, a: A): (b: A) => ComparisonNumbers; <A, B>(f: (a: A) => B): { (a: A, b: A): ComparisonNumbers; (a: A): (b: A) => ComparisonNumbers } } = curry(function descend<A, B extends ComparableValues>(f: (a: A) => B,a: A,b: A,): ComparisonNumbers {const aa = f(a)const bb = f(b)if (aa < bb) {return 1}if (aa > bb) {return -1}return 0}) as {<A, B extends ComparableValues>(f: (a: A) => B, a: A, b: A): ComparisonNumbers<A, B extends ComparableValues>(f: (a: A) => B, a: A): (b: A) => ComparisonNumbers<A, B extends ComparableValues>(f: (a: A) => B): {(a: A, b: A): ComparisonNumbers(a: A): (b: A) => ComparisonNumbers}}

Sort a function in descending order given a comparison function.

param

:: (a -> b)

param

:: a

param

:: a

returns

:: int

Type declaration

Const drop

drop: { <A>(quantity: number, list: ReadonlyArray<A>): A[]; <A>(quantity: number): (list: ReadonlyArray<A>) => A[] } = curry(<A>(quantity: number, list: ReadonlyArray<A>): A[] =>list.slice(quantity),) as {<A>(quantity: number, list: ReadonlyArray<A>): A[]<A>(quantity: number): (list: ReadonlyArray<A>) => A[]}

Drop n amount of values from the beginning of a list.

param

:: number

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(quantity: number, list: ReadonlyArray<A>): A[]
    • <A>(quantity: number): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • quantity: number
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • quantity: number

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const dropLast

dropLast: { <A>(quantity: number, list: ReadonlyArray<A>): A[]; <A>(quantity: number): (list: ReadonlyArray<A>) => A[] } = curry(<A>(quantity: number, list: ReadonlyArray<A>): A[] =>list.slice(0, list.length - quantity),) as {<A>(quantity: number, list: ReadonlyArray<A>): A[]<A>(quantity: number): (list: ReadonlyArray<A>) => A[]}

Drop n amount of items from the end of a list

param

:: number

param

:: [a]

returns::

[a]

Type declaration

    • <A>(quantity: number, list: ReadonlyArray<A>): A[]
    • <A>(quantity: number): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • quantity: number
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • quantity: number

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const endsWith

endsWith: { <A>(expected: ReadonlyArray<A>, list: ArrayLike<A>): boolean; <A>(expected: ReadonlyArray<A>): (list: ArrayLike<A>) => boolean } = curry(<A>(expected: ReadonlyArray<A>, list: ArrayLike<A>) =>equals(expected, slice(list.length - expected.length, list.length, list)),) as {<A>(expected: ReadonlyArray<A>, list: ArrayLike<A>): boolean<A>(expected: ReadonlyArray<A>): (list: ArrayLike<A>) => boolean}

Returns true if a list ends with a given set of values otherwise false.

param

:: [a]

param

:: [a]

returns

:: boolean

Type declaration

    • <A>(expected: ReadonlyArray<A>, list: ArrayLike<A>): boolean
    • <A>(expected: ReadonlyArray<A>): (list: ArrayLike<A>) => boolean
    • Type parameters

      • A

      Parameters

      • expected: ReadonlyArray<A>
      • list: ArrayLike<A>

      Returns boolean

    • Type parameters

      • A

      Parameters

      • expected: ReadonlyArray<A>

      Returns (list: ArrayLike<A>) => boolean

        • (list: ArrayLike<A>): boolean
        • Parameters

          • list: ArrayLike<A>

          Returns boolean

Const filter

filter: { <A, B>(predicate: Is<B>, list: ReadonlyArray<A>): B[]; <B>(predicate: Is<B>): <A>(list: ReadonlyArray<A>) => B[]; <A>(predicate: Predicate<A>, list: ReadonlyArray<A>): A[]; <A>(predicate: Predicate<A>): (list: ReadonlyArray<A>) => A[] } = curry(<A>(predicate: Predicate<A>, list: ReadonlyArray<A>): A[] => list.filter(predicate)) as {<A, B extends A>(predicate: Is<B>, list: ReadonlyArray<A>): B[]<B>(predicate: Is<B>): <A>(list: ReadonlyArray<A>) => B[]<A>(predicate: Predicate<A>, list: ReadonlyArray<A>): A[]<A>(predicate: Predicate<A>): (list: ReadonlyArray<A>) => A[]}

Filter a list given a predicate.

param

:: (a -> boolean)

param

:: [a]

returns

:: [a]

Type declaration

    • <A, B>(predicate: Is<B>, list: ReadonlyArray<A>): B[]
    • <B>(predicate: Is<B>): <A>(list: ReadonlyArray<A>) => B[]
    • <A>(predicate: Predicate<A>, list: ReadonlyArray<A>): A[]
    • <A>(predicate: Predicate<A>): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      • B: A

      Parameters

      • predicate: Is<B>
      • list: ReadonlyArray<A>

      Returns B[]

    • Type parameters

      • B

      Parameters

      • predicate: Is<B>

      Returns <A>(list: ReadonlyArray<A>) => B[]

        • <A>(list: ReadonlyArray<A>): B[]
        • Type parameters

          • A

          Parameters

          • list: ReadonlyArray<A>

          Returns B[]

    • Type parameters

      • A

      Parameters

      • predicate: Predicate<A>
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const find

find: { <A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<A>; <A>(predicate: Predicate<A>): (list: ArrayLike<A>) => Maybe<A> } = curry(<A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<A> =>map((index: number) => list[index], findIndex(predicate, list)),) as {<A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<A><A>(predicate: Predicate<A>): (list: ArrayLike<A>) => Maybe<A>}

Search for a value in a list given a predicate.

param

:: (a -> boolean)

param

:: [a]

returns

:: Maybe a

Type declaration

    • Type parameters

      • A

      Parameters

      Returns Maybe<A>

    • Type parameters

      • A

      Parameters

      Returns (list: ArrayLike<A>) => Maybe<A>

        • (list: ArrayLike<A>): Maybe<A>
        • Parameters

          • list: ArrayLike<A>

          Returns Maybe<A>

Const findIndex

findIndex: { <A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<number>; <A>(predicate: Predicate<A>): (list: ArrayLike<A>) => Maybe<number> } = curry(<A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<number> => {for (let i = 0; i < list.length; ++i) {if (predicate(list[i])) {return Maybe.of(i)}}return Nothing},) as {<A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<number><A>(predicate: Predicate<A>): (list: ArrayLike<A>) => Maybe<number>}

Find the index of a value in an array like

param

:: (a -> boolean)

param

:: [a]

returns

:: Maybe number

Type declaration

    • Type parameters

      • A

      Parameters

      Returns Maybe<number>

    • Type parameters

      • A

      Parameters

      Returns (list: ArrayLike<A>) => Maybe<number>

        • (list: ArrayLike<A>): Maybe<number>
        • Parameters

          • list: ArrayLike<A>

          Returns Maybe<number>

Const findLast

findLast: { <A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<A>; <A>(predicate: Predicate<A>): (list: ArrayLike<A>) => Maybe<A> } = curry(__findLast) as {<A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<A><A>(predicate: Predicate<A>): (list: ArrayLike<A>) => Maybe<A>}

Find a value in an array-like starting from the end of the array-like

param

:: (a -> boolean)

param

:: [a]

returns

:: Maybe a

Type declaration

    • Type parameters

      • A

      Parameters

      Returns Maybe<A>

    • Type parameters

      • A

      Parameters

      Returns (list: ArrayLike<A>) => Maybe<A>

        • (list: ArrayLike<A>): Maybe<A>
        • Parameters

          • list: ArrayLike<A>

          Returns Maybe<A>

Const findLastIndex

findLastIndex: { <A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<number>; <A>(predicate: Predicate<A>): (list: ArrayLike<A>) => Maybe<number> } = curry(__findLastIndex) as {<A>(predicate: Predicate<NoInfer<A>>, list: ArrayLike<A>): Maybe<number><A>(predicate: Predicate<A>): (list: ArrayLike<A>) => Maybe<number>}

Find the index of a value in an array-like starting from the end of the array-like.

param

:: (a -> boolean)

param

:: [a]

returns

:: Maybe a

Type declaration

    • Type parameters

      • A

      Parameters

      Returns Maybe<number>

    • Type parameters

      • A

      Parameters

      Returns (list: ArrayLike<A>) => Maybe<number>

        • (list: ArrayLike<A>): Maybe<number>
        • Parameters

          • list: ArrayLike<A>

          Returns Maybe<number>

Const forEach

forEach: { <R, A>(f: Arity2<R, number, void>, list: A): A; <R>(f: Arity2<R, number, void>): <A>(list: A) => A } = curry(__forEach) as {<R, A extends ArrayLike<R>>(f: Arity2<R, number, void>, list: A): A<R>(f: Arity2<R, number, void>): <A extends ArrayLike<R>>(list: A) => A}

Perform a side-effect on every value in an array like. Returns the array-like passed in.

param

:: (a -> number -> *)

param

:: [a]

returns

:: [a]

Type declaration

    • <R, A>(f: Arity2<R, number, void>, list: A): A
    • <R>(f: Arity2<R, number, void>): <A>(list: A) => A
    • Type parameters

      • R

      • A: ArrayLike<R>

      Parameters

      • f: Arity2<R, number, void>
      • list: A

      Returns A

    • Type parameters

      • R

      Parameters

      Returns <A>(list: A) => A

        • <A>(list: A): A
        • Type parameters

          • A: ArrayLike<R>

          Parameters

          • list: A

          Returns A

Const groupBy

groupBy: { <A, B>(f: Arity1<A, B>, list: ReadonlyArray<A>): Record<B, A[]>; <A, B>(f: Arity1<A, B>): (list: ReadonlyArray<A>) => Record<B, A[]> } = curry(__groupBy) as {<A, B extends PropertyKey>(f: Arity1<A, B>, list: ReadonlyArray<A>): Record<B, A[]><A, B extends PropertyKey>(f: Arity1<A, B>): (list: ReadonlyArray<A>) => Record<B, A[]>}

Converts a list of values into groups keyed by passed in function.

param

:: a -> b

param

:: [a]

returns

Type declaration

    • <A, B>(f: Arity1<A, B>, list: ReadonlyArray<A>): Record<B, A[]>
    • <A, B>(f: Arity1<A, B>): (list: ReadonlyArray<A>) => Record<B, A[]>
    • Type parameters

      • A

      • B: PropertyKey

      Parameters

      • f: Arity1<A, B>
      • list: ReadonlyArray<A>

      Returns Record<B, A[]>

    • Type parameters

      • A

      • B: PropertyKey

      Parameters

      Returns (list: ReadonlyArray<A>) => Record<B, A[]>

        • (list: ReadonlyArray<A>): Record<B, A[]>
        • Parameters

          • list: ReadonlyArray<A>

          Returns Record<B, A[]>

Const includes

includes: { <A>(value: A, list: ArrayLike<A>): boolean; <A>(value: A): (list: ArrayLike<A>) => boolean } = curry(<A>(value: A, list: ArrayLike<A>): boolean => indexOf(list, value) > -1,) as {<A>(value: A, list: ArrayLike<A>): boolean<A>(value: A): (list: ArrayLike<A>) => boolean}

Returns true if a given value is contained in a list

param

:: a

param

:: [a]

returns

:: boolean

Type declaration

    • <A>(value: A, list: ArrayLike<A>): boolean
    • <A>(value: A): (list: ArrayLike<A>) => boolean
    • Type parameters

      • A

      Parameters

      • value: A
      • list: ArrayLike<A>

      Returns boolean

    • Type parameters

      • A

      Parameters

      • value: A

      Returns (list: ArrayLike<A>) => boolean

        • (list: ArrayLike<A>): boolean
        • Parameters

          • list: ArrayLike<A>

          Returns boolean

Const indexOf

indexOf: { <A>(value: A, list: ArrayLike<A>): Maybe<number>; <A>(value: A): (list: ArrayLike<A>) => Maybe<number> } = curry(<A>(value: A, list: ArrayLike<A>): Maybe<number> => {const index = _indexOf(list, value)return index > -1 ? Maybe.of(index) : Nothing},) as {<A>(value: A, list: ArrayLike<A>): Maybe<number><A>(value: A): (list: ArrayLike<A>) => Maybe<number>}

Find the index of a value

param

:: a

param

:: [a]

returns

:: Maybe int

Type declaration

    • <A>(value: A, list: ArrayLike<A>): Maybe<number>
    • <A>(value: A): (list: ArrayLike<A>) => Maybe<number>
    • Type parameters

      • A

      Parameters

      • value: A
      • list: ArrayLike<A>

      Returns Maybe<number>

    • Type parameters

      • A

      Parameters

      • value: A

      Returns (list: ArrayLike<A>) => Maybe<number>

        • (list: ArrayLike<A>): Maybe<number>
        • Parameters

          • list: ArrayLike<A>

          Returns Maybe<number>

Const insert

insert: { <A>(index: number, value: A, list: ReadonlyArray<A>): A[]; <A>(index: number, value: A): (list: ReadonlyArray<A>) => A[]; <A>(index: number): { (value: A, list: A[]): A[]; (value: A): (list: A[]) => A[] } } = curry(__insert) as {<A>(index: number, value: A, list: ReadonlyArray<A>): A[]<A>(index: number, value: A): (list: ReadonlyArray<A>) => A[]<A>(index: number): {(value: A, list: A[]): A[](value: A): (list: A[]) => A[]}}

Insert a value at a given index

param

:: int

param

:: a

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(index: number, value: A, list: ReadonlyArray<A>): A[]
    • <A>(index: number, value: A): (list: ReadonlyArray<A>) => A[]
    • <A>(index: number): { (value: A, list: A[]): A[]; (value: A): (list: A[]) => A[] }
    • Type parameters

      • A

      Parameters

      • index: number
      • value: A
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • index: number
      • value: A

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

    • Type parameters

      • A

      Parameters

      • index: number

      Returns { (value: A, list: A[]): A[]; (value: A): (list: A[]) => A[] }

        • (value: A, list: A[]): A[]
        • (value: A): (list: A[]) => A[]
        • Parameters

          • value: A
          • list: A[]

          Returns A[]

        • Parameters

          • value: A

          Returns (list: A[]) => A[]

            • (list: A[]): A[]
            • Parameters

              • list: A[]

              Returns A[]

Const join

join: { <A>(separator: string, list: ArrayLike<A>): string; <A>(separator: string): (list: ArrayLike<A>) => string } = curry(__join) as {<A>(separator: string, list: ArrayLike<A>): string<A>(separator: string): (list: ArrayLike<A>) => string}

Going together a list into a string separated by some string.

param

:: string

param

:: [a]

returns

:: string

Type declaration

    • <A>(separator: string, list: ArrayLike<A>): string
    • <A>(separator: string): (list: ArrayLike<A>) => string
    • Type parameters

      • A

      Parameters

      • separator: string
      • list: ArrayLike<A>

      Returns string

    • Type parameters

      • A

      Parameters

      • separator: string

      Returns (list: ArrayLike<A>) => string

        • (list: ArrayLike<A>): string
        • Parameters

          • list: ArrayLike<A>

          Returns string

Const lastIndexOf

lastIndexOf: { <A>(value: A, list: ArrayLike<A>): Maybe<number>; <A>(value: A): (list: ArrayLike<A>) => Maybe<number> } = curry(__lastIndexOf) as {<A>(value: A, list: ArrayLike<A>): Maybe<number><A>(value: A): (list: ArrayLike<A>) => Maybe<number>}

Find the last index of a given value in a list

param

:: a

param

:: [a]

returns

Maybe number

Type declaration

    • <A>(value: A, list: ArrayLike<A>): Maybe<number>
    • <A>(value: A): (list: ArrayLike<A>) => Maybe<number>
    • Type parameters

      • A

      Parameters

      • value: A
      • list: ArrayLike<A>

      Returns Maybe<number>

    • Type parameters

      • A

      Parameters

      • value: A

      Returns (list: ArrayLike<A>) => Maybe<number>

        • (list: ArrayLike<A>): Maybe<number>
        • Parameters

          • list: ArrayLike<A>

          Returns Maybe<number>

Const map

map: { <A, B>(fn: Arity1<A, B>, list: ArrayLike<A>): B[]; <A, B>(fn: Arity1<A, B>): (list: ArrayLike<A>) => B[] } = curry((f, list) => mapArrayLike(f, list)) as {<A, B>(fn: Arity1<A, B>, list: ArrayLike<A>): B[]<A, B>(fn: Arity1<A, B>): (list: ArrayLike<A>) => B[]}

Map over a list of values

param

:: (a -> b)

param

:: [a]

returns

:: [b]

Type declaration

    • <A, B>(fn: Arity1<A, B>, list: ArrayLike<A>): B[]
    • <A, B>(fn: Arity1<A, B>): (list: ArrayLike<A>) => B[]
    • Type parameters

      • A

      • B

      Parameters

      • fn: Arity1<A, B>
      • list: ArrayLike<A>

      Returns B[]

    • Type parameters

      • A

      • B

      Parameters

      Returns (list: ArrayLike<A>) => B[]

        • (list: ArrayLike<A>): B[]
        • Parameters

          • list: ArrayLike<A>

          Returns B[]

Const maybeFilter

maybeFilter: { <A, B>(predicate: Predicate2<A, B>, maybe: Maybe<A>, list: ReadonlyArray<B>): B[]; <A, B>(predicate: Predicate2<A, B>, maybe: Maybe<A>): (list: ReadonlyArray<B>) => B[]; <A, B>(predicate: Predicate2<A, B>): { (maybe: Maybe<A>, list: ReadonlyArray<B>): B[]; (maybe: Maybe<A>): (list: ReadonlyArray<B>) => B[] } } = curry(<A, B>(predicate: Predicate2<A, B>, maybe: Maybe<A>, list: ReadonlyArray<B>): B[] => {if (isNothing(maybe)) {return list.slice()}const a = fromJust(maybe)return list.filter((b) => predicate(a, b))}) as {<A, B>(predicate: Predicate2<A, B>, maybe: Maybe<A>, list: ReadonlyArray<B>): B[]<A, B>(predicate: Predicate2<A, B>, maybe: Maybe<A>): (list: ReadonlyArray<B>) => B[]<A, B>(predicate: Predicate2<A, B>): {(maybe: Maybe<A>, list: ReadonlyArray<B>): B[](maybe: Maybe<A>): (list: ReadonlyArray<B>) => B[]}}

Filter a list using a maybe value. Returns the list unchanged if maybe is Nothing.

param

:: (a -> b -> boolean)

param

:: Maybe a

param

:: [b]

returns

:: [b]

Type declaration

    • <A, B>(predicate: Predicate2<A, B>, maybe: Maybe<A>, list: ReadonlyArray<B>): B[]
    • <A, B>(predicate: Predicate2<A, B>, maybe: Maybe<A>): (list: ReadonlyArray<B>) => B[]
    • <A, B>(predicate: Predicate2<A, B>): { (maybe: Maybe<A>, list: ReadonlyArray<B>): B[]; (maybe: Maybe<A>): (list: ReadonlyArray<B>) => B[] }
    • Type parameters

      • A

      • B

      Parameters

      Returns B[]

    • Type parameters

      • A

      • B

      Parameters

      Returns (list: ReadonlyArray<B>) => B[]

        • (list: ReadonlyArray<B>): B[]
        • Parameters

          • list: ReadonlyArray<B>

          Returns B[]

    • Type parameters

      • A

      • B

      Parameters

      Returns { (maybe: Maybe<A>, list: ReadonlyArray<B>): B[]; (maybe: Maybe<A>): (list: ReadonlyArray<B>) => B[] }

        • (maybe: Maybe<A>, list: ReadonlyArray<B>): B[]
        • (maybe: Maybe<A>): (list: ReadonlyArray<B>) => B[]
        • Parameters

          • maybe: Maybe<A>
          • list: ReadonlyArray<B>

          Returns B[]

        • Parameters

          Returns (list: ReadonlyArray<B>) => B[]

            • (list: ReadonlyArray<B>): B[]
            • Parameters

              • list: ReadonlyArray<B>

              Returns B[]

Const move

move: { <A>(fromIndex: number, toIndex: number, list: ArrayLike<A>): A[]; (fromIndex: number, toIndex: number): <A>(list: ArrayLike<A>) => A[]; (fromIndex: number): { <A>(toIndex: number, list: ArrayLike<A>): A[]; (toIndex: number): <A>(list: ArrayLike<A>) => A[] } } = curry(__move) as {<A>(fromIndex: number, toIndex: number, list: ArrayLike<A>): A[](fromIndex: number, toIndex: number): <A>(list: ArrayLike<A>) => A[](fromIndex: number): {<A>(toIndex: number, list: ArrayLike<A>): A[](toIndex: number): <A>(list: ArrayLike<A>) => A[]}}

Move a value from one index to another

param

:: int

param

:: int

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(fromIndex: number, toIndex: number, list: ArrayLike<A>): A[]
    • (fromIndex: number, toIndex: number): <A>(list: ArrayLike<A>) => A[]
    • (fromIndex: number): { <A>(toIndex: number, list: ArrayLike<A>): A[]; (toIndex: number): <A>(list: ArrayLike<A>) => A[] }
    • Type parameters

      • A

      Parameters

      • fromIndex: number
      • toIndex: number
      • list: ArrayLike<A>

      Returns A[]

    • Parameters

      • fromIndex: number
      • toIndex: number

      Returns <A>(list: ArrayLike<A>) => A[]

        • <A>(list: ArrayLike<A>): A[]
        • Type parameters

          • A

          Parameters

          • list: ArrayLike<A>

          Returns A[]

    • Parameters

      • fromIndex: number

      Returns { <A>(toIndex: number, list: ArrayLike<A>): A[]; (toIndex: number): <A>(list: ArrayLike<A>) => A[] }

        • <A>(toIndex: number, list: ArrayLike<A>): A[]
        • (toIndex: number): <A>(list: ArrayLike<A>) => A[]
        • Type parameters

          • A

          Parameters

          • toIndex: number
          • list: ArrayLike<A>

          Returns A[]

        • Parameters

          • toIndex: number

          Returns <A>(list: ArrayLike<A>) => A[]

            • <A>(list: ArrayLike<A>): A[]
            • Type parameters

              • A

              Parameters

              • list: ArrayLike<A>

              Returns A[]

Const multiSort

multiSort: { <A>(sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[]; <A>(sortFns: Arity1<A, PropertyKey>[]): (list: ReadonlyArray<A>) => A[] } = curry(function multiSort<A>(sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[] {return multiSortWithOrder(SortOrder.Ascending, sortFns, list)})

Order a list into groups and subgroups

param

:: [(a -> PropertyKey)]

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[]
    • <A>(sortFns: Arity1<A, PropertyKey>[]): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • sortFns: Arity1<A, PropertyKey>[]
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • sortFns: Arity1<A, PropertyKey>[]

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const multiSortWithOrder

multiSortWithOrder: { <A>(order: SortOrder, sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[]; <A>(order: SortOrder, sortFns: Arity1<A, PropertyKey>[]): (list: ReadonlyArray<A>) => A[]; (order: SortOrder): { <A>(sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[]; <A>(sortFns: Arity1<A, PropertyKey>[]): (list: ReadonlyArray<A>) => A[] } } = curry(function multiSortWithOrder<A>(order: SortOrder,sortFns: Arity1<A, PropertyKey>[],list: ReadonlyArray<A>,): A[] {if (sortFns.length === 0 || list.length === 0) {return list.slice()}const sort = order === SortOrder.Ascending ? ascend : descendconst initialObject = groupBy(sortFns[0], list)const initialKeys = Object.keys(initialObject).sort(sort(id))const innerSortFns = sortFns.slice(1)const result = initialKeys.reduce((acc, key) => {acc[key] = multiSortWithOrder(order, innerSortFns, initialObject[key])return acc}, {} as Record<string, A[]>)return chain((x) => result[x], initialKeys)})

Type declaration

    • <A>(order: SortOrder, sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[]
    • <A>(order: SortOrder, sortFns: Arity1<A, PropertyKey>[]): (list: ReadonlyArray<A>) => A[]
    • (order: SortOrder): { <A>(sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[]; <A>(sortFns: Arity1<A, PropertyKey>[]): (list: ReadonlyArray<A>) => A[] }
    • Type parameters

      • A

      Parameters

      • order: SortOrder
      • sortFns: Arity1<A, PropertyKey>[]
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

    • Parameters

      Returns { <A>(sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[]; <A>(sortFns: Arity1<A, PropertyKey>[]): (list: ReadonlyArray<A>) => A[] }

        • <A>(sortFns: Arity1<A, PropertyKey>[], list: ReadonlyArray<A>): A[]
        • <A>(sortFns: Arity1<A, PropertyKey>[]): (list: ReadonlyArray<A>) => A[]
        • Type parameters

          • A

          Parameters

          • sortFns: Arity1<A, PropertyKey>[]
          • list: ReadonlyArray<A>

          Returns A[]

        • Type parameters

          • A

          Parameters

          • sortFns: Arity1<A, PropertyKey>[]

          Returns (list: ReadonlyArray<A>) => A[]

            • (list: ReadonlyArray<A>): A[]
            • Parameters

              • list: ReadonlyArray<A>

              Returns A[]

Const prepend

prepend: { <A>(value: A, list: ReadonlyArray<A>): A[]; <A>(value: A): (list: ReadonlyArray<A>) => A[] } = curry(<A>(value: A, list: A[]): A[] => [value].concat(list)) as {<A>(value: A, list: ReadonlyArray<A>): A[]<A>(value: A): (list: ReadonlyArray<A>) => A[]}

Add a value at the beginning of a list

param

:: a

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(value: A, list: ReadonlyArray<A>): A[]
    • <A>(value: A): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • value: A
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • value: A

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const range

range: { (from: number, to: number): number[]; (from: number): (to: number) => number[] } = curry(__range)

Create a list of number from one number to another

param

:: int

param

:: int

retuns

:: [int]

Type declaration

    • (from: number, to: number): number[]
    • (from: number): (to: number) => number[]
    • Parameters

      • from: number
      • to: number

      Returns number[]

    • Parameters

      • from: number

      Returns (to: number) => number[]

        • (to: number): number[]
        • Parameters

          • to: number

          Returns number[]

Const reduce

reduce: { <A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B, list: ReadonlyArray<A>): B; <A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B): (list: ReadonlyArray<A>) => B; <A, B>(fn: (accumulator: B, value: A, index: number) => B): { (seed: B, list: ReadonlyArray<A>): B; (seed: B): (list: ReadonlyArray<A>) => B } } = curry(<A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B, list: ReadonlyArray<A>): B =>list.reduce(fn, seed),) as {<A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B, list: ReadonlyArray<A>): B<A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B): (list: ReadonlyArray<A>) => B<A, B>(fn: (accumulator: B, value: A, index: number) => B): {(seed: B, list: ReadonlyArray<A>): B(seed: B): (list: ReadonlyArray<A>) => B}}

Reduce over a list of values.

param

:: (b -> a -> b)

param

:: b

param

:: [a]

returns

:: b

Type declaration

    • <A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B, list: ReadonlyArray<A>): B
    • <A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B): (list: ReadonlyArray<A>) => B
    • <A, B>(fn: (accumulator: B, value: A, index: number) => B): { (seed: B, list: ReadonlyArray<A>): B; (seed: B): (list: ReadonlyArray<A>) => B }
    • Type parameters

      • A

      • B

      Parameters

      • fn: (accumulator: B, value: A, index: number) => B
          • (accumulator: B, value: A, index: number): B
          • Parameters

            • accumulator: B
            • value: A
            • index: number

            Returns B

      • seed: B
      • list: ReadonlyArray<A>

      Returns B

    • Type parameters

      • A

      • B

      Parameters

      • fn: (accumulator: B, value: A, index: number) => B
          • (accumulator: B, value: A, index: number): B
          • Parameters

            • accumulator: B
            • value: A
            • index: number

            Returns B

      • seed: B

      Returns (list: ReadonlyArray<A>) => B

        • (list: ReadonlyArray<A>): B
        • Parameters

          • list: ReadonlyArray<A>

          Returns B

    • Type parameters

      • A

      • B

      Parameters

      • fn: (accumulator: B, value: A, index: number) => B
          • (accumulator: B, value: A, index: number): B
          • Parameters

            • accumulator: B
            • value: A
            • index: number

            Returns B

      Returns { (seed: B, list: ReadonlyArray<A>): B; (seed: B): (list: ReadonlyArray<A>) => B }

        • (seed: B, list: ReadonlyArray<A>): B
        • (seed: B): (list: ReadonlyArray<A>) => B
        • Parameters

          • seed: B
          • list: ReadonlyArray<A>

          Returns B

        • Parameters

          • seed: B

          Returns (list: ReadonlyArray<A>) => B

            • (list: ReadonlyArray<A>): B
            • Parameters

              • list: ReadonlyArray<A>

              Returns B

Const reduceBy

reduceBy: ReduceByArity4 = curry(<A, B>(f: (acc: B, x: A) => B,seed: B,by: (a: A) => PropertyKey,list: A[],): { readonly [key: string]: B } => {const length = list.lengthconst newObj: any = {}for (let i = 0; i < length; ++i) {const a = list[i]const key = by(a)const b = f(newObj[key] || seed, a)newObj[key] = b}return newObj},) as ReduceByArity4

Group and reduce a list of values.

param

:: (b -> a -> b)

param

:: b

param

:: (a -> PropertyKey)

returns

Const reduceRight

reduceRight: { <A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B, list: ReadonlyArray<A>): B; <A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B): (list: ReadonlyArray<A>) => B; <A, B>(fn: (accumulator: B, value: A, index: number) => B): { (seed: B, list: ReadonlyArray<A>): B; (seed: B): (list: ReadonlyArray<A>) => B } } = curry(<A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B, list: ReadonlyArray<A>): B =>list.reduceRight(fn, seed),) as {<A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B, list: ReadonlyArray<A>): B<A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B): (list: ReadonlyArray<A>) => B<A, B>(fn: (accumulator: B, value: A, index: number) => B): {(seed: B, list: ReadonlyArray<A>): B(seed: B): (list: ReadonlyArray<A>) => B}}

Reduce over a list of values.

param

:: (b -> a -> b)

param

:: b

param

:: [a]

returns

:: b

Type declaration

    • <A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B, list: ReadonlyArray<A>): B
    • <A, B>(fn: (accumulator: B, value: A, index: number) => B, seed: B): (list: ReadonlyArray<A>) => B
    • <A, B>(fn: (accumulator: B, value: A, index: number) => B): { (seed: B, list: ReadonlyArray<A>): B; (seed: B): (list: ReadonlyArray<A>) => B }
    • Type parameters

      • A

      • B

      Parameters

      • fn: (accumulator: B, value: A, index: number) => B
          • (accumulator: B, value: A, index: number): B
          • Parameters

            • accumulator: B
            • value: A
            • index: number

            Returns B

      • seed: B
      • list: ReadonlyArray<A>

      Returns B

    • Type parameters

      • A

      • B

      Parameters

      • fn: (accumulator: B, value: A, index: number) => B
          • (accumulator: B, value: A, index: number): B
          • Parameters

            • accumulator: B
            • value: A
            • index: number

            Returns B

      • seed: B

      Returns (list: ReadonlyArray<A>) => B

        • (list: ReadonlyArray<A>): B
        • Parameters

          • list: ReadonlyArray<A>

          Returns B

    • Type parameters

      • A

      • B

      Parameters

      • fn: (accumulator: B, value: A, index: number) => B
          • (accumulator: B, value: A, index: number): B
          • Parameters

            • accumulator: B
            • value: A
            • index: number

            Returns B

      Returns { (seed: B, list: ReadonlyArray<A>): B; (seed: B): (list: ReadonlyArray<A>) => B }

        • (seed: B, list: ReadonlyArray<A>): B
        • (seed: B): (list: ReadonlyArray<A>) => B
        • Parameters

          • seed: B
          • list: ReadonlyArray<A>

          Returns B

        • Parameters

          • seed: B

          Returns (list: ReadonlyArray<A>) => B

            • (list: ReadonlyArray<A>): B
            • Parameters

              • list: ReadonlyArray<A>

              Returns B

Const remove

remove: { <A>(index: number, amount: number, list: ReadonlyArray<A>): A[]; (index: number, amount: number): <A>(list: ReadonlyArray<A>) => A[]; (index: number): { <A>(amount: number, list: ReadonlyArray<A>): A[]; (amount: number): <A>(list: ReadonlyArray<A>) => A[] } } = curry(function remove<A>(index: number,amount: number,list: ReadonlyArray<A>,): A[] {const length = list.lengthif (isZero(amount) || isZero(length) || index >= length) {return list.slice()}if (isZero(index) && amount >= length) {return []}const newList = Array(length - Math.abs(index) - 1)for (let i = 0; i < index; ++i) {newList[i] = list[i]}for (let i = index + amount; i < length; ++i) {newList[i - amount] = list[i]}return newList}) as {<A>(index: number, amount: number, list: ReadonlyArray<A>): A[](index: number, amount: number): <A>(list: ReadonlyArray<A>) => A[](index: number): {<A>(amount: number, list: ReadonlyArray<A>): A[](amount: number): <A>(list: ReadonlyArray<A>) => A[]}}

Remove values from a list at a given index.

param

:: int

param

:: int

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(index: number, amount: number, list: ReadonlyArray<A>): A[]
    • (index: number, amount: number): <A>(list: ReadonlyArray<A>) => A[]
    • (index: number): { <A>(amount: number, list: ReadonlyArray<A>): A[]; (amount: number): <A>(list: ReadonlyArray<A>) => A[] }
    • Type parameters

      • A

      Parameters

      • index: number
      • amount: number
      • list: ReadonlyArray<A>

      Returns A[]

    • Parameters

      • index: number
      • amount: number

      Returns <A>(list: ReadonlyArray<A>) => A[]

        • <A>(list: ReadonlyArray<A>): A[]
        • Type parameters

          • A

          Parameters

          • list: ReadonlyArray<A>

          Returns A[]

    • Parameters

      • index: number

      Returns { <A>(amount: number, list: ReadonlyArray<A>): A[]; (amount: number): <A>(list: ReadonlyArray<A>) => A[] }

        • <A>(amount: number, list: ReadonlyArray<A>): A[]
        • (amount: number): <A>(list: ReadonlyArray<A>) => A[]
        • Type parameters

          • A

          Parameters

          • amount: number
          • list: ReadonlyArray<A>

          Returns A[]

        • Parameters

          • amount: number

          Returns <A>(list: ReadonlyArray<A>) => A[]

            • <A>(list: ReadonlyArray<A>): A[]
            • Type parameters

              • A

              Parameters

              • list: ReadonlyArray<A>

              Returns A[]

Const slice

slice: { <A>(from: number, to: number, list: ArrayLike<A>): A[]; (from: number, to: number): <A>(list: ArrayLike<A>) => A[]; (from: number): { <A>(to: number, list: ArrayLike<A>): A[]; (to: number): <A>(list: ArrayLike<A>) => A[] } } = curry(<A>(from: number, to: number, list: ArrayLike<A>): A[] =>Array.from(list).slice(from, to),) as {<A>(from: number, to: number, list: ArrayLike<A>): A[](from: number, to: number): <A>(list: ArrayLike<A>) => A[](from: number): {<A>(to: number, list: ArrayLike<A>): A[](to: number): <A>(list: ArrayLike<A>) => A[]}}

Slice chunks out of a list

param

:: int

param

:: int

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(from: number, to: number, list: ArrayLike<A>): A[]
    • (from: number, to: number): <A>(list: ArrayLike<A>) => A[]
    • (from: number): { <A>(to: number, list: ArrayLike<A>): A[]; (to: number): <A>(list: ArrayLike<A>) => A[] }
    • Type parameters

      • A

      Parameters

      • from: number
      • to: number
      • list: ArrayLike<A>

      Returns A[]

    • Parameters

      • from: number
      • to: number

      Returns <A>(list: ArrayLike<A>) => A[]

        • <A>(list: ArrayLike<A>): A[]
        • Type parameters

          • A

          Parameters

          • list: ArrayLike<A>

          Returns A[]

    • Parameters

      • from: number

      Returns { <A>(to: number, list: ArrayLike<A>): A[]; (to: number): <A>(list: ArrayLike<A>) => A[] }

        • <A>(to: number, list: ArrayLike<A>): A[]
        • (to: number): <A>(list: ArrayLike<A>) => A[]
        • Type parameters

          • A

          Parameters

          • to: number
          • list: ArrayLike<A>

          Returns A[]

        • Parameters

          • to: number

          Returns <A>(list: ArrayLike<A>) => A[]

            • <A>(list: ArrayLike<A>): A[]
            • Type parameters

              • A

              Parameters

              • list: ArrayLike<A>

              Returns A[]

Const sort

sort: { <A>(sortFn: SortFn<A>, list: ReadonlyArray<A>): A[]; <A>(sortFn: SortFn<A>): (list: ReadonlyArray<A>) => A[] } = curry(<A>(sortFn: SortFn<A>, list: ReadonlyArray<A>): A[] =>list.slice().sort(sortFn),) as {<A>(sortFn: SortFn<A>, list: ReadonlyArray<A>): A[]<A>(sortFn: SortFn<A>): (list: ReadonlyArray<A>) => A[]}

Sort a list

param

:: Comparable b => (a -> a -> b)

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(sortFn: SortFn<A>, list: ReadonlyArray<A>): A[]
    • <A>(sortFn: SortFn<A>): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • sortFn: SortFn<A>
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const splitAt

splitAt: { <A>(index: number, list: ReadonlyArray<A>): Tuple<A[], A[]>; <A>(index: number): (list: ReadonlyArray<A>) => Tuple<A[], A[]> } = curry(<A>(index: number, list: ReadonlyArray<A>): Tuple<A[], A[]> => [list.slice(0, index),list.slice(index),],) as {<A>(index: number, list: ReadonlyArray<A>): Tuple<A[], A[]><A>(index: number): (list: ReadonlyArray<A>) => Tuple<A[], A[]>}

Split a list into two parts at a given index

Type declaration

    • <A>(index: number, list: ReadonlyArray<A>): Tuple<A[], A[]>
    • <A>(index: number): (list: ReadonlyArray<A>) => Tuple<A[], A[]>
    • Type parameters

      • A

      Parameters

      • index: number
      • list: ReadonlyArray<A>

      Returns Tuple<A[], A[]>

    • Type parameters

      • A

      Parameters

      • index: number

      Returns (list: ReadonlyArray<A>) => Tuple<A[], A[]>

        • (list: ReadonlyArray<A>): Tuple<A[], A[]>
        • Parameters

          • list: ReadonlyArray<A>

          Returns Tuple<A[], A[]>

Const splitEvery

splitEvery: { <A>(amount: number, list: ReadonlyArray<A>): A[][]; <A>(amount: number): (list: ReadonlyArray<A>) => A[][] } = curry(function splitEvery<A>(amount: number,list: ReadonlyArray<A>,): A[][] {if (amount <= 0) {return [list.slice()]}const result: A[][] = []let i = 0while (i < list.length) {result.push(list.slice(i, (i += amount)))}return result}) as {<A>(amount: number, list: ReadonlyArray<A>): A[][]<A>(amount: number): (list: ReadonlyArray<A>) => A[][]}

Split a list into a list of lists containing a specified amount of values.

param

:: int

param

:: [a]

returns

:: [[a]]

Type declaration

    • <A>(amount: number, list: ReadonlyArray<A>): A[][]
    • <A>(amount: number): (list: ReadonlyArray<A>) => A[][]
    • Type parameters

      • A

      Parameters

      • amount: number
      • list: ReadonlyArray<A>

      Returns A[][]

    • Type parameters

      • A

      Parameters

      • amount: number

      Returns (list: ReadonlyArray<A>) => A[][]

        • (list: ReadonlyArray<A>): A[][]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[][]

Const startsWith

startsWith: { <A>(search: ArrayLike<A>, list: ArrayLike<A>): boolean; <A>(search: ArrayLike<A>): (list: ArrayLike<A>) => boolean } = curry(__startsWith) as {<A>(search: ArrayLike<A>, list: ArrayLike<A>): boolean<A>(search: ArrayLike<A>): (list: ArrayLike<A>) => boolean}

Checks if a list starts with a given set of values

param

:: [a]

param

:: [a]

returns

:: boolean

Type declaration

    • <A>(search: ArrayLike<A>, list: ArrayLike<A>): boolean
    • <A>(search: ArrayLike<A>): (list: ArrayLike<A>) => boolean
    • Type parameters

      • A

      Parameters

      • search: ArrayLike<A>
      • list: ArrayLike<A>

      Returns boolean

    • Type parameters

      • A

      Parameters

      • search: ArrayLike<A>

      Returns (list: ArrayLike<A>) => boolean

        • (list: ArrayLike<A>): boolean
        • Parameters

          • list: ArrayLike<A>

          Returns boolean

Const take

take: { <A>(n: number, list: ReadonlyArray<A>): A[]; <A>(n: number): (list: ReadonlyArray<A>) => A[] } = curry(<A>(n: number, list: ReadonlyArray<A>) =>list.slice(0, n < 0 ? Infinity : n),) as {<A>(n: number, list: ReadonlyArray<A>): A[]<A>(n: number): (list: ReadonlyArray<A>) => A[]}

Take n number of values from the beginning of a list

param

:: int

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(n: number, list: ReadonlyArray<A>): A[]
    • <A>(n: number): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • n: number
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • n: number

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const takeLast

takeLast: { <A>(n: number, list: ReadonlyArray<A>): A[]; <A>(n: number): (list: ReadonlyArray<A>) => A[] } = curry(<A>(n: number, list: ReadonlyArray<A>) =>drop(n >= 0 ? list.length - n : 0, list),) as {<A>(n: number, list: ReadonlyArray<A>): A[]<A>(n: number): (list: ReadonlyArray<A>) => A[]}

Take n number of values from the end of a list

param

:: int

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(n: number, list: ReadonlyArray<A>): A[]
    • <A>(n: number): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • n: number
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • n: number

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const takeLastWhile

takeLastWhile: { <A>(f: (a: A, i: number) => boolean, list: ArrayLike<A>): A[]; <A>(f: (a: A, i: number) => boolean): (list: ArrayLike<A>) => A[] } = curry(_takeLastWhile)

Take values from the ending of a list while predicate is true

param

:: int

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(f: (a: A, i: number) => boolean, list: ArrayLike<A>): A[]
    • <A>(f: (a: A, i: number) => boolean): (list: ArrayLike<A>) => A[]
    • Type parameters

      • A

      Parameters

      • f: (a: A, i: number) => boolean
          • (a: A, i: number): boolean
          • Parameters

            • a: A
            • i: number

            Returns boolean

      • list: ArrayLike<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • f: (a: A, i: number) => boolean
          • (a: A, i: number): boolean
          • Parameters

            • a: A
            • i: number

            Returns boolean

      Returns (list: ArrayLike<A>) => A[]

        • (list: ArrayLike<A>): A[]
        • Parameters

          • list: ArrayLike<A>

          Returns A[]

Const takeWhile

takeWhile: { <A>(f: (a: A, i: number) => boolean, list: ArrayLike<A>): A[]; <A>(f: (a: A, i: number) => boolean): (list: ArrayLike<A>) => A[] } = curry(_takeWhile)

Take values from the start of a list while predicate is true

param

:: int

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(f: (a: A, i: number) => boolean, list: ArrayLike<A>): A[]
    • <A>(f: (a: A, i: number) => boolean): (list: ArrayLike<A>) => A[]
    • Type parameters

      • A

      Parameters

      • f: (a: A, i: number) => boolean
          • (a: A, i: number): boolean
          • Parameters

            • a: A
            • i: number

            Returns boolean

      • list: ArrayLike<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • f: (a: A, i: number) => boolean
          • (a: A, i: number): boolean
          • Parameters

            • a: A
            • i: number

            Returns boolean

      Returns (list: ArrayLike<A>) => A[]

        • (list: ArrayLike<A>): A[]
        • Parameters

          • list: ArrayLike<A>

          Returns A[]

Const uniq

uniq: <A>(list: ReadonlyArray<A>) => A[] = uniqBy(id)

Get unique set of values contained in list.

Type declaration

    • <A>(list: ReadonlyArray<A>): A[]
    • Type parameters

      • A

      Parameters

      • list: ReadonlyArray<A>

      Returns A[]

Const uniqBy

uniqBy: { <A, B>(toComparisonValue: (value: A, index: number) => B, list: ReadonlyArray<A>): A[]; <A, B>(toComparisonValue: (value: A, index: number) => B): (list: ReadonlyArray<A>) => A[] } = curry(<A, B>(toComparisonValue: (value: A, index: number) => B, list: ReadonlyArray<A>): A[] => {const valuesSeen: B[] = []const result: A[] = []// tslint:disable-next-line:prefer-for-offor (let i = 0; i < list.length; ++i) {const value = list[i]const comparisonValue = toComparisonValue(value, i)const valueHasBeenSeen = includes(comparisonValue, valuesSeen)if (!valueHasBeenSeen) {valuesSeen.push(comparisonValue)result.push(value)}}return result},) as {<A, B>(toComparisonValue: (value: A, index: number) => B, list: ReadonlyArray<A>): A[]<A, B>(toComparisonValue: (value: A, index: number) => B): (list: ReadonlyArray<A>) => A[]}

Remove duplicate values from a list given a comparison function.

param

:: (a -> int -> b)

param

:: [a]

returns

:: [a]

Type declaration

    • <A, B>(toComparisonValue: (value: A, index: number) => B, list: ReadonlyArray<A>): A[]
    • <A, B>(toComparisonValue: (value: A, index: number) => B): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      • B

      Parameters

      • toComparisonValue: (value: A, index: number) => B
          • (value: A, index: number): B
          • Parameters

            • value: A
            • index: number

            Returns B

      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      • B

      Parameters

      • toComparisonValue: (value: A, index: number) => B
          • (value: A, index: number): B
          • Parameters

            • value: A
            • index: number

            Returns B

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const update

update: { <A>(index: number, value: A, list: ReadonlyArray<A>): A[]; <A>(index: number, value: A): (list: ReadonlyArray<A>) => A[]; (index: number): { <A>(value: A, list: ReadonlyArray<A>): A[]; <A>(value: A): (list: ReadonlyArray<A>) => A[] } } = curry(function update<A>(index: number,value: A,list: ReadonlyArray<A>,): A[] {const length = list.lengthconst newList = list.slice()if (length === 0 || index < 0 || index >= length) {return newList}newList[index] = valuereturn newList}) as {<A>(index: number, value: A, list: ReadonlyArray<A>): A[]<A>(index: number, value: A): (list: ReadonlyArray<A>) => A[](index: number): {<A>(value: A, list: ReadonlyArray<A>): A[]<A>(value: A): (list: ReadonlyArray<A>) => A[]}}

Replace a value at a given index

param

:: int

param

:: a

param

:: [a]

returns

:: [a]

Type declaration

    • <A>(index: number, value: A, list: ReadonlyArray<A>): A[]
    • <A>(index: number, value: A): (list: ReadonlyArray<A>) => A[]
    • (index: number): { <A>(value: A, list: ReadonlyArray<A>): A[]; <A>(value: A): (list: ReadonlyArray<A>) => A[] }
    • Type parameters

      • A

      Parameters

      • index: number
      • value: A
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • index: number
      • value: A

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

    • Parameters

      • index: number

      Returns { <A>(value: A, list: ReadonlyArray<A>): A[]; <A>(value: A): (list: ReadonlyArray<A>) => A[] }

        • <A>(value: A, list: ReadonlyArray<A>): A[]
        • <A>(value: A): (list: ReadonlyArray<A>) => A[]
        • Type parameters

          • A

          Parameters

          • value: A
          • list: ReadonlyArray<A>

          Returns A[]

        • Type parameters

          • A

          Parameters

          • value: A

          Returns (list: ReadonlyArray<A>) => A[]

            • (list: ReadonlyArray<A>): A[]
            • Parameters

              • list: ReadonlyArray<A>

              Returns A[]

Const without

without: { <A>(values: A[], list: ReadonlyArray<A>): A[]; <A>(values: A[]): (list: ReadonlyArray<A>) => A[] } = curry(__without) as {<A>(values: A[], list: ReadonlyArray<A>): A[]<A>(values: A[]): (list: ReadonlyArray<A>) => A[]}

Returns a list without the specified values.

name

without(values: A[], list: A[]): Array

Type declaration

    • <A>(values: A[], list: ReadonlyArray<A>): A[]
    • <A>(values: A[]): (list: ReadonlyArray<A>) => A[]
    • Type parameters

      • A

      Parameters

      • values: A[]
      • list: ReadonlyArray<A>

      Returns A[]

    • Type parameters

      • A

      Parameters

      • values: A[]

      Returns (list: ReadonlyArray<A>) => A[]

        • (list: ReadonlyArray<A>): A[]
        • Parameters

          • list: ReadonlyArray<A>

          Returns A[]

Const zip

zip: { <A, B>(xs: ReadonlyArray<A>, ys: ReadonlyArray<B>): [A, B][]; <A>(xs: ReadonlyArray<A>): <B>(ys: ReadonlyArray<B>) => [A, B][] } = curry(function zip<A, B>(xs: ReadonlyArray<A>, ys: ReadonlyArray<B>): [A, B][] {const length = Math.min(xs.length, ys.length)const newList = Array(length)for (let i = 0; i < length; ++i) {newList[i] = [xs[i], ys[i]]}return newList}) as {<A, B>(xs: ReadonlyArray<A>, ys: ReadonlyArray<B>): [A, B][]<A>(xs: ReadonlyArray<A>): <B>(ys: ReadonlyArray<B>) => [A, B][]}

Zip together two lists into a list of Tuples

param

:: [a]

param

:: [b]

returns

:: [(a, b)]

Type declaration

    • <A, B>(xs: ReadonlyArray<A>, ys: ReadonlyArray<B>): [A, B][]
    • <A>(xs: ReadonlyArray<A>): <B>(ys: ReadonlyArray<B>) => [A, B][]
    • Type parameters

      • A

      • B

      Parameters

      • xs: ReadonlyArray<A>
      • ys: ReadonlyArray<B>

      Returns [A, B][]

    • Type parameters

      • A

      Parameters

      • xs: ReadonlyArray<A>

      Returns <B>(ys: ReadonlyArray<B>) => [A, B][]

        • <B>(ys: ReadonlyArray<B>): [A, B][]
        • Type parameters

          • B

          Parameters

          • ys: ReadonlyArray<B>

          Returns [A, B][]

Functions

Const filterMaybes

  • filterMaybes<A>(list: ReadonlyArray<Maybe<A>>): A[]

flatten

Const head

  • head<A>(list: ArrayLike<A>): Nothing | Just<A>

Const last

  • last<A>(list: ArrayLike<A>): Maybe<A>

Const length

  • length<A>(list: A): number

Const reverse

  • reverse<A>(list: ReadonlyArray<A>): A[]

unnest

  • unnest<A>(nestedList: ReadonlyArray<ReadonlyArray<A>>): A[]
  • Flatten a list of lists with a depth of 1.

    returns::

    [a]

    Type parameters

    • A

    Parameters

    • nestedList: ReadonlyArray<ReadonlyArray<A>>

      :: [[a]]

    Returns A[]

Generated using TypeDoc