Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/bimPublic

Bidirectional dictionaries based on the ES6 Map & WeakMap

NotificationsYou must be signed in to change notification settings

inker/bim

Repository files navigation

NPM versionDownloadsDependency statusDev Dependency status

A bidirectional map based on the ES6 Map object containing additional methods to retrive keys by values, delete key-value pairs by values and check the existence of keys by values. The module contains two classes:BiMap &WeakBiMap based onMap &WeakMap respectively.

Installation

npm install --save bim

Usage

Same as normalMap &WeakMap, plus thegetKey,hasValue &deleteValue methods.

import{WeakBiMap}from'bim'// create objects to use as keysconsta={i:'foo',j:8,}constb={k:'bar',p:11,}// create the bidirectional weak mapconstwbm=newWeakBiMap()wbm.set(a,5)wbm.set(b,6)wbm.deleteValue(5)// now only has { k: 'bar', p: 11 } => 6wbm.hasValue(5)// falseconstc={h:'quux',z:100,}wbm.set(c,7)wbm.hasValue(7)// truewbm.getKey(7)// { h: 'quux', z: 100 }

About

Bidirectional dictionaries based on the ES6 Map & WeakMap

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp