{"dist":{"shasum":"97fce7558c177d57f40998afdb56bac6718ea7b6","tarball":"https://registry.npmjs.org/harmony-collections/-/harmony-collections-0.3.2.tgz","integrity":"sha512-FWn91YMzWkLfbLhZCoYmfNr+RkWyl0Ddr/FxcT5S6bTyEfcMhGeA0zp52Eg/Kq+USS/WzPRky2fZXUEbDJedpQ==","signatures":[{"sig":"MEQCIGJH4Dlx4DqCQVN1QfJ+g0bGrgqIONkFunMC0AXn4VSoAiA5DHQsfN/9k7BKl6g+5ynJbeCk4i110KkXPwudBShM7Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"harmony-collections.js","name":"harmony-collections","author":{"name":"Brandon Benvie","email":"http://bbenvie.com"},"readme":"# Harmony Collections Shim\n\nProvides Map, Set, and WeakMap with the same usage as the new ES6 native versions. Values in Harmony Collections are not contained in the collection instance itself, like array items and object properties, but in a private store. It's not possible to get access to or inspect the store directly.\n\nFor WeakMaps this means there's no way to find what's inside it or how many items are contained, and the only way to get a reference to a value is if you have a direct reference to the key object that links to it.\n\n# Compatability\n\nWorks with IE9+, Chrome, Firefox, Safari, untested in Opera.\n\n# Collections Usage\n\nMaps, WeakMaps, Hashes, and Sets can each be created using their constructor with or without `new`. Examples:\n\n    var aWeakMap = new WeakMap;\n    var aMap = Map();\n    var aSet = new Set();\n\nItems in a collection do not appear in any manner through traditional inspection. The only way to interact with the data contained in a collection is by using the functions below.\n\n    var aWeakMap = new WeakMap;\n    aWeakMap.set(this, { secrets: 'Dark Secrets' });\n    console.log(Object.getOwnPropertyNames(aWeakMap)); // []\n    for (var k in aWeakMap) { console.log(k); }         // nothing\n    console.log(aWeakMap.get(this));                    // { secrets: 'Dark Secrets' }\n\n\n# WeakMap\n\nWeakMaps require the use of objects as keys; primitives are not valid keys. Keys are per WeakMap are unique and setting the same key will overwrite the old value. WeakMaps provide for no method of iteration or listing the keys or values contained inside. Because WeakMaps expose no method of listing keys or values, and keys are required to be full-fledged objects with unique identities, the only way to extract a value from it is by having a direct reference to the object used as the key.\n\n* __set__ `weakmap.set(key, value)`. Key is any value including objects. Only non-primitives can be used as keys. Returns undefined.\n* __get__ `weakmap.get(key)`. Returns the value that key corresponds to the key or undefined.\n* __has__ `weakmap.has(key)`. Returns boolean.\n* __delete__ `weakmap.delete(key)`. Removes value from the WeakMap if found. Returns true.\n\nWeakMaps allow for some interesting use cases like anonymous communication channels where neither side can identify the other, and no one else can eavesdrop. By using using a target object as its own key to retrieve a hidden seceret value no information about the origin can be obtained.\n\n__All non-primitives__ are valid keys, including WeakMaps themselves.\n\n\n# Map\n\nMaps are much the same as WeakMaps but they can be iterated and thus their contents can be inspected. Many use cases have no requirement for anonymity or special garbage collection, but can benefit from using objects as keys and also not having the storage contained in the Map itself.\n\n* __set__ `map.set(key, value)`. Key is any value including objects. Returns undefined.\n* __get__ `map.get(key)`. Returns the value that key corresponds to or undefined.\n* __has__ `map.has(key)`. Returns boolean.\n* __delete__ `map.delete(key)`. Removes value from the Map if found. Returns true.\n* __forEach__ `map.forEach(callback, context)`. Loop through the collection raising callback for each.\n* __map__ `map.forEach(callback, context)`. Loop through the collection adding the return value for each to an array and returns it.\n\n__All possible values__ are valid keys, including undefined, null, and NaN.\n\n\n# Hash\n\nAs an added bonus, Hash is also exported. This has the same API as a Map except it only accepts primitive keys.\n\n* __set__ `hash.set(key, value)`. Key must be primitive. Returns undefined.\n* __get__ `hash.get(key)`. Returns the value that key corresponds to or undefined.\n* __has__ `hash.has(key)`. Returns boolean.\n* __delete__ `hash.delete(key)`. Removes value from the Map if found. Returns true.\n* __forEach__ `map.forEach(callback, context)`. Loop through the collection raising callback for each.\n* __map__ `map.forEach(callback, context)`. Loop through the collection adding the return value for each to an array and returns it.\n\n__Primitives__ are valid keys, specifically numbers and strings. All input values are coerced to strings so you can give it any value, but they will be converted to string keys.\n\n\n# Set\n\nSets are similar to arrays but enforce uniqueness of values. Adding the same value twice will only result in one being added to the set.\n\n* __add__ `set.add(value)`. Inserts a value of any type into the set if it's not already in the set.\n* __has__ `set.has(value)`. Returns boolean.\n* __delete__ `set.delete(value)`. Removes value from the Set if found. Returns true.\n* __forEach__ `map.forEach(callback, context)`. Loop through the collection raising callback for each.\n* __map__ `map.forEach(callback, context)`. Loop through the collection adding the return value for each to an array and returns it.\n","_npmUser":{"name":"benvie","email":"brandon@bbenvie.com"},"homepage":"https://github.com/Benvie/ES6-Harmony-Collections-Shim","keywords":["harmony","collection","weakmap","map","set","ecmascript","shim","garbage collection",""],"repository":{"url":"https://github.com/Benvie/ES6-Harmony-Collections-Shim","type":"git"},"_npmVersion":"1.1.61","description":"Shim to provide Map, Set, and WeakMap if they're not available, with non-leaky O(1) lookup WeakMaps","maintainers":[{"name":"benvie","email":"brandon@bbenvie.com"}],"dependencies":{},"devDependencies":{"tap":"*"},"_id":"harmony-collections@0.3.2","version":"0.3.2"}