1.0.0 • Published 5 years ago

@allex/composite-key-weakmap v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@allex/composite-key-weakmap

A map for weakly holding nested references.

Docs

CompositeKeyWeakMap.d.ts

export declare class CompositeKeyWeakMap<T> {
  private _weakMap;
  set(keys: any[], value: T): void;
  get(keys: any[]): T;
  has(keys: any[]): boolean;
  delete(keys: any[]): void;
}

Usage

import { CompositeKeyWeakMap } from @allex/composite-key-weakmap
interface ILoaderEntry {
  name: string;
}
const map = new CompositeKeyWeakMap<ILoaderEntry>();
const obj = {}
const bar = {}
map.set([ obj, bar ], 'foo')
map.get([ obj, bar ]) // -> foo

License

MIT Copyright (c) Allex Wang