{"name":"uint8arraylist","version":"2.4.3","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":{".":{"types":"./dist/src/index.d.ts","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":"docs","release":"patch"},{"type":"test","release":"patch"},{"type":"deps","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":"Documentation"},{"type":"deps","section":"Dependencies"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"]},"scripts":{"clean":"aegir clean","lint":"aegir lint","dep-check":"aegir dep-check","build":"aegir build","test":"aegir test","test:chrome":"aegir test -t browser --cov","test:chrome-webworker":"aegir test -t webworker","test:firefox":"aegir test -t browser -- --browser firefox","test:firefox-webworker":"aegir test -t webworker -- --browser firefox","test:node":"aegir test -t node --cov","test:electron-main":"aegir test -t electron-main","release":"aegir release","docs":"aegir docs"},"dependencies":{"uint8arrays":"^4.0.2"},"devDependencies":{"aegir":"^37.4.6","benchmark":"^2.1.4","bl":"^6.0.0","it-all":"^2.0.0"},"gitHead":"0adda9ad78c3db75bee73a63acce5aee8c5f0f76","_id":"uint8arraylist@2.4.3","_nodeVersion":"18.12.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-oEVZr4/GrH87K0kjNce6z8pSCzLEPqHNLNR5sj8cJOySrTP8Vb/pMIbZKLJGhQKxm1TiZ31atNrpn820Pyqpow==","shasum":"1148aa979b407d382e4eb8d9c8f2b4bf3f5910d5","tarball":"http://registry-npm.ywwl.com/uint8arraylist/download/uint8arraylist-2.4.3.tgz","fileCount":10,"unpackedSize":70696,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDOzGveYvYyI96OaKT8oy/GOYhZ7w3nVK9HgzoWDaz3ZAIgTG49JMCT308WvKl1Na9gX0vsydGO65B+nuAQ935G9Fo="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjnGBIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrUgg//bio1gmEBI4YIuuAyT2vOoQTWrozr3Q5vxermXzSvi4YzsYwY\r\neX5EkmyKzfUx0/Km9r3FvQ/AFItKp5ZAPmKLfXxLG0lylx0VlkAIqGHi75/4\r\n9mE5PSxktVdo0sx/vOJlm6sset9aM247r2HJnDwgfoRc3dL47DuyALns/Z/M\r\nvx5NhxeIuTu6R5NLdw3tUmMI8TkEjy3WoawsXfQc5eXV2dhagSf2lNj4hj4O\r\n8HJCAZqZqrPJx/ry8Ou+0JeWGuIETQ8L5Eb2LgIWULoYj+225b0YWzaHP8np\r\nwyJvJkX9hzuzkTrHztGzyjAeqtG2JQmKNna1Pl4IaAEt9nW10Q3Pron0l/g2\r\nGgfYz0v7n5gZA0+mcFLV+xq3jsKFzrQTYdmY3Obkp30gw2jZSjsHNhAWR4VS\r\nVozob8gYjw/mm2UWWvhnlJYbMNjXbUXGRX9kaIgU2hBCoSGcw6gW9hd1SOjY\r\nOqKcUDEoqVU7KnR8hGHzozNukZ2yI+ud9iQg+OD1dxKcoI4VRYBMn0eR9Msm\r\nbVdv010qG9lzXvsbrKzprpB8/neLkPVVmb0EPvP2vbUnzHFaZM9ox3AvW/Pz\r\nRSPZi9q9K7UYXwxVbh/M1t47qVJnctufm9BzdizHF/8TtMBVVqneP4WtN0WC\r\nIGZLtwqlnYQvmJKw5DCoiqYHAA+6hsZIoJg=\r\n=5eAC\r\n-----END PGP SIGNATURE-----\r\n","size":14071,"noattachment":false,"key":"/uint8arraylist/-/uint8arraylist-2.4.3.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_2.4.3_1671192648735_0.39705157894576293"},"_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":1671192648902,"_cnpm_publish_time":1671192648902,"dist-tags":{"latest":"3.0.2"}}