@allex/composite-key-weakmap
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@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

Package Sidebar

Install

npm i @allex/composite-key-weakmap

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

5.76 kB

Total Files

5

Last publish

Collaborators

  • allex