{"id":13634763,"url":"https://github.com/zhipeng-jia/snappyjs","last_synced_at":"2026-02-19T07:33:06.010Z","repository":{"id":37601796,"uuid":"50250684","full_name":"zhipeng-jia/snappyjs","owner":"zhipeng-jia","description":"JavaScript implementation of Google's Snappy compression library","archived":false,"fork":false,"pushed_at":"2023-03-06T04:22:47.000Z","size":983,"stargazers_count":163,"open_issues_count":10,"forks_count":31,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-01-23T18:27:22.833Z","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/zhipeng-jia.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-23T17:58:09.000Z","updated_at":"2025-11-02T21:13:44.000Z","dependencies_parsed_at":"2024-06-18T12:41:59.181Z","dependency_job_id":"0bb7f005-973b-4d8b-bb25-6b0a1917556c","html_url":"https://github.com/zhipeng-jia/snappyjs","commit_stats":{"total_commits":96,"total_committers":8,"mean_commits":12.0,"dds":0.125,"last_synced_commit":"3ccc1b6cd959c8618f3dc943f296f9f5ba5ccaf9"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/zhipeng-jia/snappyjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhipeng-jia%2Fsnappyjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhipeng-jia%2Fsnappyjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhipeng-jia%2Fsnappyjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhipeng-jia%2Fsnappyjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhipeng-jia","download_url":"https://codeload.github.com/zhipeng-jia/snappyjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhipeng-jia%2Fsnappyjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29606927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-08-02T00:00:33.327Z","updated_at":"2026-02-19T07:33:05.993Z","avatar_url":"https://github.com/zhipeng-jia.png","language":"JavaScript","funding_links":[],"categories":["compress (压缩)"],"sub_categories":[],"readme":"# SnappyJS [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) ![Node.js CI](https://github.com/zhipeng-jia/snappyjs/actions/workflows/test.yml/badge.svg)\nA pure JavaScript implementation of Google's [Snappy](https://github.com/google/snappy) compression library.\n\nThis implementation is reasonably fast (see benchmark below). It takes advantage of `ArrayBuffer`.\n\n## Install\n\nIf using with Node.js,\n~~~\nnpm install snappyjs\n~~~\n\nIf using with Bower,\n~~~\nbower install snappyjs\n~~~\n\n## Usage\n\n### Node.js\n\nSnappyJS works with Node.js 10.x or later.\n~~~javascript\nvar SnappyJS = require('snappyjs')\nvar buffer = new ArrayBuffer(100)\n// fill data in buffer\nvar compressed = SnappyJS.compress(buffer)\nvar uncompressed = SnappyJS.uncompress(compressed)\n~~~\n\n### Browser\n\nYou can also use SnappyJS in browser. Adding `dist/snappyjs.js` or `dist/snappyjs.min.js` will introduce `SnappyJS` in the global scope.\n\nSnappyJS relies on `ArrayBuffer`. All major browsers support it now ([http://caniuse.com/#feat=typedarrays](http://caniuse.com/#feat=typedarrays)). Also, as I tested, SnappyJS has high performance on latest version of Google Chrome, Safari, Firefox, and Microsoft Edge.\n\n**When using webpack to build your project**, and you plan to only use `ArrayBuffer` or `Uint8Array` as input parameters, make sure to put the following in your webpack config to prevent it from automatically bundling a `Buffer` polyfill:\n\n```js\n  node: {\n    Buffer: false,\n  }\n```\n\n## API\n\n### SnappyJS.compress(input)\n\nCompress `input`, which must be type of `ArrayBuffer`, `Buffer`, or `Uint8Array`.\nCompressed byte stream is returned, with same type of `input`.\n\n### SnappyJS.uncompress(compressed, [maxLength])\n\nUncompress `compressed`, which must be type of `ArrayBuffer`, `Buffer`, or `Uint8Array`.\nUncompressed byte stream is returned, with same type of `compressed`.\n\nIf `maxLength` is provided, uncompress function will throw an exception if the data length\nencoded in the header exceeds `maxLength`. This is a protection mechanism for malicious data stream.\n\n## Benchmark\n\nAlthough JavaScript is dynamic-typing, all major JS engines are highly optimized.\nThus well-crafted JavaScript code can have competitive performance even compared to native C++ code.\n\nI benchmark SnappyJS against `node-snappy` (which is Node.js binding of native implementation).\n\nCommand for benchmark is `node benchmark`. Below is the result running on Node.js v5.5.0.\n\n~~~\nReal text #1 (length 618425, byte length 618425), repeated 100 times:\nnode-snappy#compress x 2.31 ops/sec ±1.47% (10 runs sampled)\nsnappyjs#compress x 0.91 ops/sec ±0.92% (7 runs sampled)\nnode-snappy#uncompress x 7.22 ops/sec ±4.07% (22 runs sampled)\nsnappyjs#uncompress x 2.45 ops/sec ±1.53% (11 runs sampled)\n\nReal text #2 (length 3844590, byte length 3844591), repeated 10 times:\nnode-snappy#compress x 7.68 ops/sec ±2.78% (23 runs sampled)\nsnappyjs#compress x 3.56 ops/sec ±1.44% (13 runs sampled)\nnode-snappy#uncompress x 17.94 ops/sec ±4.71% (33 runs sampled)\nsnappyjs#uncompress x 7.24 ops/sec ±2.57% (22 runs sampled)\n\nRandom string (length 1000000, byte length 1500098), repeated 50 times:\nnode-snappy#compress x 6.69 ops/sec ±5.23% (21 runs sampled)\nsnappyjs#compress x 2.39 ops/sec ±2.54% (10 runs sampled)\nnode-snappy#uncompress x 14.94 ops/sec ±6.90% (40 runs sampled)\nsnappyjs#uncompress x 5.92 ops/sec ±4.28% (19 runs sampled)\n\nRandom string (length 100, byte length 147), repeated 100000 times:\nnode-snappy#compress x 4.17 ops/sec ±2.96% (15 runs sampled)\nsnappyjs#compress x 5.45 ops/sec ±1.51% (18 runs sampled)\nnode-snappy#uncompress x 4.39 ops/sec ±3.83% (15 runs sampled)\nsnappyjs#uncompress x 14.01 ops/sec ±2.06% (38 runs sampled)\n~~~\n\nFrom the result, we see that SnappyJS has 35%~45% performance of native implementation.\nIf input size is small, SnappyJS may have better performance than `node-snappy`.\nIt is because calling native function in JS is much more expensive than calling JS function.\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhipeng-jia%2Fsnappyjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhipeng-jia%2Fsnappyjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhipeng-jia%2Fsnappyjs/lists"}