collectionsts
Version:
collectionsts =============
26 lines (25 loc) • 779 B
TypeScript
export interface ICollection {
forEach(op: Function): void;
toArray(): any[];
add(elem: any): void;
remove(elem: IUnique): void;
removeById(id: string): void;
get(id: string): void;
length: number;
}
export interface IUnique {
uid: string;
}
export class Collection implements ICollection {
private _items;
private _length;
public length : number;
public get(id: string): IUnique;
private getHash();
public add(elem: any): void;
public remove(elem: IUnique): void;
public removeById(id: string): void;
public forEach(op: (elem: IUnique, id: string, i: number, list: Collection) => void): void;
public toArray(): IUnique[];
}
export function toUnique(obj: any, id: string): IUnique;