1.0.0 • Published 8 years ago

string-dict v1.0.0

Weekly downloads
4
License
BSD-3-Clause
Repository
github
Last release
8 years ago

string-dict

A dictionary prototype for JavaScript using strings as keys. It avoids common JS object pitfalls and adds some convenience methods known from JS arrays.

Usage

var Dict = require("string-dict");

var myDict = new Dict({
    "weather": "good",
    "mood": "splendid",
    "wants": "food",
    "warts": 3
});

myDict.set("hasOwnProperty", "foo");
myDict.has("hasOwnProperty"); // true
myDict.get("hasOwnProperty"); // "foo"

myDict.forEach(console.log.bind(console));
myDict.keys(); // ["weather", "mood", "wants", "warts", "hasOwnProperty"]