{"dist":{"shasum":"83a8edd895e993c5b11625822b278e2b497f967c","tarball":"https://registry.npmjs.org/persistent-hash-trie/-/persistent-hash-trie-0.3.2.tgz","integrity":"sha512-ac0iqKVEsle0MC4XHd0TiEHYkL7Ul5Ma6Ev13nYOxlgfqTCJ7ctFWByuSLr/rhQou/Brb9t+rzDmLBTO4NBcxQ==","signatures":[{"sig":"MEQCIBMGK5Tr9AWckw0q0Ga36Ncv3jC5LyNdaF8C0adEMKpBAiALunhdN9eMfSds8seOOR23QOHWb9OOp3RXTI877NQ+2w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/persistent-hash-trie.js","name":"persistent-hash-trie","_from":".","author":{"name":"hughfdjackson"},"readme":"# 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### 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","prepublish":"npm test"},"_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.2.2","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":{"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.3.2","version":"0.3.2"}