{"name":"stringmap","version":"0.2.2","description":"fast and robust stringmap","main":"stringmap.js","repository":{"type":"git","url":"https://github.com/olov/stringmap.git"},"keywords":["stringmap","hashmap","hash","dict","dictionary","__proto__"],"author":{"name":"Olov Lassus","email":"olov.lassus@gmail.com"},"license":"MIT","readme":"# stringmap.js\nA fast and robust stringmap implementation that can hold any string keys,\nincluding `__proto__`, with minimal overhead compared to a plain object.\nWorks in node and browsers.\n\nThe API is created to be as close to the ES6 Map API as possible. Prefer\n`sm.remove(\"key\")` for deleting a key. ES6 Map uses `map.delete(\"key\")`\ninstead and for that reason `sm['delete'](\"key\")` is available as a\nstringmap alias as well. Never do `sm.delete(\"key\")` unless you're\ncertain to be in the land of ES5 or later.\n\n\n\n## Examples\nAvailable in `examples.js`\n\n```javascript\nvar StringMap = require(\"stringmap\");\n\nvar sm1 = new StringMap();\nsm1.set(\"greeting\", \"yoyoma\");\nsm1.set(\"check\", true);\nsm1.set(\"__proto__\", -1);\nconsole.log(sm1.has(\"greeting\")); // true\nconsole.log(sm1.get(\"__proto__\")); // -1\nsm1.remove(\"greeting\");\nconsole.log(sm1.keys()); // [ 'check', '__proto__' ]\nconsole.log(sm1.values()); // [ true, -1 ]\nconsole.log(sm1.items()); // [ [ 'check', true ], [ '__proto__', -1 ] ]\nconsole.log(sm1.toString()); // {\"check\":true,\"__proto__\":-1}\n\nvar sm2 = new StringMap({\n    one: 1,\n    two: 2,\n});\nconsole.log(sm2.map(function(value, key) {\n    return value * value;\n})); // [ 1, 4 ]\nsm2.forEach(function(value, key) {\n    // ...\n});\nconsole.log(sm2.isEmpty()); // false\nconsole.log(sm2.size()); // 2\n\nvar sm3 = sm1.clone();\nsm3.merge(sm2);\nsm3.setMany({\n    a: {},\n    b: [],\n});\nconsole.log(sm3.toString()); // {\"check\":true,\"one\":1,\"two\":2,\"a\":{},\"b\":[],\"__proto__\":-1}\n```\n\n\n\n## Installation\n\n### Node\nInstall using npm\n\n    npm install stringmap\n\n```javascript\nvar StringMap = require(\"stringmap\");\n```\n\n### Browser\nClone the repo and include it in a script tag\n\n    git clone https://github.com/olov/stringmap.git\n\n```html\n<script src=\"stringmap/stringmap.js\"></script>\n```\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/olov/stringmap/issues"},"homepage":"https://github.com/olov/stringmap","_id":"stringmap@0.2.2","_shasum":"556c137b258f942b8776f5b2ef582aa069d7d1b1","_from":"https://registry.npmjs.org/stringmap/-/stringmap-0.2.2.tgz","_resolved":"https://registry.npmjs.org/stringmap/-/stringmap-0.2.2.tgz"}