{"name":"snappyjs","version":"0.6.1","description":"JavaScript implementation of Google's Snappy compression library","repository":{"type":"git","url":"git+https://github.com/zhipeng-jia/snappyjs.git"},"main":"index.js","scripts":{"test":"standard && tap test.js"},"author":{"name":"Zhipeng Jia"},"license":"MIT","devDependencies":{"benchmark":"~2.1.4","bluebird":"~3.5.0","browserify":"~14.4.0","licensify":"~3.1.3","microtime":"~3.0.0","request-promise":"~4.2.1","snappy":"~6.3.5","standard":"~10.0.2","tap":"^15.0.9","uglifyify":"^5.0.2"},"keywords":["snappy"],"standard":{"ignore":["/dist/snappyjs.js","/dist/snappyjs.min.js"],"globals":["FileReader","Benchmark","SnappyJS"]},"tap":{"check-coverage":false},"gitHead":"887737695851c140e75a966167c965a9d481084b","bugs":{"url":"https://github.com/zhipeng-jia/snappyjs/issues"},"homepage":"https://github.com/zhipeng-jia/snappyjs#readme","_id":"snappyjs@0.6.1","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-YIK6I2lsH072UE0aOFxxY1dPDCS43I5ktqHpeAsuLNYWkE5pGxRGWfDM4/vSUfNzXjC1Ivzt3qx31PCLmc9yqg==","shasum":"9bca9ff8c54b133a9cc84a71d22779e97fc51878","tarball":"http://registry-npm.ywwl.com/snappyjs/download/snappyjs-0.6.1.tgz","fileCount":14,"unpackedSize":61661,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgw6puCRA9TVsSAnZWagAATvgP/2ovwt144fh5RUiLKKhW\nDsbC2QYkjdd/WEWXjz76KADkigvmd+wSgQU29AeeYUg4QDBYOOFyB5Eq9rE4\nfcPNN6OOzmsQD/dmGLhqY05FQSQU5szarOY3QNqf6FCFpwPXkVgaxxBuwmxc\nfe/GWFeWJIou1pXG9eL4JbUr+tbNzMasRBkyE34JGNE3dEtD/Zaic88LLH8f\nC/5xGaIJB9I/mzaj9Us69OruzTsPthf2gbJOnEPhSDLP39FoNiLFj8HKOUFk\nxnh8BOvAwz8Czoq6uv4y1+IRLgClyi21SZkKbkhaWzVYpcBTYdkfJA6DWGg0\nGWlls7B5dpDctEE3LzZOXJCg5wz1r0pnrv4WEzqhDTyJw4D3ruGDGmNxWoRV\ne1RxbjDZjKqMKJmNYFum7Kb5BCkFqUs2TZjeMSMoq/JLYIjbeGLIfOBZOW7y\no1j8aklbu9NeQjhmQRlABXdm29VgbZVFyRYqxeQK3qhtw4qwQixdElAgSQBa\nRjYbv0edxNgbKiG3m8Gxucla7LJ3RTEIQ/0cvtOLSO/QIkILd1VwODL5aHTm\nxmnVtvg1+0EynslrFLAWMhKApRQAb9QWfNKO4uBZCLNUE+KgwsilQe5S2vtQ\nIBFg9OKFjGePsSfIFcG8XjRoDOhMV5j93/uke7/uP2Ov1Tt348Jf8vMyYKU0\ny3YP\r\n=fJ9U\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEiLrojq0Hc+hu1RN8L4Tg5kJzuK7ex8piqZ9GJMK48GAiEA+sBOLaOokCpiPmxPGJEBAhggmt3pqA5CZqT9CUGKj9w="}],"size":12823,"noattachment":false,"key":"/snappyjs/-/snappyjs-0.6.1.tgz"},"_npmUser":{"name":"zhipengjia","email":"zhipeng.jia@outlook.com"},"directories":{},"maintainers":[{"name":"zhipengjia","email":"zhipeng.jia@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/snappyjs_0.6.1_1623435886774_0.211652161632653"},"_hasShrinkwrap":false,"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","publish_time":1623435886922,"_cnpm_publish_time":1623435886922,"dist-tags":{"latest":"0.7.0"}}