import { FlattenArray, Predicate2 } from './helper-types'; /** * Takes a string and array of strings; returns string. Curried * :: str -> str[] -> str */ export declare const joinStringArray: import("./helper-types").Curried2 & import("./helper-types").Function2; /** * Takes a string and array of any; returns string as Javascript would handle it by default. Curried * :: str -> a[] -> str */ export declare const joinArray: import("./helper-types").Curried2 & import("./helper-types").Function2; export declare function removeIndex(arr: A[], index: number): A[]; export declare function removeIndex(arr: A[]): (index: number) => A[]; /** * Takes an array and an index and returns a tuple with the item at index and array without index * * @template A * @param {A[]} arr Array to remove index from * @param {number} index Index number to remove from array * @returns {[ A, A[] ]} Tuple of [ value at index, array without index ] * @example * popIndex(2,[1,2,3,4]) * // [ 3, [1,2,4] ] */ export declare function popIndex(arr: A[], index: number): [A, A[]]; export declare function popIndex(arr: A[]): (index: number) => [A, A[]]; /** * Takes a function, `f` taking an item of type T returning a string and * an array and returns an object who's keys are the returned strings of `f` * @template T * @param {(a: T) => string} fn function takes value T from array T[] returning a string * @param {ReadonlyArray} arr an array of T[] * @returns {{ [index: string]: T[] }} * @example * groupBy( x => x % 2 ? 'odd' : 'even', [1,2,3,4,5,6,7]) * // { odd: [ 1, 3, 5, 7 ], even: [ 2, 4, 6 ] } */ export declare function groupBy(fn: (a: T) => string, arr: ReadonlyArray): { [index: string]: T[]; }; export declare function groupBy(fn: (a: T) => string): (arr: ReadonlyArray) => { [index: string]: T[]; }; /** * Takes two parameters (curried) and returns an array pair containing one of each item * @sig a -> b -> [a,b] * @category array * @param {A} a * @param {B} b * @returns {[A,B]} * @example * */ export declare function toTuple(a: A, b: B): [A, B]; export declare function toTuple(a: A): (b: B) => [A, B]; export declare const _splitAt: any; /** * Takes a number and an array, returns two arrays from array divided at split point * :: n -> a[] -> [ a[], a[] ] * @example * splitAt(2,[1,2,3,4,5,6]) // [ [1,2],[3,4,5,6] ] */ export declare function splitAt(num: number, arr: A[]): [A[], A[]]; export declare function splitAt(num: number): (arr: A[]) => [A[], A[]]; export declare const _arrayItemsMeetPredicate: any; /** * Takes a predicate (taking the current and previous values) and an array, * returns true if every item in array return true for predicate; else false. * :: ((a1,a2) -> bool) -> [a1,a2,a3...an] -> bool * @example * arrayItemsMeetPredicate( (current,previous) => current > previous , [1,2,3,4,2]) // false * arrayItemsMeetPredicate( (current,previous) => current > previous , [1,2,3,4,]) //true */ export declare function arrayItemsMeetPredicate(predicate: Predicate2, list: A[]): boolean; export declare function arrayItemsMeetPredicate(predicate: Predicate2): (list: A[]) => boolean; /** * Takes a value and an array, returns true if every item in array matches value; else false. * :: a -> a[] -> bool * @example * arrayItemsAllEqual(1,[1,2,2]) // false * arrayItemsAllEqual(1,[1,1,1]) // true */ export declare function arrayItemsAllEqual(value: A, list: A[]): boolean; export declare function arrayItemsAllEqual(value: A): (list: A[]) => boolean; /** * Takes an array of number and returns the sum value * :: number[] -> number */ export declare const sumArray: (arr: number[]) => number; /** * Removes an item from an array and returns a tuple containing * 1. The item removed at the given index * 2. The array without the item removed * * @param index * @param arr * @example * * removeAt( 2, ['a','b','c','d']) * // => [ 'c' , ['a','b','d'] ] * */ export declare function removeAt(index: number, arr: A[]): [A, A[]]; export declare function removeAt(index: number): (arr: A[]) => [A, A[]]; /** * Takes a column and a row of objects and returns the sum value at key of object * * @template K * @template V * @param {K} column * @param {{[k in K]: V}[]} rows * @returns {number} * @example * sumColumn('score', [{name: 'john', 'score': 20},{name: 'larry', score: 15}]) * // => 35 */ export declare function sumColumn(column: K, rows: { [k in K]: V; }[]): number; export declare function sumColumn(column: K): (rows: { [k in K]: V; }[]) => number; interface PossiblyCurriedArrayFold { (fn: (acc: V, item: A) => V): (arr: A[]) => V; (fn: (acc: V, item: A) => V, arr: A[]): V; } /** * Folds an array -- like reduce only the initial value position is flipped * * @export * @template A * @template V * @param {V} initial * @param {(acc: V, item: A) => V} fn * @param {A[]} arr * @returns {V} */ export declare function foldArray(initial: V, fn: (acc: V, item: A) => V, arr: A[]): V; export declare function foldArray(initialValue: V, fn: (acc: V, item: A) => V): (arr: A[]) => V; export declare function foldArray(initialValue: V): PossiblyCurriedArrayFold; /** * Reduce an array * * @export * @template A * @template V * @param {(acc: V, item: A) => V} fn * @param {V} initialValue * @param {A[]} arr * @returns {V} */ export declare function reduceArray(fn: (acc: V, item: A) => V, initialValue: V, arr: A[]): V; export declare function reduceArray(fn: (acc: V, item: A) => V, initialValue: V): (arr: A[]) => V; export declare function reduceArray(fn: (acc: V, item: A) => V): PossiblyCurriedArrayFold; /** * Flattens an array by one level. * * @template A * @param {A[]} arr * @returns {FlattenArray} */ export declare const flattenArray: (arr: A[]) => FlattenArray; /** * Takes an array an returns a copy reversed * :: a[] -> a[] */ export declare const reverse: (arr: A[]) => A[]; /** * Takes a function, arguments, and returns function with arguments applied * :: ( fn -> (... args) -> a ) -> (...args) -> a */ export declare const applyOver: (fn: (...a: any[]) => A) => (...args: any[]) => A; /** * Takes a function and its arguments, then more, arguments, and returns function with arguments applied * :: ( fn, ...args1 ) -> ( ...args2 ) -> fn(...args1,...args2) */ export declare const applyOverPartial: (fn: (...a: any[]) => A, ...args1: any[]) => (...args2: any[]) => A; /** * Takes a function f and an array a and returns an array with f mapped over a * :: ( f -> a -> b ) -> a[] -> b[] */ export declare function mapArray(fn: (item: A) => B, arr: A[]): B[]; export declare function mapArray(fn: (item: A) => B): (arr: A[]) => B[]; /** * Takes an key (or index) and an array of arrays or objects and returns * the selected key from each row * @example * pluck(1, [ [1,2,3], [4,5,6] ] ) // [2,5] */ export declare function pluck(key: B, arr: A[][]): (A | undefined)[]; export declare function pluck(key: B, arr: A[]): A[B][]; export declare function pluck(key: number): (arr: A[][]) => (A | undefined)[]; export declare function pluck(keys: A): (arr: B) => B; /** * Takes a number n and an array, returns new array with items grouped every n * :: n -> a[] -> a[][] */ export declare function chunk(n: number, arr: A[]): A[][]; export declare function chunk(n: number): (arr: A[]) => A[][]; /** * Takes an iterable and returns an array * :: Iterable -> a[] */ export declare const toArray: (iterable: NodeListOf | Iterable) => A[]; /** * Takes any iterable and returns the reverse as an array * :: Iter -> a[] */ export declare const toArrayReverse: (iter: Iterable) => A[]; export declare const getValueAt: (as: G, k: K) => G[K]; /** * Return first item in array * * @example * head( [ 1, 2, 3 ] ) // 1 * * :: a[] -> a */ export declare const head: (as: A) => A[0]; /** * Return last item in array * * @example * last( [ 1, 2, 3 ] ) // 3 * :: a[] -> a */ export declare const last: (arr: A[]) => A; /** * * predicate takes an array and an item and returns if array contains item * @example * includes([1,2,3])(1) // true */ export declare function contains(arr: A[], item: A): boolean; export declare function contains(arr: A[]): (item: A) => boolean; /** * Alias for `contains` */ export declare const includes: typeof contains; /** * Takes arguments for slice, an array, and returns sliced array * :: (...args) -> a[] -> a[] */ export declare const slice: (...args: any[]) => (list: A[]) => A[]; /** * Get the array after the head * Takes array and returns all but first element * * @example * tail( [ 1 , 2, 3, 4 ] ) // [ 2, 3, 4 ] * * :: a[] -> a[] */ export declare const tail: (arr: T[]) => T[]; /** * Get the array before the last item * Takes array and returns all but last element * * @example * init( [ 1 , 2, 3, 4 ] ) // [ 1, 2, 3 ] * * :: a[] -> a[] */ export declare const init: (arr: T[]) => T[]; /** * Take the first `n` items in an array * Takes a number n, an array, and returns an array with first n elements. Curried. * * @example * take(2, [1,2,3,4]) // [1,2] * * :: n -> a[] -> a[] */ export declare const take: (n: N, arr: T[]) => T[]; /** * Takes a number `n`, an offset, and an array returns * an array with every other `n` item skipped. * @example * every(2,1,[1,2,3,4]) // [2,4] */ export declare function every(n: number): (offset: number) => (arr: A[]) => A[]; export declare function every(n: number, offset: number): (arr: A[]) => A[]; export declare function every(n: number, offset: number, arr: A[]): A[]; /** * takes an index and an array and returns the value at array's index * @example * index(2,[1,2,3]) // 3 */ export declare function index(index: B | number, arr: A): A[B] | undefined; export declare function index(index: B | number): (arr: A) => A[B] | undefined; export {};