{"id":21921059,"url":"https://github.com/alienhoboken/node-huffman-coding","last_synced_at":"2025-03-22T10:36:43.347Z","repository":{"id":151967092,"uuid":"44967323","full_name":"AlienHoboken/node-huffman-coding","owner":"AlienHoboken","description":"Node.js module implementing an Adaptive Huffman Coding algorithm ","archived":false,"fork":false,"pushed_at":"2015-12-17T19:05:40.000Z","size":670,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-27T10:21:49.538Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlienHoboken.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-26T12:37:58.000Z","updated_at":"2015-10-26T12:49:27.000Z","dependencies_parsed_at":"2023-04-16T06:25:12.554Z","dependency_job_id":null,"html_url":"https://github.com/AlienHoboken/node-huffman-coding","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlienHoboken%2Fnode-huffman-coding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlienHoboken%2Fnode-huffman-coding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlienHoboken%2Fnode-huffman-coding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlienHoboken%2Fnode-huffman-coding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlienHoboken","download_url":"https://codeload.github.com/AlienHoboken/node-huffman-coding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244945570,"owners_count":20536294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T20:18:27.814Z","updated_at":"2025-03-22T10:36:43.314Z","avatar_url":"https://github.com/AlienHoboken.png","language":"JavaScript","readme":"# About\nThis is an Node.js module implementing the Adaptive Huffman Coding algorithm described in Sayood's Data Compression book. The code was originally written by Id Software and Tim Angus and was compiled to Javascript using Emscripten. It was then turned into a Node.js module. The base code is taken from the ioQuake3 engine and thus this project is published under the same GNU license.\n\n#Prerequisites\nTo use, the only prerequisite is to have node.js installed. If you wish to build then you need to have the appropriate build tools installed and setup as well as Emscripten if you wish to compile to JS.\n\n#Using\nFind the module `huffman.js` in the module directory. Use huffman compress as follows:\n```JavaScript\n//Parameters: String to compress, length of string, offset within string to start compression at.\nvar huff_compress = require('./huffman.js').cwrap('compress', 'string', ['string', 'number', 'number']);\nvar msg = \"Hello, world!\";\nvar compressed_msg = huff_compress(msg, msg.length, 3);\nconsole.log(msg.length);\n```\nWould return: \"Hel[compressed text]\"\n\nTo avoid passing raw bytes from the module to the calling program, the module will return a string of hex codes representing the bytes of the encoded string. This string most be decoded into a buffer object.  You can use the following code snippet to do this for you:\n```JavaScript\n/*\n  Convenience method which turns a space delimited string of octets into a buffer\n*/\nfunction hexStrToBuffer(hexStr) {\n  var hexArr = new Array();\n  var tokens = hexStr.split(\" \");\n\n  //find all the hex octets until the second null byte\n  var firstNullHit = false;\n  for(var i=0; i \u003c tokens.length \u0026\u0026 (tokens[i] != 0 || !firstNullHit); i++) {\n    hexArr.push(\"0x\" + tokens[i]);\n    if(tokens[i] == 0)\n      firstNullHit = true;\n  }\n\n  var buffer = new Buffer(hexArr);\n  return buffer;\n}\n```\n\n#Building\nTo compile the C code to JS using Emscripten, please run: `make`\n\nTo compile the C code to a system executbale run: `make -f makefile.c`\n\n# Good to Know\nCurrently only compresison is supported, decompression is a WIP. Uses the same prebuilt frequency table as the ioQuake3 engine. This frequency table can be modified in the common.h file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falienhoboken%2Fnode-huffman-coding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falienhoboken%2Fnode-huffman-coding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falienhoboken%2Fnode-huffman-coding/lists"}