UNPKG

5.96 kBTypeScriptView Raw
1export declare function setEquals(equals: (a: any, b: any) => boolean): void;
2export declare type Sizes = number[] | undefined;
3export declare class Node {
4 sizes: Sizes;
5 array: any[];
6 constructor(sizes: Sizes, array: any[]);
7}
8export declare function nth<A>(index: number, l: List<A>): A | undefined;
9export declare class List<A> {
10 bits: number;
11 offset: number;
12 length: number;
13 root: Node | undefined;
14 suffix: A[];
15 prefix: A[];
16 constructor(bits: number, offset: number, length: number, root: Node | undefined, suffix: A[], prefix: A[]);
17 [Symbol.iterator](): Iterator<A>;
18}
19export declare function prepend<A>(value: A, l: List<A>): List<A>;
20export declare function append<A>(value: A, l: List<A>): List<A>;
21export declare function list<A>(...elements: A[]): List<A>;
22export declare function of<A>(a: A): List<A>;
23export declare function pair<A>(first: A, second: A): List<A>;
24export declare function empty(): List<any>;
25export declare function repeat<A>(value: A, times: number): List<A>;
26/**
27 * Generates a new list by calling a function with the current index
28 * `n` times.
29 * @param func Function used to generate list values.
30 * @param times Number of values to generate.
31 */
32export declare function times<A>(func: (index: number) => A, times: number): List<A>;
33/**
34 * Gets the length of a list.
35 *
36 * @example
37 * length(list(0, 1, 2, 3)); //=> 4
38 *
39 * @param l The list to get the length of.
40 */
41export declare function length(l: List<any>): number;
42export declare function first<A>(l: List<A>): A | undefined;
43export declare function last<A>(l: List<A>): A | undefined;
44export declare function map<A, B>(f: (a: A) => B, l: List<A>): List<B>;
45export declare function pluck<A, K extends keyof A>(key: K, l: List<A>): List<A[K]>;
46export declare function range(start: number, end: number): List<number>;
47/**
48 * Folds a function over a list. Left-associative.
49 *
50 * @example
51 * foldl((n, m) => n - m, 1, list(2, 3, 4, 5)); //=> -13
52 */
53export declare function foldl<A, B>(f: (acc: B, value: A) => B, initial: B, l: List<A>): B;
54export declare const reduce: typeof foldl;
55export declare function forEach<A>(callback: (a: A) => void, l: List<A>): void;
56export declare function filter<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
57export declare function reject<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
58export declare function partition<A>(predicate: (a: A) => boolean, l: List<A>): List<List<A>>;
59export declare function join(separator: string, l: List<string>): string;
60export declare function foldr<A, B>(f: (value: A, acc: B) => B, initial: B, l: List<A>): B;
61export declare const reduceRight: typeof foldr;
62export declare function ap<A, B>(listF: List<(a: A) => B>, l: List<A>): List<B>;
63export declare function flatten<A>(nested: List<List<A>>): List<A>;
64export declare function chain<A, B>(f: (a: A) => List<B>, l: List<A>): List<B>;
65export declare function every<A>(predicate: (a: A) => boolean, l: List<A>): boolean;
66export declare const all: typeof every;
67export declare function some<A>(predicate: (a: A) => boolean, l: List<A>): boolean;
68export declare const any: typeof some;
69export declare function none<A>(predicate: (a: A) => boolean, l: List<A>): boolean;
70export declare function find<A>(predicate: (a: A) => boolean, l: List<A>): A | undefined;
71export declare function indexOf<A>(element: A, l: List<A>): number;
72export declare function findIndex<A>(predicate: (a: A) => boolean, l: List<A>): number;
73export declare function includes<A>(element: A, l: List<A>): boolean;
74export declare const contains: typeof includes;
75export declare function equals<A>(firstList: List<A>, secondList: List<A>): boolean;
76export declare function concat<A>(left: List<A>, right: List<A>): List<A>;
77export declare function update<A>(index: number, a: A, l: List<A>): List<A>;
78export declare function adjust<A>(index: number, f: (a: A) => A, l: List<A>): List<A>;
79export declare function slice<A>(from: number, to: number, l: List<A>): List<A>;
80export declare function take<A>(n: number, l: List<A>): List<A>;
81export declare function takeWhile<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
82export declare function dropWhile<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
83export declare function takeLast<A>(n: number, l: List<A>): List<A>;
84export declare function splitAt<A>(index: number, l: List<A>): [List<A>, List<A>];
85export declare function remove<A>(from: number, amount: number, l: List<A>): List<A>;
86export declare function drop<A>(n: number, l: List<A>): List<A>;
87export declare function dropLast<A>(n: number, l: List<A>): List<A>;
88export declare function pop<A>(l: List<A>): List<A>;
89export declare const init: typeof pop;
90export declare function tail<A>(l: List<A>): List<A>;
91export declare function toArray<A>(l: List<A>): A[];
92export declare function fromArray<A>(array: A[]): List<A>;
93export declare function fromIterable<A>(iterable: IterableIterator<A>): List<A>;
94export declare function insert<A>(index: number, element: A, l: List<A>): List<A>;
95export declare function insertAll<A>(index: number, elements: List<A>, l: List<A>): List<A>;
96/**
97 * Reverses a list.
98 * @category Updater
99 * @param l The list to reverse.
100 * @returns A reversed list.
101 */
102export declare function reverse<A>(l: List<A>): List<A>;
103export declare function isList<A>(l: any): l is List<A>;
104export declare function zipWith<A, B, C>(f: (a: A, b: B) => C, as: List<A>, bs: List<B>): List<C>;
105export declare function zip<A, B>(as: List<A>, bs: List<B>): List<[A, B]>;
106export declare type Ordering = -1 | 0 | 1;
107export interface Ord {
108 "fantasy-land/lte"(b: any): boolean;
109}
110export declare type Comparable = number | string | Ord;
111export declare function sort<A extends Comparable>(l: List<A>): List<A>;
112export declare function sortWith<A>(comparator: (a: A, b: A) => Ordering, l: List<A>): List<A>;
113export declare function sortBy<A, B extends Comparable>(f: (a: A) => B, l: List<A>): List<A>;