{"dist":{"shasum":"fdde131fc82d20c23317298bb82cfbbc661ac4a4","tarball":"https://registry.npmjs.org/harmony-collections/-/harmony-collections-0.2.0.tgz","integrity":"sha512-+og99vaiTSNs+KIsFTw4VW0flUn9fft81lRdn/ePuAOLQ/M2gHRWCJQehtOXKlZr1fyBql+6TN8s2mLs7BdBjw==","signatures":[{"sig":"MEUCIQCETUeiL3ivN4kkeCHSvYPyYgpU4ZQ5gMr6LMH6Gl9o3wIgcLf9NpB9F2oEuhyU+4C0mDelfg/Qth5qcAFJpLQa0jg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"harmony-collections.js","name":"harmony-collections","author":{"url":"http://bbenvie.com","name":"Brandon Benvie","email":"brandon@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\nWeakMap won't give the same garbage collector magic as the native one but it can be used with the same code.\n\n\n# Shim Usage\n\nThe function `attachIfMissing` is exported along with Map, WeakMap, and Set which will inspect the global object for the existence of Map, WeakMap, and Set in turn and add ones that are missing. Each one is checked separately because WeakMap's existence predates the other two so there's no guarantee which may already exist. If the global object is the window then `attach` is automatically executed.\n\n\n# Collections Usage\n\nMaps, WeakMaps, 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.\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. Primitives are valid keys but uniqueness is matched by their value since primitives don't have identity. Objects are matched by identity. Returns the value passed in.\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* __keys__ `map.keys()`. Returns array of contained keys.\n* __values__ `map.values()`. Return array of contained values.\n* __iterate__ `map.iterate(callback, context)`. Loop through the Map executing callback with the signature `callback.call(context || null, key, value, index)`.\n\n*All possible values* are valid keys, including undefined, null, and NaN.\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* __values__ `set.values()`. Return array of contained values.\n* __iterate__ `set.iterate(callback, context)`. Loop through the Set executing callback with the signature `callback.call(context || null, value, index)`.\n\n\n# TODO\n\n* Check up on iteration semantics for ES6 as they stand now.","engines":{"node":"0.6"},"_npmUser":{"name":"benvie","email":"brandon@bbenvie.com"},"homepage":"https://github.com/Benvie/ES6-Harmony-Collections-Shim","keywords":["harmony","collection","weakmap","map","set","ecmascript","shim"],"repository":{"url":"git://github.com/Benvie/ES6-Harmony-Collections-Shim.git","type":"git"},"_npmVersion":"1.1.0-beta-4","description":"Shim to provide Map, Set, and WeakMap if they're not available","maintainers":[{"name":"benvie","email":"brandon@bbenvie.com"}],"_nodeVersion":"v0.7.0-pre","dependencies":{},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":false,"_id":"harmony-collections@0.2.0","version":"0.2.0"}