{"_id":"n-ary-huffman","_rev":"14-9b8d246a9265d18676552d2296473bc1","name":"n-ary-huffman","description":"An n-ary Huffman algorithm implementation.","dist-tags":{"latest":"4.0.0"},"versions":{"1.0.0":{"name":"n-ary-huffman","version":"1.0.0","license":"MIT","description":"An n-ary Huffman algorithm implementation.","repository":{"type":"git","url":"https://github.com/lydell/n-ary-huffman"},"keywords":["huffman","n-ary"],"scripts":{"test":"mocha","build":"coffee --compile --bare index.coffee"},"devDependencies":{"coffee-script":"^1.8.0","mocha":"^2.0.1"},"gitHead":"81b8e9fa3a48308830f0b724b8e12e62fe3d58d9","bugs":{"url":"https://github.com/lydell/n-ary-huffman/issues"},"homepage":"https://github.com/lydell/n-ary-huffman","_id":"n-ary-huffman@1.0.0","_shasum":"aaa5fda08ad8e6f354da64f8e4720d9d429e72f1","_from":".","_npmVersion":"2.1.7","_nodeVersion":"0.10.33","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"dist":{"shasum":"aaa5fda08ad8e6f354da64f8e4720d9d429e72f1","tarball":"https://registry.npmjs.org/n-ary-huffman/-/n-ary-huffman-1.0.0.tgz","integrity":"sha512-UlCGov+EQY2lp07v34SSIsuzD2oxx0ih2ntucLwom1k5bXNxtDcMISrnu2YPkx8+Efk19oTz72QnKNiIpEiOEw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDz2ZgfS63W8RS423SoOTsJ8n/Lsl52XPz+AivxCL4d5AiAbMRoUkGSAVxQ1X+scwUy/sQIF4cuGZVSkKmAlXWYbIw=="}]},"directories":{}},"2.0.0":{"name":"n-ary-huffman","version":"2.0.0","license":"MIT","description":"An n-ary Huffman algorithm implementation.","repository":{"type":"git","url":"https://github.com/lydell/n-ary-huffman"},"keywords":["huffman","n-ary"],"scripts":{"test":"mocha --ui tdd --compilers coffee:coffee-script/register","build":"coffee --compile --bare index.coffee"},"devDependencies":{"coffee-script":"^1.8.0","mocha":"^2.0.1"},"gitHead":"a96d5a1a6e434522d969999489784c217bf817df","bugs":{"url":"https://github.com/lydell/n-ary-huffman/issues"},"homepage":"https://github.com/lydell/n-ary-huffman","_id":"n-ary-huffman@2.0.0","_shasum":"3c1fb7fb59585b0720e6e0573b5c8a6d59b16428","_from":".","_npmVersion":"2.1.16","_nodeVersion":"0.10.35","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"dist":{"shasum":"3c1fb7fb59585b0720e6e0573b5c8a6d59b16428","tarball":"https://registry.npmjs.org/n-ary-huffman/-/n-ary-huffman-2.0.0.tgz","integrity":"sha512-y5ge8PKwd26m7fsqy3oUiqnuDtIRjpCV06rWBtdt6UEeQQreir4AvKTbFGfLDzKV3lupUlj9+W84ogSFs7/mTw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDvTveioi3MPwbpVODNtjlAPhM6bbrwVEOzEDTSrtP4RQIgcmEbq66zoYZcFA17yORY9QMu6/BsKj6ss0u5mI9MZtI="}]},"directories":{}},"2.1.0":{"name":"n-ary-huffman","version":"2.1.0","license":"MIT","description":"An n-ary Huffman algorithm implementation.","repository":{"type":"git","url":"https://github.com/lydell/n-ary-huffman"},"keywords":["huffman","n-ary"],"scripts":{"test":"mocha --ui tdd --compilers coffee:coffee-script/register","build":"coffee --compile --bare index.coffee"},"devDependencies":{"coffee-script":"^1.8.0","mocha":"^2.0.1"},"gitHead":"6182b7ab9ccc9d8c41db183c4fefc14d67998233","bugs":{"url":"https://github.com/lydell/n-ary-huffman/issues"},"homepage":"https://github.com/lydell/n-ary-huffman","_id":"n-ary-huffman@2.1.0","_shasum":"dce0cd50f2e7467a55f6fbea050c3a7e813480ad","_from":".","_npmVersion":"2.1.16","_nodeVersion":"0.10.35","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"dist":{"shasum":"dce0cd50f2e7467a55f6fbea050c3a7e813480ad","tarball":"https://registry.npmjs.org/n-ary-huffman/-/n-ary-huffman-2.1.0.tgz","integrity":"sha512-StsO4/LxTmqfXdP+sJDOS9AUGPFqlUx6QjDV3x8aW8M3coiQyhx6ZC/x48UADMB8hrMudvnETnNTFKCjZUL0PQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBMUvtwt31XG1Ik+6iBXYzbKtjl8kFhCY+XNqkqwVDsSAiEAl6fwoj1uYsDnLRT7vemuJeXFTWJbN8aMSKtiiext9kA="}]},"directories":{}},"2.1.1":{"name":"n-ary-huffman","version":"2.1.1","license":"MIT","description":"An n-ary Huffman algorithm implementation.","repository":{"type":"git","url":"https://github.com/lydell/n-ary-huffman"},"keywords":["huffman","n-ary"],"scripts":{"test":"mocha --ui tdd --compilers coffee:coffee-script/register","build":"coffee --compile --bare index.coffee"},"devDependencies":{"coffee-script":"^1.8.0","mocha":"^2.0.1"},"gitHead":"91a4f177003c1d0fc8c419716da978daa3bb5551","bugs":{"url":"https://github.com/lydell/n-ary-huffman/issues"},"homepage":"https://github.com/lydell/n-ary-huffman","_id":"n-ary-huffman@2.1.1","_shasum":"56e06a3c7d8f398a82706f23e00a0a49d76a42c1","_from":".","_npmVersion":"2.1.16","_nodeVersion":"0.10.35","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"dist":{"shasum":"56e06a3c7d8f398a82706f23e00a0a49d76a42c1","tarball":"https://registry.npmjs.org/n-ary-huffman/-/n-ary-huffman-2.1.1.tgz","integrity":"sha512-uRIi+o+UJKerBfJiqInFGpBW+UkgzTSMDY1AjO1BTU+Wkb1EY+3VIsvi4kKlb2TJH0/WwubfAsa0J0QvhGhBQQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB0TTlG4htb29pKeme+wc7AKqDACCySCNTrAhENwIQVmAiEAuCn4J7qoDPhCZ91pIyrvW1Nmxz2uRxgQO2nOMWbtolw="}]},"directories":{}},"3.0.0":{"name":"n-ary-huffman","version":"3.0.0","license":"MIT","description":"An n-ary Huffman algorithm implementation.","repository":{"type":"git","url":"git+https://github.com/lydell/n-ary-huffman.git"},"files":["index.js"],"keywords":["huffman","n-ary"],"scripts":{"test":"mocha --ui tdd --compilers coffee:coffee-script/register","build":"coffee --compile --bare index.coffee"},"devDependencies":{"coffee-script":"~1.10.0","mocha":"^3.0.2"},"gitHead":"9ae634a44b3d8b5b31afb8ce1eba0d559c9975e8","bugs":{"url":"https://github.com/lydell/n-ary-huffman/issues"},"homepage":"https://github.com/lydell/n-ary-huffman#readme","_id":"n-ary-huffman@3.0.0","_shasum":"337e4834a8218ffdb941d785465db5759d049ba8","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"shasum":"337e4834a8218ffdb941d785465db5759d049ba8","tarball":"https://registry.npmjs.org/n-ary-huffman/-/n-ary-huffman-3.0.0.tgz","integrity":"sha512-+4Rzpk+BD2peis9VIPFK0OIf98mNnu74nennK9bAi0vSWsTH1FYe4o+OUOqjN/JSVhVIG+ECGxe4HE5QL40oLQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMJRErjjWRFM6ZPT4IVwjtemoSk3gjTElinoTn7VIWmQIhAIUzzvarai93x0aUmfxrdr+eJC3Hmkz+ceIqkhlEN3sA"}]},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/n-ary-huffman-3.0.0.tgz_1473348881998_0.0966421163175255"},"directories":{}},"3.1.0":{"name":"n-ary-huffman","version":"3.1.0","license":"MIT","description":"An n-ary Huffman algorithm implementation.","repository":{"type":"git","url":"git+https://github.com/lydell/n-ary-huffman.git"},"files":["index.js"],"keywords":["huffman","n-ary"],"scripts":{"test":"mocha --ui tdd --compilers coffee:coffee-script/register","build":"coffee --compile --bare index.coffee"},"devDependencies":{"coffee-script":"~1.11.0","mocha":"^3.0.2"},"gitHead":"c42036f95b30e4f3709a35c3fbaea14e305b682d","bugs":{"url":"https://github.com/lydell/n-ary-huffman/issues"},"homepage":"https://github.com/lydell/n-ary-huffman#readme","_id":"n-ary-huffman@3.1.0","_shasum":"36bdb90721594d1098c082ee09411e8678eae7c5","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.5.0","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"shasum":"36bdb90721594d1098c082ee09411e8678eae7c5","tarball":"https://registry.npmjs.org/n-ary-huffman/-/n-ary-huffman-3.1.0.tgz","integrity":"sha512-hAYn4Iv1BOPsxQkpvVQyusGPc08UleIVvYDgbcFvTEH4Ig1QagNNymXAmfsvxeMozLumECT3dJmgS8KZ4L/8Kw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIESFQmH5qe88h2tbG3pbB8HSv2N2wGl6nDsFoLCpQQupAiApES8ystcHao0T1nTpS/+42WGnsaibIS6ix+J1svnyfw=="}]},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/n-ary-huffman-3.1.0.tgz_1478445521670_0.4432933134958148"},"directories":{}},"4.0.0":{"name":"n-ary-huffman","version":"4.0.0","license":"MIT","description":"An n-ary Huffman algorithm implementation.","repository":{"type":"git","url":"git+https://github.com/lydell/n-ary-huffman.git"},"keywords":["huffman","n-ary"],"scripts":{"test":"mocha --ui tdd --require coffeescript/register \"test/**/*.coffee\"","build":"coffee --compile --bare index.coffee"},"devDependencies":{"coffeescript":"1.12.7","mocha":"5.2.0"},"gitHead":"ef46a1ef52bb72c4bee3297280b6e7ee5cb90ef3","bugs":{"url":"https://github.com/lydell/n-ary-huffman/issues"},"homepage":"https://github.com/lydell/n-ary-huffman#readme","_id":"n-ary-huffman@4.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"integrity":"sha512-pEsEDhe1pr93O+asFOXN+MLi0qfKkDnVkkkFJWjbJJ2aljuYszo35QGOVkVimf7VVj5VDbZunLTWrsY3SHgN3g==","shasum":"a1b2efff0becf2d98b6591f31a29e0621b2d8320","tarball":"https://registry.npmjs.org/n-ary-huffman/-/n-ary-huffman-4.0.0.tgz","fileCount":5,"unpackedSize":10474,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbzO/lCRA9TVsSAnZWagAAXbcQAIeOEcuAv9sP4JVySbSn\nb0DJw4K1vqdm8D6AKJFy7aY7g2fg6tDCXMP+Tig1F4koblaNi/Nn6B0aSDga\n0vMwpcyQRdRPLQp6gMz+mMSHqwZED3LwDHI7OXd9Tv4ecdMWUG0vWOsESkBN\nyPcFy8B6xZSi5AzRA47mqmg4d26Sr413u632TnO1IIh82oZaSJQoPH3HSn6T\nwErjSIM7kBv3XBGqEA1NVgZg7Zzy7FTkElQTR2Cppfbq1bKD+Vn/OzUIY/Ex\nS5Lin4o5oN1cQNYGqlvp0fsMH05NHsgby1ficdMLnvmZIxwlEg9mLvkpcrtE\ndKZyIYHg3YA5rgRO3XhTbW6gCLDq0Z2xgtSqG26WC/DDGpgqL7WeIapgjPEw\n9AGwtUABh6GkznYXXncJ/459ulu9ncfW2/gWk0vVOUXP6CikWAEy7jF0NacC\n78PYwZhLGUE22JdO3oBnAjU3P2h+ci4QHNCDskGSzQ3sa/t7Xmqx8NBbLiGx\nl00bKQjNEQgB9pq9eEweudiPCJAVhmgSE+FYSBckKZA8RO1dJFCSIfaULKa4\nhILj2cHMhYVXtfKExjXrAbGkbBpF+/2HJqY75NFcxMOJR6k51Gswr34YUQIj\nMmKtD0LR9gtTolFeGX2YeDNlZ6k6x1rlxFlYUv2s+YE+JLxwYIq7EU6Dz2VP\nhw1S\r\n=wsGq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHnCPyZWm14rKPDfb5ebF9e4FIiXR0VHcENmcDI72XS7AiBt/+Aq8MDBM4jyeOhk6CTO78+r6uomCXyls8YEFnFVpw=="}]},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/n-ary-huffman_4.0.0_1540157413156_0.5732252361306018"},"_hasShrinkwrap":false}},"readme":"Overview [![Build Status](https://travis-ci.org/lydell/n-ary-huffman.svg?branch=master)](https://travis-ci.org/lydell/n-ary-huffman)\n========\n\n```js\nvar huffman = require(\"n-ary-huffman\")\n\nvar names = [\"Alfa\", \"Bravo\", \"Charlie\", \"Delta\", \"Echo\", \"Foxtrot\", \"Golf\"]\nvar items = names.map(function(name, index) {\n  return {\n    name: name,\n    weight: index,\n    codeWord: null\n  }\n})\n\nvar alphabet = \"0123\"\n\nvar tree = huffman.createTree(items, alphabet.length)\ntree.assignCodeWords(alphabet, function(item, codeWord) {\n  item.codeWord = codeWord\n})\n\nconsole.log(items)\n// [\n//   { name: 'Alfa',    weight: 0, codeWord: '13' },\n//   { name: 'Bravo',   weight: 1, codeWord: '12' },\n//   { name: 'Charlie', weight: 2, codeWord: '11' },\n//   { name: 'Delta',   weight: 3, codeWord: '10' },\n//   { name: 'Echo',    weight: 4, codeWord: '3'  },\n//   { name: 'Foxtrot', weight: 5, codeWord: '2'  },\n//   { name: 'Golf',    weight: 6, codeWord: '0'  }\n// ]\n```\n\nInstallation\n============\n\n`npm install n-ary-huffman`\n\n```js\nvar huffman = require('n-ary-huffman')\n```\n\n\nUsage\n=====\n\n`createTree(elements, n, [options])`\n------------------------------------\n\n`elements` is an array of objects. Each object is expected to have a `weight`\nproperty which represents the _weight_ of the object, which is a number.\n\nReturns a new `BranchPoint`—the root of an `n`-ary huffman tree, consisting of\nall the items in `elements` as well as `BranchPoint`s. Each `BranchPoint` has\n`n` children (except the deepest one which might have fewer, depending on\n`elements.length`).\n\n`options`:\n\n- sorted: `Boolean`. Defaults to `false`. In order to create the tree,\n  `elements` needs to be sorted after the weights in descending order. Enable\n  this option if `elements` already is sorted this way, to skip sorting again.\n\n`new BranchPoint(children, weight)`\n-----------------------------------\n\nInstance properties:\n\n- children: `children`\n- weight: `weight`\n\nSee `createTree(…)` above for more information.\n\n`BranchPoint.prototype.assignCodeWords(alphabet, callback, prefix=\"\")`\n----------------------------------------------------------------------\n\nAssign a _code word_ to each element in the tree. The larger the weight of an\nelement, the shorter the code word.\n\n`alphabet` is a string or an array of characters to use for the code words. Make\nsure that the alphabet is at least as long the arity of the tree. Note: Don’t\nrepeat characters, or you’ll get invalid code words.\n\n`callback(element, codeWord)` is run for each object in the tree.\n\n`prefix` (optional) will be added at the beginning of each code word.\n\n\nLicense\n=======\n\n[The X11 “MIT” License](LICENSE).\n","maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"time":{"modified":"2022-06-20T18:49:15.199Z","created":"2014-12-06T20:23:30.864Z","1.0.0":"2014-12-06T20:23:30.864Z","2.0.0":"2015-01-22T22:06:12.632Z","2.1.0":"2015-01-23T17:47:38.928Z","2.1.1":"2015-01-23T18:00:50.119Z","3.0.0":"2016-09-08T15:34:43.326Z","3.1.0":"2016-11-06T15:18:43.416Z","4.0.0":"2018-10-21T21:30:13.274Z"},"homepage":"https://github.com/lydell/n-ary-huffman#readme","keywords":["huffman","n-ary"],"repository":{"type":"git","url":"git+https://github.com/lydell/n-ary-huffman.git"},"bugs":{"url":"https://github.com/lydell/n-ary-huffman/issues"},"license":"MIT","readmeFilename":"README.md"}