UNPKG

data-validator-js

Version:
36 lines (35 loc) 1.17 kB
export interface IDictionary<K extends number | string, V> { add(key: K, value: V): boolean; upsert(key: K, value: V): void; clear(): void; containsKey(key: K): boolean; containsValue(value: V): boolean; count(): number; getKeys(): K[]; getValues(): V[]; getValue(key: K): V | boolean; update(key: K, value: V): boolean; remove(key: K): boolean; } export default class HashMap<V> implements IDictionary<string, V> { private data; add(key: string, value: V): boolean; upsert(key: string, value: V): void; clear(): void; containsKey(key: string): boolean; containsValue(value: V): boolean; count(): number; getValue(key: string): V | boolean; getKeys(): string[]; getValues(): V[]; remove(key: string): boolean; update(key: string, value: V): boolean; /** * Returns the internal object. * The current implementation returns data: { the actual key value pairs} as hashmap. * Wherever there is a need to pass only the key value pairs without data being appended along with it, return this.data. */ getInternalObject(): { [key: string]: V; }; }