UNPKG

7.42 kBTypeScriptView Raw
1export declare type Sizes = number[] | undefined;
2export declare class Node {
3 sizes: Sizes;
4 array: any[];
5 constructor(sizes: Sizes, array: any[]);
6}
7export declare class List<A> implements Iterable<A> {
8 readonly bits: number;
9 readonly offset: number;
10 readonly length: number;
11 readonly prefix: A[];
12 readonly root: Node | undefined;
13 readonly suffix: A[];
14 constructor(bits: number, offset: number, length: number, prefix: A[], root: Node | undefined, suffix: A[]);
15 [Symbol.iterator](): Iterator<A>;
16 toJSON(): A[];
17}
18export declare function backwards<A>(l: List<A>): Iterable<A>;
19export declare function list<A>(...elements: A[]): List<A>;
20export declare function empty<A = any>(): List<A>;
21export declare function of<A>(a: A): List<A>;
22export declare function pair<A>(first: A, second: A): List<A>;
23export declare function from<A>(sequence: A[] | ArrayLike<A> | Iterable<A>): List<A>;
24export declare function range(start: number, end: number): List<number>;
25export declare function repeat<A>(value: A, times: number): List<A>;
26export declare function times<A>(func: (index: number) => A, times: number): List<A>;
27export declare function nth<A>(index: number, l: List<A>): A | undefined;
28export declare function prepend<A>(value: A, l: List<A>): List<A>;
29export declare function append<A>(value: A, l: List<A>): List<A>;
30export declare function length(l: List<any>): number;
31export declare function first<A>(l: List<A>): A | undefined;
32export declare const head: typeof first;
33export declare function last<A>(l: List<A>): A | undefined;
34export declare function map<A, B>(f: (a: A) => B, l: List<A>): List<B>;
35export declare function pluck<A, K extends keyof A>(key: K, l: List<A>): List<A[K]>;
36export declare function foldl<A, B>(f: (acc: B, value: A) => B, initial: B, l: List<A>): B;
37export declare const reduce: typeof foldl;
38export interface Of {
39 "fantasy-land/of"<B>(a: B): Applicative<B>;
40}
41export interface Applicative<A> {
42 "fantasy-land/map"<B>(f: (a: A) => B): Applicative<B>;
43 "fantasy-land/ap"<B>(fa: Applicative<(a: A) => B>): Applicative<B>;
44}
45export declare function traverse<A, B>(of: Of, f: (a: A) => Applicative<B>, l: List<A>): any;
46export declare function sequence<A>(ofObj: Of, l: List<Applicative<A>>): any;
47export declare function scan<A, B>(f: (acc: B, value: A) => B, initial: B, l: List<A>): List<B>;
48export declare function forEach<A>(callback: (a: A) => void, l: List<A>): void;
49export declare function filter<A, B extends A>(predicate: (a: A) => a is B, l: List<A>): List<B>;
50export declare function filter<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
51export declare function reject<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
52export declare function partition<A, B extends A>(predicate: (a: A) => a is B, l: List<A>): [List<B>, List<Exclude<A, B>>];
53export declare function partition<A>(predicate: (a: A) => boolean, l: List<A>): [List<A>, List<A>];
54export declare function join(separator: string, l: List<string>): string;
55export declare function foldr<A, B>(f: (value: A, acc: B) => B, initial: B, l: List<A>): B;
56export declare const reduceRight: typeof foldr;
57export declare function ap<A, B>(listF: List<(a: A) => B>, l: List<A>): List<B>;
58export declare function flatten<A>(nested: List<List<A>>): List<A>;
59export declare function flatMap<A, B>(f: (a: A) => List<B>, l: List<A>): List<B>;
60export declare const chain: typeof flatMap;
61export declare function foldlWhile<A, B>(predicate: (acc: B, value: A) => boolean, f: (acc: B, value: A) => B, initial: B, l: List<A>): B;
62export declare const reduceWhile: typeof foldlWhile;
63export declare function every<A>(predicate: (a: A) => boolean, l: List<A>): boolean;
64export declare const all: typeof every;
65export declare function some<A>(predicate: (a: A) => boolean, l: List<A>): boolean;
66export declare const any: typeof some;
67export declare function none<A>(predicate: (a: A) => boolean, l: List<A>): boolean;
68export declare function find<A>(predicate: (a: A) => boolean, l: List<A>): A | undefined;
69export declare function findLast<A>(predicate: (a: A) => boolean, l: List<A>): A | undefined;
70export declare function indexOf<A>(element: A, l: List<A>): number;
71export declare function lastIndexOf<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>(l1: List<A>, l2: List<A>): boolean;
76export declare function equalsWith<A>(f: (a: A, b: A) => boolean, l1: List<A>, l2: List<A>): boolean;
77export declare function concat<A>(left: List<A>, right: List<A>): List<A>;
78export declare function update<A>(index: number, a: A, l: List<A>): List<A>;
79export declare function adjust<A>(index: number, f: (a: A) => A, l: List<A>): List<A>;
80export declare function slice<A>(from: number, to: number, l: List<A>): List<A>;
81export declare function take<A>(n: number, l: List<A>): List<A>;
82export declare function takeWhile<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
83export declare function takeLastWhile<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
84export declare function dropWhile<A>(predicate: (a: A) => boolean, l: List<A>): List<A>;
85export declare function dropRepeats<A>(l: List<A>): List<A>;
86export declare function dropRepeatsWith<A>(predicate: (a: A, b: A) => Boolean, l: List<A>): List<A>;
87export declare function takeLast<A>(n: number, l: List<A>): List<A>;
88export declare function splitAt<A>(index: number, l: List<A>): [List<A>, List<A>];
89export declare function splitWhen<A>(predicate: (a: A) => boolean, l: List<A>): [List<A>, List<A>];
90export declare function splitEvery<A>(size: number, l: List<A>): List<List<A>>;
91export declare function remove<A>(from: number, amount: number, l: List<A>): List<A>;
92export declare function drop<A>(n: number, l: List<A>): List<A>;
93export declare function dropLast<A>(n: number, l: List<A>): List<A>;
94export declare function pop<A>(l: List<A>): List<A>;
95export declare const init: typeof pop;
96export declare function tail<A>(l: List<A>): List<A>;
97export declare function toArray<A>(l: List<A>): A[];
98export declare function insert<A>(index: number, element: A, l: List<A>): List<A>;
99export declare function insertAll<A>(index: number, elements: List<A>, l: List<A>): List<A>;
100export declare function reverse<A>(l: List<A>): List<A>;
101export declare function isList<A>(l: any): l is List<A>;
102export declare function zip<A, B>(as: List<A>, bs: List<B>): List<[A, B]>;
103export declare function zipWith<A, B, C>(f: (a: A, b: B) => C, as: List<A>, bs: List<B>): List<C>;
104export declare type Ordering = -1 | 0 | 1;
105export interface Ord {
106 "fantasy-land/lte"(b: any): boolean;
107}
108export declare type Comparable = number | string | Ord;
109export declare function sort<A extends Comparable>(l: List<A>): List<A>;
110export declare function sortWith<A>(comparator: (a: A, b: A) => Ordering, l: List<A>): List<A>;
111export declare function sortBy<A, B extends Comparable>(f: (a: A) => B, l: List<A>): List<A>;
112export declare function group<A>(l: List<A>): List<List<A>>;
113export declare function groupWith<A>(f: (a: A, b: A) => boolean, l: List<A>): List<List<A>>;
114export declare function intersperse<A>(separator: A, l: List<A>): List<A>;
115export declare function isEmpty(l: List<any>): boolean;
116
\No newline at end of file