{"bugs":{"url":"https://github.com/hughfdjackson/persistent-hash-trie/issues"},"dist":{"shasum":"4044b2fe82d723e6cecd963213f4c4c76a112552","tarball":"https://registry.npmjs.org/persistent-hash-trie/-/persistent-hash-trie-0.4.2.tgz","integrity":"sha512-7QYLjGjIhpoyYuQT+v2STXdmtR+/NnvpxOaDkXlnyKNAf8+PeYDsQCPzNQtMJdFZBRLewVEes3JLmrElMiVsmQ==","signatures":[{"sig":"MEUCIGqFTKEszsoK9uD2IkiFc24r6GUYINRW9n3YzdxWnUfKAiEA9nX/Mnqa6jD2yURMxPJzUf79E+LXk6sQ55uVl6LI4Qw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/persistent-hash-trie.js","name":"persistent-hash-trie","_from":".","author":{"name":"hughfdjackson"},"readme":"# NOTE\nThis project is no longer actively supported.  If anyone is interested in becoming the new maintainer, don't hesitate to contact me (hughfdjackson@googlemail.com).\n\nFor an alternative, consider [https://npmjs.org/package/mori](https://npmjs.org/package/mori). \n\n# persistent-hash-trie\n\nPure string:val storage, using structural sharing.\n\n[![browser support](https://ci.testling.com/hughfdjackson/persistent-hash-trie.png)](https://ci.testling.com/hughfdjackson/persistent-hash-trie)\n\n## Why\n\nThis module forms a possible basis for effecient persistent datastructures; such as those found in Clojure's PersistentHashMap and PersistentVector.\n\n## Install\n\n`npm install persistent-hash-trie`\n\n## Docs\n\n### Trie\n\n```javascript\nvar p = require('persistent-hash-trie')\n\nvar trie = p.Trie()\n```\n\n### assoc\n\nReturns a new Trie with the new key:value keys added.\n\n```javascript\nvar trie1 = p.Trie()\nvar trie2 = p.assoc(trie1, 'key', { value: true })\n```\n\n### dissoc\n\nReturns a new Trie without a specific key\n\n```javascript\nvar trie1 = p.assoc(p.Trie(), 'key', 'val')\nvar trie2 = p.dissoc(trie2, 'key')\n```\n\n### get\n\nRetrieves a value from a Trie.\n\n```javascript\nvar trie = p.assoc(p.Trie(), 'key', 'val')\np.get(trie, 'key') //= 'val'\n```\n\n### has\n\nReturns `true` or `false`, depending on whether the value is in the Trie.\n\n```javascript\nvar trie = p.assoc(p.Trie(), 'key', 'val')\np.has(trie, 'key') \t\t//= true\np.has(trie, 'not-in-here') //= false\n```\n\n### mutable\n\nReturns a mutable copy of a Trie, in the form of a js object.\n\n```javascript\nvar trie = p.assoc(p.Trie(), 'key', 'val')\np.mutable(trie) //= { key: 'val' }\n```\n\n### keys\n\nReturns an array of all keys in the trie\n\n```javascript\nvar trie = p.assoc(p.Trie(), 'key', 'val')\np.keys(trie) //= ['key']\n```\n\n### reduce\n\nThe traditional reduce - requires seed.\n\n```javascript\n// definition of `mutable` using reduce:\n\nvar mutable = function(node){\n    return p.reduce(node, addKeyVal, {})\n}\n\nvar addKeyVal = function(o, val, key){\n    o[key] = val\n    return o\n}\n```\n\nCan be cancelled early:\n\n```javascript\n\nvar some = function(node, predicate){\n\treturn p.reduce(node, function(seed, value){\n\t\tif ( !predicate(value)) return p.reduce.Break(false)\n\t\telse                    return true\n\t}, true)\n}\n```\n\n\n### Extending assoc/dissoc/get/has\n\nThe hashing and equality functions used on the keys can be overidden by passing an opts object to `assoc`, `dissoc`, `get` and `has`.\n\n```javascript\nvar p = require('persistent-hash-trie')\n\nvar opts = {\n\teq: function(a, b){ return a === b},\n\thash: function(key){ return parseInt(key, 10) }\n}\n\nvar vector = p.assoc(p.Trie(), 3, 'my-val', opts)\nvar val = p.get(vector, 3, opts)\nvar vector2 = p.dissoc(vector, 3, opts)\np.has(vector2, 3, opts) // false\n```\n\n## Running tests and benchmarks\n\n`npm test` and `npm run benchmark` are your friends.\n","license":"BSD","scripts":{"test":"mocha","benchmark":"node benchmark/benchmarks.js"},"_npmUser":{"name":"hughfdjackson","email":"hughfdjackson@googlemail.com"},"keywords":["persistent","hash","trie","pure","functional","datastructure","bagwell","clojure","immutability"],"testling":{"files":"test/*-test.js","harness":"mocha","browsers":["iexplore/6.0","iexplore/7.0","iexplore/8.0","iexplore/9.0","iexplore/10.0","chrome/4.0","chrome/23.0","firefox/3.0","firefox/17.0","safari/5.0.5","safari/5.1"]},"repository":{"url":"https://github.com/hughfdjackson/persistent-hash-trie.git","type":"git"},"_npmVersion":"1.3.11","description":"Pure string:val storage, using structural sharing","maintainers":[{"name":"hughfdjackson","email":"hughfdjackson@googlemail.com"}],"dependencies":{"string-hash":"1.1.0"},"readmeFilename":"README.markdown","devDependencies":{"mori":"0.2.0","mocha":"1.8.1","lodash":"1.0.1","benchmark":"1.0.0","microtime":"0.3.3","string-hash":"1.1.0","format-number":"0.0.0","better-stack-traces":"0.0.4"},"_id":"persistent-hash-trie@0.4.2","version":"0.4.2"}