1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | export = Yallist;
|
8 |
|
9 | declare class Yallist<T> implements Iterable<T> {
|
10 | static create<T>(): Yallist<T>;
|
11 | static create<T>(list: Yallist.ForEachIterable<T>): Yallist<T>;
|
12 | static create<T>(...items: T[]): Yallist<T>;
|
13 |
|
14 | static Node: Yallist.NodeConstructor;
|
15 |
|
16 | head: Yallist.Node<T> | null;
|
17 | tail: Yallist.Node<T> | null;
|
18 | length: number;
|
19 |
|
20 | constructor();
|
21 | constructor(list: Yallist.ForEachIterable<T>);
|
22 | constructor(...items: T[]);
|
23 |
|
24 | forEach<U = this>(callbackFn: (this: U, value: T, index: number, list: this) => void, thisArg?: U): void;
|
25 | forEachReverse<U = this>(callbackFn: (this: U, value: T, index: number, list: this) => void, thisArg?: U): void;
|
26 | get(n: number): T | undefined;
|
27 | getReverse(n: number): T | undefined;
|
28 | map<U = this, R = T>(callbackFn: (this: U, value: T, list: this) => R, thisArg?: U): Yallist<R>;
|
29 | mapReverse<U = this, R = T>(callbackFn: (this: U, value: T, list: this) => R, thisArg?: U): Yallist<R>;
|
30 | pop(): T | undefined;
|
31 | push(...items: T[]): number;
|
32 | pushNode(node: Yallist.Node<T>): void;
|
33 | reduce<U = T>(fn: (previousValue: U, currentValue: T, index: number) => U, initialValue?: U): U;
|
34 | reduceReverse<U = T>(fn: (previousValue: U, currentValue: T, index: number) => U, initialValue?: U): U;
|
35 | removeNode(node: Yallist.Node<T>): void;
|
36 | reverse(): this;
|
37 | shift(): T | undefined;
|
38 | slice(from?: number, to?: number): Yallist<T>;
|
39 | sliceReverse(from?: number, to?: number): Yallist<T>;
|
40 | splice(start: number, deleteCount: number, ...nodes: T[]): T[];
|
41 | toArray(): T[];
|
42 | toArrayReverse(): T[];
|
43 | unshift(...items: T[]): number;
|
44 | unshiftNode(node: Yallist.Node<T>): void;
|
45 |
|
46 | [Symbol.iterator](): Iterator<T>;
|
47 | }
|
48 |
|
49 | declare namespace Yallist {
|
50 | interface ForEachIterable<T> {
|
51 | forEach(callbackFn: (item: T) => void): void;
|
52 | }
|
53 |
|
54 | interface NodeConstructor {
|
55 | <T>(value: T, prev?: Node<T>, next?: Node<T>, list?: Yallist<T>): Node<T>;
|
56 | new <T>(value: T, prev?: Node<T>, next?: Node<T>, list?: Yallist<T>): Node<T>;
|
57 | }
|
58 |
|
59 | interface Node<T> {
|
60 | prev: Node<T> | null;
|
61 | next: Node<T> | null;
|
62 | value: T;
|
63 | list?: Yallist<T> | undefined;
|
64 | }
|
65 | }
|