{"name":"uint8arraylist","version":"1.5.0","description":"Append and consume bytes using only no-copy operations","author":{"name":"Alex Potsides","email":"alex@achingbrain.net"},"license":"Apache-2.0 OR MIT","homepage":"https://github.com/achingbrain/uint8arraylist#readme","repository":{"type":"git","url":"git+https://github.com/achingbrain/uint8arraylist.git"},"bugs":{"url":"https://github.com/achingbrain/uint8arraylist/issues"},"engines":{"node":">=16.0.0","npm":">=7.0.0"},"type":"module","types":"./dist/src/index.d.ts","exports":{".":{"import":"./dist/src/index.js"}},"eslintConfig":{"extends":"ipfs","parserOptions":{"sourceType":"module"}},"release":{"branches":["master"],"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"breaking":true,"release":"major"},{"revert":true,"release":"patch"},{"type":"feat","release":"minor"},{"type":"fix","release":"patch"},{"type":"chore","release":"patch"},{"type":"docs","release":"patch"},{"type":"test","release":"patch"},{"scope":"no-release","release":false}]}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits","presetConfig":{"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"chore","section":"Trivial Changes"},{"type":"docs","section":"Trivial Changes"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"]},"scripts":{"lint":"aegir lint","dep-check":"aegir dep-check dist/src/**/*.js dist/test/**/*.js","build":"tsc","pretest":"npm run build","test":"aegir test -f ./dist/test/**/*.js","test:chrome":"npm run test -- -t browser","test:chrome-webworker":"npm run test -- -t webworker","test:firefox":"npm run test -- -t browser -- --browser firefox","test:firefox-webworker":"npm run test -- -t webworker -- --browser firefox","test:node":"npm run test -- -t node --cov","test:electron-main":"npm run test -- -t electron-main","release":"semantic-release"},"dependencies":{"uint8arrays":"^3.0.0"},"devDependencies":{"aegir":"^36.1.3","it-all":"^1.0.6"},"gitHead":"fe4930e6794bd919b1acf3b3bcbd286c8f7fb3d1","_id":"uint8arraylist@1.5.0","_nodeVersion":"16.14.0","_npmVersion":"7.24.2","dist":{"integrity":"sha512-z4SGEk4yaeuk0Le1y8LwV+np2ulzdIoX1VtdQWQ/Sm9skz6pk1K9t+VuLdbap45+13Qix2mj6eV8IoB1fBLVEg==","shasum":"ad4fd819e7f62f300b93abef77fb32f20b7bce56","tarball":"http://registry-npm.ywwl.com/uint8arraylist/download/uint8arraylist-1.5.0.tgz","fileCount":8,"unpackedSize":41312,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiOI6/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrmbRAAmMTKVAROu2Cmbj/cOmrWFGSUq+p49nxklI3uhzxo6dFQhsrp\r\nWvZS+hLqhS8GAQ/KuUhu2Ys5eUPnilUEPUQJkzFqhDade39jc7agwkmbuwZb\r\nxToKa3sh/wD+QaaTM/EOIpxhJhD6JDw42g7W3HWDhQqRYWzqQzgKol+jq3LS\r\ny+/KdjXmxXhaT5Kp9GwPjCSEz9V1RILVEu5iMjMwyIPuZOVwckfoSeG6eRr5\r\npxdcKP48E6XjybAOv5M1Sk30MdEMaFAPhFTijM4Bauv8e7IQ1P0u+22soHJR\r\nOsuiowt9KENzEG1IjhFel0RGGbVOkFXNer0OhtcaDbuGi0mdv3er7b50K7Lz\r\naeE8iWqmmUVdNBNO/+MH771tcxLPZDUvCTfC0LRN+eEeNxG+L7+DeHJ70Dbc\r\noyClnIzwToFHKWOg4f06iMe2gJG7e9vSSkQ6Nsjc3u0YuFjDTGMhzrnQy7d8\r\n4pmcyja/bsSByRvrblsSJ3xm7RW7rs4Ui3utaCsWQcHZqSFKvqsmBq1O5SSz\r\nX8OZyRHoM0Zy2K+soqgxCJzIALPapAMvDRJON7CceF5Okqe06Kz6vl97argi\r\nIEUy6jEqc08OTkPH8ZW+wPDlW9UDL/kkidTIr2iKmJRIZ6xCGEm29nqQSETN\r\nk63m+I6SA+tMZfbEhBiBxTuRSfbQ1NQ07QA=\r\n=prWB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDrp5Gr9v4qfkDBIY29bY/27QjhW0D0gDANLSTSD5XXQwIhAOYM/lwTNisaca5vBchO9a9dREmjMjFCuTtqKabdLdjD"}],"size":6954,"noattachment":false,"key":"/uint8arraylist/-/uint8arraylist-1.5.0.tgz"},"_npmUser":{"name":"achingbrain","email":"alex@achingbrain.net"},"directories":{},"maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/uint8arraylist_1.5.0_1647873726844_0.21042448813103598"},"_hasShrinkwrap":false,"readme":"[![codecov](https://img.shields.io/codecov/c/github/achingbrain/uint8arraylist.svg?style=flat-square)](https://codecov.io/gh/achingbrain/uint8arraylist)\n[![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/uint8arraylist/js-test-and-release.yml?branch=main\\&style=flat-square)](https://github.com/achingbrain/uint8arraylist/actions/workflows/js-test-and-release.yml?query=branch%3Amain)\n\n> Append and consume bytes using only no-copy operations\n\n# About\n\nA class that lets you do operations over a list of Uint8Arrays without\ncopying them.\n\n```js\nimport { Uint8ArrayList } from 'uint8arraylist'\n\nconst list = new Uint8ArrayList()\nlist.append(Uint8Array.from([0, 1, 2]))\nlist.append(Uint8Array.from([3, 4, 5]))\n\nlist.subarray()\n// -> Uint8Array([0, 1, 2, 3, 4, 5])\n\nlist.consume(3)\nlist.subarray()\n// -> Uint8Array([3, 4, 5])\n\n// you can also iterate over the list\nfor (const buf of list) {\n  // ..do something with `buf`\n}\n\nlist.subarray(0, 1)\n// -> Uint8Array([0])\n```\n\n## Converting Uint8ArrayLists to Uint8Arrays\n\nThere are two ways to turn a `Uint8ArrayList` into a `Uint8Array` - `.slice` and `.subarray` and one way to turn a `Uint8ArrayList` into a `Uint8ArrayList` with different contents - `.sublist`.\n\n### slice\n\nSlice follows the same semantics as [Uint8Array.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice) in that it creates a new `Uint8Array` and copies bytes into it using an optional offset & length.\n\n```js\nconst list = new Uint8ArrayList()\nlist.append(Uint8Array.from([0, 1, 2]))\nlist.append(Uint8Array.from([3, 4, 5]))\n\nlist.slice(0, 1)\n// -> Uint8Array([0])\n```\n\n### subarray\n\nSubarray attempts to follow the same semantics as [Uint8Array.subarray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray) with one important different - this is a no-copy operation, unless the requested bytes span two internal buffers in which case it is a copy operation.\n\n```js\nconst list = new Uint8ArrayList()\nlist.append(Uint8Array.from([0, 1, 2]))\nlist.append(Uint8Array.from([3, 4, 5]))\n\nlist.subarray(0, 1)\n// -> Uint8Array([0]) - no-copy\n\nlist.subarray(2, 5)\n// -> Uint8Array([2, 3, 4]) - copy\n```\n\n### sublist\n\nSublist creates and returns a new `Uint8ArrayList` that shares the underlying buffers with the original so is always a no-copy operation.\n\n```js\nconst list = new Uint8ArrayList()\nlist.append(Uint8Array.from([0, 1, 2]))\nlist.append(Uint8Array.from([3, 4, 5]))\n\nlist.sublist(0, 1)\n// -> Uint8ArrayList([0]) - no-copy\n\nlist.sublist(2, 5)\n// -> Uint8ArrayList([2], [3, 4]) - no-copy\n```\n\n## Inspiration\n\nBorrows liberally from [bl](https://www.npmjs.com/package/bl) but only uses native JS types.\n\n# Install\n\n```console\n$ npm i uint8arraylist\n```\n\n## Browser `<script>` tag\n\nLoading this module through a script tag will make it's exports available as `Uint8arraylist` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/uint8arraylist/dist/index.min.js\"></script>\n```\n\n# API Docs\n\n- <https://achingbrain.github.io/uint8arraylist>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n# Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1647873727008,"_cnpm_publish_time":1647873727008,"dist-tags":{"latest":"3.0.2"}}