UNPKG

@panyam/tsutils

Version:

Some basic TS utils for personal use

53 lines (52 loc) 1.72 kB
import { Nullable } from "./types"; export interface ListNode<V> { nextSibling: Nullable<V>; prevSibling: Nullable<V>; } declare class MutableListNode<V> implements ListNode<MutableListNode<V>> { value: V; nextSibling: Nullable<MutableListNode<V>>; prevSibling: Nullable<MutableListNode<V>>; constructor(value: V); } export declare class ValueList<V extends ListNode<V>> { protected _firstChild: Nullable<V>; protected _lastChild: Nullable<V>; protected _size: number; constructor(...values: V[]); toJSON(): V[]; forEach(method: (val: V) => boolean | any): number; equals(another: ValueList<V>, eqlFunc: (val1: V, val2: V) => boolean): boolean; get isEmpty(): boolean; get size(): number; get first(): Nullable<V>; get last(): Nullable<V>; reversedValues(): Generator<V>; values(): Generator<V>; add(child: V, before?: Nullable<V>): this; pushFront(value: V): this; pushBack(value: V): this; remove(child: V): this; popBack(): V; popFront(): V; } export declare class List<V> { private container; constructor(...values: V[]); toJSON(): V[]; forEach(method: (val: V) => boolean | any): number; equals(another: List<V>, eqlFunc: (val1: V, val2: V) => boolean): boolean; find(target: V): Nullable<MutableListNode<V>>; get isEmpty(): boolean; get size(): number; get first(): Nullable<MutableListNode<V>>; get last(): Nullable<MutableListNode<V>>; reversedValues(): Generator<V>; values(): Generator<V>; popBack(): V; popFront(): V; pushFront(value: V): this; push(value: V): this; add(child: V, before?: Nullable<MutableListNode<V>>): this; } export {};