rxjs
Version:
Reactive Extensions for modern JavaScript
30 lines (25 loc) • 596 B
text/typescript
export class FastMap {
private values: Object = {};
delete(key: string): boolean {
this.values[key] = null;
return true;
}
set(key: string, value: any): FastMap {
this.values[key] = value;
return this;
}
get(key: string): any {
return this.values[key];
}
forEach(cb: (value: any, key: any) => void, thisArg?: any): void {
const values = this.values;
for (let key in values) {
if (values.hasOwnProperty(key) && values[key] !== null) {
cb.call(thisArg, values[key], key);
}
}
}
clear(): void {
this.values = {};
}
}