{"id":13455124,"url":"https://github.com/kesla/node-snappy","last_synced_at":"2025-03-24T07:32:22.781Z","repository":{"id":48644710,"uuid":"1532364","full_name":"kesla/node-snappy","owner":"kesla","description":"DEPRECATED - please use https://github.com/Brooooooklyn/snappy. Nodejs bindings to Google's Snappy compression library","archived":true,"fork":false,"pushed_at":"2021-07-16T05:13:44.000Z","size":3243,"stargazers_count":481,"open_issues_count":19,"forks_count":52,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-28T22:35:09.951Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kesla.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","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":"2011-03-27T10:57:09.000Z","updated_at":"2024-09-18T13:57:23.000Z","dependencies_parsed_at":"2022-08-31T08:41:30.952Z","dependency_job_id":null,"html_url":"https://github.com/kesla/node-snappy","commit_stats":null,"previous_names":[],"tags_count":64,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kesla%2Fnode-snappy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kesla%2Fnode-snappy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kesla%2Fnode-snappy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kesla%2Fnode-snappy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kesla","download_url":"https://codeload.github.com/kesla/node-snappy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245227567,"owners_count":20580898,"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-07-31T08:01:01.529Z","updated_at":"2025-03-24T07:32:22.418Z","avatar_url":"https://github.com/kesla.png","language":"JavaScript","readme":"# snappy [![Linux Status](https://img.shields.io/travis/kesla/node-snappy.svg?label=linux)](https://travis-ci.org/kesla/node-snappy)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fkesla%2Fnode-snappy.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkesla%2Fnode-snappy?ref=badge_shield)\n\nNodejs bindings to the [snappy](https://github.com/google/snappy) compression library\n\n[![NPM](https://nodei.co/npm/snappy.png?downloads\u0026stars)](https://nodei.co/npm/snappy/)\n\n[![NPM](https://nodei.co/npm-dl/snappy.png)](https://nodei.co/npm/snappy/)\n\n\n## Installation\n\n```bash\nnpm install snappy\n```\n\n## Example\n\n### Input\n\n```javascript\nvar snappy = require('snappy')\n\nsnappy.compress('beep boop', function (err, compressed) {\n  console.log('compressed is a Buffer', compressed)\n  // return it as a string\n  snappy.uncompress(compressed, { asBuffer: false }, function (err, original) {\n    console.log('the original String', original)\n  })\n})\n```\n\n### Output\n\n```bash\ncompressed is a Buffer \u003cSlowBuffer 09 20 62 65 65 70 20 62 6f 6f 70\u003e\nthe original String beep boop\n```\n\n## API\n\n### snappy.compress(input, callback)\n\nCompress `input`, which can be a `Buffer` or a `String`.\n\nThe `callback` function will be called with a single `error` if the operation failed for any reason. If successful the first argument will be `null` and the second argument will be the `value` as a ``Buffer`.\n\n### snappy.compressSync(input)\n\nThe synchronous version of `snappy.compress`, returns the compressed value.\n\n### snappy.uncompress(compressed, [options,] callback)\n\nUncompress `compressed` and call `callback` with `err` and `decompressed`.\n\n#### `options`\n\n* `'asBuffer'` *(boolean, default: `true`)*: Used to determine whether to return the `value` of the entry as a `String` or a Node.js `Buffer` object. Note that converting from a `Buffer` to a `String` incurs a cost so if you need a `String` (and the `value` can legitimately become a UFT8 string) then you should fetch it as one with `asBuffer: true` and you'll avoid this conversion cost.\n\nThe `callback` function will be called with a single `error` if the operation failed for any reason. If successful the first argument will be `null` and the second argument will be the `value` as a `String` or `Buffer` depending on the `asBuffer` option.\n\n### snappy.uncompressSync(compressed, [options])\n\nThe synchronous version of `snappy.uncompress`, returns the uncompressed value.\n\n### snappy.isValidCompressed(input, callback)\n\nCheck is input is a valid compressed `Buffer`.\n\nThe `callback` function will be called with a single `error` if the operation failed for any reason and the second argument will be `true` if input is a valid snappy compressed Buffer, `false` otherwise.\n\n### snappy.isValidCompressedSync(input)\n\nThe synchronous version of `snappy.isValidCompressed`, returns a boolean indicating if input was correctly compressed or not.\n\n### stream\n\nFor a streaming interface to snappy, please take a look at [snappy-stream](https://www.npmjs.org/package/snappy-stream)\n\n## [Benchmark](benchmark)\n\nThis is the result I'm seeing on my laptop (Macbook Air from 2012) running `node benchmark`\n\n```bash\n  snappy.compress() x 479 ops/sec ±0.99% (80 runs sampled)\n  zlib.gzip() x 289 ops/sec ±1.66% (86 runs sampled)\n  snappy.uncompress() x 652 ops/sec ±0.86% (43 runs sampled)\n  zlib.gunzip() x 559 ops/sec ±1.65% (64 runs sampled)\n```\n\n## License\n\nCopyright (c) 2011 - 2015 David Björklund \u0026 contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fkesla%2Fnode-snappy.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkesla%2Fnode-snappy?ref=badge_large)","funding_links":[],"categories":["Packages","JavaScript","Repository","包","目录","Serialization"],"sub_categories":["Serialization","序列化"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkesla%2Fnode-snappy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkesla%2Fnode-snappy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkesla%2Fnode-snappy/lists"}