{"id":18743917,"url":"https://github.com/guyoung/zlib-module.js","last_synced_at":"2025-07-22T06:04:12.308Z","repository":{"id":233723329,"uuid":"787695051","full_name":"guyoung/zlib-module.js","owner":"guyoung","description":"compact zlib, deflate, inflate, zip library in JavaScript CommonJS module","archived":false,"fork":false,"pushed_at":"2024-04-20T08:58:14.000Z","size":828,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T01:08:48.481Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guyoung.png","metadata":{"files":{"readme":"README-zlibjs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-17T02:16:34.000Z","updated_at":"2024-04-20T08:58:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"2ab8a637-b074-4b65-84e9-398e643e750d","html_url":"https://github.com/guyoung/zlib-module.js","commit_stats":null,"previous_names":["guyoung/zlib-module.js"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/guyoung/zlib-module.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyoung%2Fzlib-module.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyoung%2Fzlib-module.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyoung%2Fzlib-module.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyoung%2Fzlib-module.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guyoung","download_url":"https://codeload.github.com/guyoung/zlib-module.js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyoung%2Fzlib-module.js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266437369,"owners_count":23928235,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-07T16:13:08.953Z","updated_at":"2025-07-22T06:04:12.297Z","avatar_url":"https://github.com/guyoung.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"zlib.js\n=======\n\n\nzlib.js is ZLIB(RFC1950), DEFLATE(RFC1951), GZIP(RFC1952) and PKZIP implementation in JavaScript.\n\n\nUsage\n------\n\nUse one in \"bin\" directory.\n\n- zlib_and_gzip.min.js: ZLIB + GZIP\n    + (Raw)\n        * rawdeflate.js: Raw Deflate\n        * rawinflate.js: Raw Inflate\n    + zlib.min.js: ZLIB Inflate + Deflate\n        * inflate.min.js: ZLIB Inflate\n        * deflate.min.js: ZLIB Deflate\n        * inflate_stream.min.js: ZLIB Inflate (stream mode)\n    + (GZIP)\n        * gzip.min.js: GZIP\n        * gunzip.min.js: GUNZIP\n    + (PKZIP)\n        * zip.min.js ZIP\n        * unzip.min.js UNZIP\n- node-zlib.js: (ZLIB + GZIP for node.js)\n\n\n### Compression\n\n#### Raw Deflate\n\n```js\n// plain = Array.\u003cnumber\u003e or Uint8Array\nvar deflate = new Zlib.RawDeflate(plain);\nvar compressed = deflate.compress();\n```\n\n#### Raw Deflate Option\n\nSee ZLIB Option.\n\n#### ZLIB\n\n```js\n// plain = Array.\u003cnumber\u003e or Uint8Array\nvar deflate = new Zlib.Deflate(plain);\nvar compressed = deflate.compress();\n```\n\n##### ZLIB Option\n\nSecond argument of Zlib.Deflate constructor\n\n```js\n{\n    compressionType: Zlib.Deflate.CompressionType, // compression type\n    lazy: number // lazy matching parameter\n}\n```\n\n\u003ccode\u003eZlib.Deflate.CompressionType\u003c/code\u003e is enumerable,\nChoose one in \u003ccode\u003eNONE\u003c/code\u003e (Store), \u003ccode\u003eFIXED\u003c/code\u003e (Fixed Huffman Coding), \u003ccode\u003eDYNAMIC\u003c/code\u003e (Dynamic Huffman Coding).\nDefault value is \u003ccode\u003eDYNAMIC\u003c/code\u003e.\n\n\u003ccode\u003elazy\u003c/code\u003e is Lazy Matching length.\nThis parameter is deprecated.\n\n\n#### GZIP\n\nGZIP implementation is incomplete.\nHowever, there is no problem in usual use. \n\n```js\n// plain = Array.\u003cnumber\u003e or Uint8Array\nvar gzip = new Zlib.Gzip(plain);\nvar compressed = gzip.compress();\n```\n\n\n##### GZIP Option\n\n```js\n{\n    deflateOptions: Object, // see: deflate option (ZLIB Option)\n    flags: {\n        fname: boolean, // use filename?\n        comment: boolean, // use comment?\n        fhcrc: boolean // use file checksum?\n    },\n    filename: string, // filename\n    comment: string // comment\n}\n```\n\n\n#### PKZIP\n\n```js\nvar zip = new Zlib.Zip();\n// plainData1\nzip.addFile(plainData1, {\n    filename: stringToByteArray('foo.txt')\n});\nzip.addFile(plainData2, {\n    filename: stringToByteArray('bar.txt')\n});\nzip.addFile(plainData3, {\n    filename: stringToByteArray('baz.txt')\n});\nvar compressed = zip.compress();\n\nfunction stringToByteArray(str) {\n    var array = new (window.Uint8Array !== void 0 ? Uint8Array : Array)(str.length);\n    var i;\n    var il;\n\n    for (i = 0, il = str.length; i \u003c il; ++i) {\n        array[i] = str.charCodeAt(i) \u0026 0xff;\n    }\n\n    return array;\n}\n```\n\n##### PKZIP Option\n\nfilename, comment, extraField are must use Uint8Array if enabled Typed Array.\n\n```js\n{\n    filename: (Array.\u003cnumber\u003e|Uint8Array), // filename\n    comment: (Array.\u003cnumber\u003e|Uint8Array), //comment\n    extraField: (Array.\u003cnumber\u003e|Uint8Array), // extra field\n    compress: boolean, // compress when called \"addFile\" method.\n    compressionMethod: Zlib.Zip.CompressionMethod, // STORE or DEFLATE\n    os: Zlib.Zip.OperatingSystem, // MSDOS or UNIX or MACINTOSH\n    deflateOption: Object // see: ZLIB Option\n}\n```\n\n### Decompression\n\n#### Raw Deflate\n\n```js\n// compressed = Array.\u003cnumber\u003e or Uint8Array\nvar inflate = new Zlib.RawInflate(compressed);\nvar plain = inflate.decompress();\n```\n\n#### Raw Deflate Option\n\nSee ZLIB Option.\n\n#### ZLIB\n\n```js\n// compressed = Array.\u003cnumber\u003e or Uint8Array\nvar inflate = new Zlib.Inflate(compressed);\nvar plain = inflate.decompress();\n```\n\n##### ZLIB Option\n\nSecond argument of Zlib.Inflate constructor\n\n```js\n{\n    'index': number, // start position in input buffer \n    'bufferSize': number, // initial output buffer size\n    'bufferType': Zlib.Inflate.BufferType, // buffer expantion type\n    'resize': boolean, // resize buffer(ArrayBuffer) when end of decompression (default: false)\n    'verify': boolean  // verify decompression result (default: false)\n}\n```\n\n\u003ccode\u003eZlib.Inflate.BufferType\u003c/code\u003e is enumerable.\nChoose one \u003ccode\u003eADAPTIVE\u003c/code\u003e(default) and \u003ccode\u003eBLOCK\u003c/code\u003e.\n\n- \u003ccode\u003eADAPTIVE\u003c/code\u003e: buffer expansion based on compression ratio in filled buffer.\n- \u003ccode\u003eBLOCK\u003c/code\u003e: buffer expansion based on \u003ccode\u003eBufferSize\u003c/code\u003e.\n\n\n#### GZIP\n\n```js\n// compressed = Array.\u003cnumber\u003e or Uint8Array\nvar gunzip = new Zlib.Gunzip(compressed);\nvar plain = gunzip.decompress();\n```\n\n\n#### PKZIP\n\n\n```js\n// compressed = Array.\u003cnumber\u003e or Uint8Array\nvar unzip = new Zlib.Unzip(compressed);\nvar filenames = unzip.getFilenames();\nvar plain = unzip.decompress(filenames[0]);\n```\n\n\n### Node.js\n\nsee unit tests.\n\u003chttps://github.com/imaya/zlib.js/blob/master/test/node-test.js\u003e\n\n\n## Debug\n\nIf you want to know the code before compile, SourceMaps and PrettyPrint can be used.\n\n\n### Source Map\n\nIf you want to use the Source Map, use `dev` version.\n\nFor example, you want to use Inflate with Source Map.\n\n    - inflate.min.js // release version\n    - inflate.dev.min.js // development version \u003c- use this\n\n\n### Pretty Print\n\n`zlib.pretty.js` is not renamed symbol.\n\n\nHow to build\n------------\n\nBuild using Grunt and Closure Compiler.\n\n### Requirement\n\n- Grunt\n- Python\n\n### Build\n\nUse \"grunt\" command.\n\n```\n$ grunt [target]\n```\n\n#### Build target\n\ntarget         | generate file         | implementation\n---------------|-----------------------|-------------\ndeps           | deps.js               | (dependency: deps.js)\ndeflate        | deflate.min.js        | ZLIB Deflate\ninflate        | inflate.min.js        | ZLIB Inflate\ninflate_stream | inflate_stream.min.js | ZLIB Inflate (stream)\nzlib           | zlib.min.js           | ZLIB Deflate + Inflate\ngzip           | gzip.min.js           | GZIP Compression\ngunzip         | gunzip.min.js         | GZIP Decompression\nzlib_and_gzip  | zlib_and_gzip.min.js  | ZLIB + GZIP\nnode           | node-zlib.js          | ZLIB + GZIP for node.js\nzip            | zip.min.js            | PKZIP Compression\nunzip          | unzip.min.js          | PKZIP Decompression\nall            | *                     | default target\n\n\nTest\n------\n\nUnit tests are using Karma and mocha.\n\n```\n$ npm test\n```\n\n### Browser only\n\n```\n$ npm run test-karma\n```\n\n### Node.js only\n\n```\n$ npm run test-mocha\n```\n\n\nIssue\n-----\n\nPreset dictionary is not implemented.\n\n\nLicense\n--------\n\nCopyright \u0026copy; 2012 imaya.\nLicensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguyoung%2Fzlib-module.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguyoung%2Fzlib-module.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguyoung%2Fzlib-module.js/lists"}