UNPKG

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