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