dictionaryjs

A simple dictionary wrapper for JavaScript objects providing associative array functionality and helpful methods. Methods include: get, set, getDefault, remove, has, size, empty, asyncEmpty, forEach, and asyncForEach.

dictionaryjs

  • Get and Set entries as key/value pairs.
  • Remove key from dictionary
  • Get length of dictionary
  • Built-in forEach looping and asyncForEach looping
npm install dictionaryjs

###examples

var Dictionary = require('dictionaryjs');

var dict = new Dictionary();

//Setting records examples dict.set("key","value"); dict.set("test","testing"); dict.set(42,"example"); dict.set(105,"test");

//Delete record example dict.remove(105); dict.remove("test");

//Return length of dictionary console.log(dict.size());

//Get records examples console.log(dict.get(42)); console.log(dict.get("key"));

//For each looping example dict.forEach(function(key,value) { console.log(key+"="+value); });

//Async for each looping example dict.asyncForEach(function(key,value,next) { console.log(key+"="+value); next(); });

###to do

  • Use some kind of hashing function to store keys