{"name":"fzstd","version":"0.1.0","description":"High performance Zstandard (de)compression","main":"./lib/index.js","module":"./esm/index.mjs","types":"./lib/index.d.ts","unpkg":"./umd/index.js","jsdelivr":"./umd/index.js","exports":{".":{"types":"./lib/index.d.ts","import":"./esm/index.mjs","require":"./lib/index.js"}},"sideEffects":false,"repository":{"type":"git","url":"git+https://github.com/101arrowz/fzstd.git"},"bugs":{"url":"https://github.com/101arrowz/fzstd/issues","email":"arjunbarrett@gmail.com"},"author":{"name":"Arjun Barrett"},"license":"MIT","keywords":["compression","decompression","zstd","zstandard","browser","node.js","tiny","fast"],"scripts":{"build":"yarn build:lib","script":"node -r ts-node/register scripts/$SC.ts","build:lib":"tsc && tsc --project tsconfig.esm.json && yarn build:rewrite && yarn build:umd","build:umd":"SC=buildUMD yarn script","build:rewrite":"SC=rewriteBuilds yarn script","prepack":"yarn build"},"devDependencies":{"@types/node":"^14.11.2","terser":"^5.3.8","ts-node":"^9.0.0","typescript":"^4.1.5","zstandard-wasm":"^1.5.0-rev.2"},"gitHead":"a2fd39615acece29ed85656f5495666144609f9d","homepage":"https://github.com/101arrowz/fzstd#readme","_id":"fzstd@0.1.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-TTvznnpde1rTv/3FOmZMbPCh75gqkJ9dKJdsKmcNiXh4olLJl3eRahHJcGzyPZjuVaytffP02Or4z5avDvqKQA==","shasum":"1d7bccb5f819e2d073a15fccea1adb7fdc7a46a9","tarball":"http://registry-npm.ywwl.com/fzstd/download/fzstd-0.1.0.tgz","fileCount":8,"unpackedSize":65109,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXQ778/1ILG9J+tbd18vFVAcN56qAls0g13CvhSq7SnAIhAJJqUCoddvNZ1WfwN7ILYCSfyPLmllybj1PJb1CLpf38"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjarNQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr5zA/9HiSPU/Orq2bkw5NvDZsuZ4sxK5cM38O5JXe51YNt6KsFn6E4\r\nQiF6lF+s37/6+z2Vp+JHBYuy1gK8aONypGHW9WFL8k5fYKKfVfBDJvgFrBRr\r\nHG7j6mo+BPNSii0zRSMx8PYJVPMgq5NmOZI4E2rvuNwVUQqYoFVZIDdrvl0K\r\n7PMGaWUlmhnZowG9AjRwZGQweAGbHeXSao3NwiosvEQTkmKrywb3XKJBIiEQ\r\nfUTFHMe8Dlq6VzHn4XEKNt1rWJbtb6sazXTKXUmLwC3l13D2hdjEyJ+wpPeX\r\nC8U33TcITqa7gginKYMdL6VuEY4hI5DsCPLvcIKSbfpU+8WNjyxbiEAtoBFe\r\naHZZHlTIbjNX0ACRA62652Wtbkeo1vJNUb4Lr4kbhjsP/OKWlpQwUJRuEgMI\r\nvT4foLZg1Hn5aUGaGm8ilVFgav5YWbN0sUfnFJXqyXyrExYVhczlNWbwQzzS\r\nfIDFgRZKxQ02hUg+aG/7Np/fYZ/lQM6SSd0t8CuVoQgvSnZLJ1spkiDGsCjE\r\naw2mN5sYN9Cj3yD+l5q2LCrkcnCwanpA0xLh2sSRvwqLWmMGTP8ZgBJT2xNd\r\ngMwXcIxUA2vROMGO0omuCWyJhGfzCZrat9IcT6UCAzgSXjy5bRpl2eXgN77P\r\nWJz0RvNTktvsbasEtF7Oqqyx1btW/IW8ATI=\r\n=dYEq\r\n-----END PGP SIGNATURE-----\r\n","size":20213,"noattachment":false,"key":"/fzstd/-/fzstd-0.1.0.tgz"},"_npmUser":{"name":"101arrowz","email":"arjunbarrett@gmail.com"},"directories":{},"maintainers":[{"name":"101arrowz","email":"arjunbarrett@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fzstd_0.1.0_1667937104492_0.9508812302596472"},"_hasShrinkwrap":false,"readme":"# fzstd\nHigh performance Zstandard decompression in a pure JavaScript, 8kB package\n\n## Usage\n\nImport:\n```js\n// I will assume that you use the following for the rest of this guide\nimport * as fzstd from 'fzstd';\n```\n\nIf your environment doesn't support ES Modules (e.g. Node.js):\n```js\nconst fzstd = require('fzstd');\n```\n\nIf you want to load from a CDN in the browser:\n```html\n<!--\nYou should use either UNPKG or jsDelivr (i.e. only one of the following)\n\nYou may also want to specify the version, e.g. with fzstd@0.01\n-->\n<script src=\"https://unpkg.com/fzstd\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/fzstd/umd/index.js\"></script>\n<!-- Now, the global variable fzstd contains the library -->\n\n<!-- If you're going buildless but want ESM, import from Skypack -->\n<script type=\"module\">\n  import * as fzstd from 'https://cdn.skypack.dev/fzstd?min';\n</script>\n```\n\nIf you are using Deno:\n```js\n// Don't use the ?dts Skypack flag; it isn't necessary for Deno support\n// The @deno-types comment adds TypeScript typings\n\n// @deno-types=\"https://cdn.skypack.dev/fzstd/lib/index.d.ts\"\nimport * as fzstd from 'https://cdn.skypack.dev/fzstd?min';\n```\n\nAnd use:\n```js\n// This is an ArrayBuffer of data\nconst compressedBuf = await fetch('/compressedData.zst').then(\n  res => res.arrayBuffer()\n);\n// To use fzstd, you need a Uint8Array\nconst compressed = new Uint8Array(compressedBuf);\n// Note that Node.js Buffers work just fine as well:\n// const massiveFile = require('fs').readFileSync('aMassiveFile.txt');\n\nconst decompressed = fzstd.decompress(compressed);\n\n// Second argument is optional: custom output buffer\nconst outBuf = new Uint8Array(100000);\n// IMPORTANT: fzstd will assume the buffer is sufficiently sized, so it\n// will yield corrupt data if the buffer is too small. It is highly\n// recommended to only specify this if you know the maximum output size.\nfzstd.decompress(compressed, outBuf);\n```\n\nYou can also use data streams to minimize memory usage while decompressing.\n```js\nlet outChunks = [];\nconst stream = new fzstd.Decompress((chunk, isLast) => {\n  // Add to list of output chunks\n  outChunks.push(chunk);\n  // Log after all chunks decompressed\n  if (isLast) {\n    console.log('Output chunks:', outChunks);\n  }\n});\n\n// You can also attach the data handler separately if you don't want to\n// do so in the constructor.\nstream.ondata = (chunk, final) => { ... }\n\n// Since this is synchronous, all errors will be thrown by stream.push()\nstream.push(chunk1);\nstream.push(chunk2);\n...\n// Last chunk must have the second parameter true\nstream.push(chunkLast, true);\n\n// Alternatively, you can push every data chunk normally and push an empty\n// chunk at the end:\n// stream.push(chunkLast);\n// stream.push(new Uint8Array(0), true);\n```\n\n## Considerations\nUnlike my Zlib implementation [`fflate`](https://github.com/101arrowz/fflate), WebAssembly ports of Zstandard are usually significantly (40-50%) faster than `fzstd`. However, they fail to decompress most archives without the decompressed size provided in advance. Moreover, they do not support streaming and thereby allocate a large amount of memory that cannot be freed. Lastly, `fzstd` is absolutely tiny: at 8kB minified and 3.8kB after gzipping, it's much smaller than most WASM implementations.\n\nPlease note that unlike the reference implementation, `fzstd` only supports a maximum backreference distance of 2<sup>25</sup> bytes. If you need to decompress files with an \"ultra\" compression level (20 or greater) AND if your files can be above 32MB decompressed, `fzstd` *might* fail to decompress properly. Consider using a WebAssembly port for files this large (though this may be difficult if you don't know the decompressed size).","publish_time":1667937104693,"_cnpm_publish_time":1667937104693,"dist-tags":{"latest":"0.1.1"}}