Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A dictionary which can be used with multiple keys
JavaScript
Branch: master
Failed to load latest commit information.
Gruntfile.js Adding grunt
README.md updating read me
multi-key-dict.js Adding grunt
package.json release 0.0.3
test.multi-key-dict.js Adding grunt

README.md

multi-key-dictionary

This is a node.js lib which provides a dictionary which can have multiple keys.

Installation

npm install multi-key-dictionary

Usage

  1. Create a new object

    var Dict = require('multi-key-dictionary');
    var dict = new Dict();
  2. Add values to the dictionary object. The keys can be passed as arguments or as an array.

    NOTE The key parameter - ['a', 'b', 'c'] and ['a','c','b'] would represent two different keys and will store two different values. The order of keys is thus important.

    //Passing keys as arguments.
    dict.add('a','b','c',34);
    
    //Pass keys as an array.
    dict.add(['a','x','y'],45);

    In both cases the last parameter is considered as the value of the key.

  3. Getting/Deleting the value using the get method. Here also the keys can be passed as arguments or as an array.

    var x = dict.get('a','b','c'); // returns 34
    dict.remove('a','b','c');
  4. A JS object is created to maintain the dictionary, which can be accessed by the items property of the dictionary. js console.log(dict.items);//Will return the complete dictionary.
Something went wrong with that request. Please try again.