list
Version:
Fast purely functional immutable lists.
62 lines (61 loc) • 2.77 kB
TypeScript
export * from "./index";
declare module "./index" {
interface List<A> {
empty(): List<any>;
of<B>(b: B): List<B>;
append(value: A): List<A>;
nth(index: number): A | undefined;
prepend(value: A): List<A>;
append(value: A): List<A>;
first(): A | undefined;
last(): A | undefined;
map<B>(f: (a: A) => B): List<B>;
pluck<K extends keyof A>(key: K): List<A[K]>;
foldl<B>(f: (acc: B, value: A) => B, initial: B): B;
reduce<B>(f: (acc: B, value: A) => B, initial: B): B;
foldr<B>(f: (value: A, acc: B) => B, initial: B): B;
reduceRight<B>(f: (value: A, acc: B) => B, initial: B): B;
forEach(callback: (a: A) => void): void;
filter(predicate: (a: A) => boolean): List<A>;
reject(predicate: (a: A) => boolean): List<A>;
partition(predicate: (a: A) => boolean): List<List<A>>;
join(separator: string): string;
ap<B>(listF: List<(a: A) => B>): List<B>;
flatten(this: List<List<A>>): List<A>;
chain<B>(f: (a: A) => List<B>): List<B>;
every(predicate: (a: A) => boolean): boolean;
some(predicate: (a: A) => boolean): boolean;
none(predicate: (a: A) => boolean): boolean;
indexOf(element: A): number;
find(predicate: (a: A) => boolean): A | undefined;
findIndex(predicate: (a: A) => boolean): number;
includes(element: A): boolean;
equals(secondList: List<any>): boolean;
equalsWith(f: (a: A, b: A) => boolean, secondList: List<any>): boolean;
concat(right: List<A>): List<A>;
update(index: number, a: A): List<A>;
adjust(index: number, f: (a: A) => A): List<A>;
slice(from: number, to: number): List<A>;
take(n: number): List<A>;
takeWhile(predicate: (a: A) => boolean): List<A>;
takeLast(n: number): List<A>;
splitAt(index: number): [List<A>, List<A>];
remove(from: number, amount: number): List<A>;
drop(n: number): List<A>;
dropWhile(predicate: (a: A) => boolean): List<A>;
dropLast(n: number): List<A>;
pop(): List<A>;
tail(): List<A>;
toArray(): A[];
insert(index: number, element: A): List<A>;
insertAll(index: number, elements: List<A>): List<A>;
reverse(): List<A>;
zipWith<B, C>(f: (a: A, b: B) => C, bs: List<B>): List<C>;
zip<B>(bs: List<B>): List<[A, B]>;
sort<A extends Comparable>(this: List<A>, l: List<A>): List<A>;
sortBy<B extends Comparable>(f: (a: A) => B): List<A>;
sortWith(comparator: (a: A, b: A) => Ordering): List<A>;
group(): List<List<A>>;
groupWith<A>(f: (a: A, b: A) => boolean): List<List<A>>;
}
}