UNPKG

conset

Version:

An ordered conditional set (you can provide your own hash) for typescript/javascript

18 lines (17 loc) 944 B
declare type HashFunction<T> = (item: T) => string; interface Conset<T> { map: Object; order: string[]; hashFunction: HashFunction<T>; } declare const create: <T>(hashFunction: HashFunction<T>, initialItems?: T[]) => Conset<T>; declare const iter: <T>(conset: Conset<T>) => IterableIterator<T>; declare const remove: <T>(conset: Conset<T>, item: T) => Conset<T>; declare const add: <T>(conset: Conset<T>, item: T) => Conset<T>; declare const contains: <T>(conset: Conset<T>, item: T) => boolean; declare const getItems: <T>(conset: Conset<T>) => T[]; declare const size: <T>(conset: Conset<T>) => number; declare const intersect: <T>(smaller: Conset<T>, larger: Conset<T>) => Conset<T>; declare const copy: <T>(conset: Conset<T>) => Conset<T>; declare const union: <T>(smaller: Conset<T>, larger: Conset<T>) => Conset<T>; export { HashFunction, Conset, create, add, remove, contains, getItems, size, iter, copy, intersect, union };