npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@psenger/bidirectional-map

v1.0.6

Published

Bi Directional Map ( BIDI Map ) for NodeJS

Downloads

14

Readme

Bidirectional Map

A bidirectional map, is an associative data structure in which the pairs form a one-to-one relationship. The binary relation is functional in both direction: each value is mapped to a unique key.

Table of contents

API

BiDirectionalMap

Extends Map

Bi Directional Map is a Map, in which the keys and values are registered pointing to each other ( a binary relationship ). EG A->B and B->A. This is a Advanced Data Type and is some times called an Associative Data Structure.

Type: BiDirectionalMap

Parameters

  • props Iterable? An Iterable object whose elements are key-value pairs (arrays with two elements, e.g. [[ 1, ['one','two'] ],[ 2, ['three'] ]]). Each key-value pair is added to the new Map; null values are treated as undefined.

Meta

  • version: 1.0.5

set

Sets the value for the key in the Map object. Overriding the parent set and returns the Map object. Only works with String or `Numbers.

Parameters
  • key (string | number) The key of the element to add to the BiDirectionalMap object.
  • value (string | number) The value of the element to add to the BiDirectionalMap object.

Returns BiDirectionalMap

species

Overwrite BiDirectionalMap species to the parent Map constructor

Returns MapConstructor

Example Usage

const bidiMap = new BiDirectionalMap();
bidiMap.set(1, 2).set(3, 4);
console.log (`Key(1) = Value(${bidiMap.get(1)})` );
console.log (`Key(2) = Value(${bidiMap.get(2)})` );
console.log (`Key(3) = Value(${bidiMap.get(3)})` );
console.log (`Key(4) = Value(${bidiMap.get(4)})` );
// Key(1) = Value(2)
// Key(2) = Value(1)
// Key(3) = Value(4)
// Key(4) = Value(3)
for( let [Key,Value] of bidiMap.entries()){
    console.log(`Key(${Key}) = Value(${Value})`);
}
// Key(1) = Value(2)
// Key(2) = Value(1)
// Key(3) = Value(4)
// Key(4) = Value(3)

Installation Instructions

npm install @psenger/bidirectional-map --save

or

yarn add @psenger/bidirectional-map

License

MIT License

Copyright (c) 2021 Philip A Senger

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Deployment Steps

  • create a pull request from dev to main
  • check out main
  • npm version patch -m "message here" or minor
  • npm publish
  • Then switch to dev branch
  • And then merge main into dev and push dev to origin