{"name":"persistent-hash-trie","description":"Pure string:val storage, using structural sharing","version":"0.2.3","main":"src/persistent-hash-trie.js","scripts":{"test":"mocha","prepublish":"npm test","benchmark":"node benchmark/benchmarks.js"},"dependencies":{"string-hash":"1.1.0"},"devDependencies":{"mocha":"1.8.1","lodash":"1.0.1","benchmark":"1.0.0","microtime":"0.3.3","better-stack-traces":"0.0.4"},"repository":{"type":"git","url":"https://github.com/hughfdjackson/persistent-hash-trie.git"},"testling":{"files":"test/*-test.js","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","opera/10.0","opera/12.0","safari/5.0.5","safari/5.1"],"harness":"mocha"},"keywords":["persistent","hash","trie","pure","functional","datastructure","bagwell","clojure","immutability"],"author":{"name":"hughfdjackson"},"license":"BSD","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### transient\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.transient(trie) //= { key: 'val' }\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 im = 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-script benchmark` are your friends.\n","readmeFilename":"README.markdown","_id":"persistent-hash-trie@0.2.3","dist":{"shasum":"f81ab21d47db8140e1287607931306d17355c2ba","tarball":"http://registry-npm.ywwl.com/persistent-hash-trie/download/persistent-hash-trie-0.2.3.tgz","integrity":"sha512-ePZvQoVHfA3KBUM0JXcgdqwCod9aVXiLiE3Fxsfr3CIGPc9iC3MFC1zU+jVyySq/Ruv0q4QLQn8rsAYoDWgtoA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE0KYz8rOjT4HjXjeO66wlwlQNd78QfLOsGAuxZabauUAiEA2UaNKnIwXwMbJqBUAcThBoHfu+BaQOzY4tXL8yuLQ1Q="}],"size":33872,"noattachment":false,"key":"/persistent-hash-trie/-/persistent-hash-trie-0.2.3.tgz"},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"hughfdjackson","email":"hughfdjackson@googlemail.com"},"maintainers":[{"name":"hughfdjackson","email":"hughfdjackson@googlemail.com"}],"directories":{},"publish_time":1364389810770,"_cnpm_publish_time":1364389810770,"dist-tags":{"latest":"0.4.2"}}