{"name":"uint8arrays","version":"5.1.1","author":{"name":"Alex Potsides","email":"alex@achingbrain.net"},"license":"Apache-2.0 OR MIT","_id":"uint8arrays@5.1.1","maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"}],"homepage":"https://github.com/achingbrain/uint8arrays#readme","bugs":{"url":"https://github.com/achingbrain/uint8arrays/issues"},"dist":{"shasum":"85b2811d0be22b1b1530f96c6abeb64a718f3f12","tarball":"http://registry-npm.ywwl.com/uint8arrays/download/uint8arrays-5.1.1.tgz","fileCount":90,"integrity":"sha512-9muQwa4wZG4dKi9gMAIBtnk2Pw87SRpvWTH6lOGm19V2Uqxr4uomUf2PGqPnWc+qs06sN8owUU4jfcoWOcfwVQ==","signatures":[{"sig":"MEYCIQDZ1sZiTwtE22Bs3U3hVUP0VSE/YRfEeg87ItqwIuaHmQIhAKZDaGDNxveTxK8tnxxMEVFmOrBpcwlY4SeEOxTj7jqP","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/uint8arrays@5.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":171300,"size":43956,"noattachment":false,"key":"/uint8arrays/-/uint8arrays-5.1.1.tgz"},"type":"module","types":"./dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js","module-sync":"./dist/src/index.js"},"./xor":{"types":"./dist/src/xor.d.ts","import":"./dist/src/xor.js","module-sync":"./dist/src/xor.js"},"./alloc":{"node":"./dist/src/alloc.node.js","types":"./dist/src/alloc.d.ts","import":"./dist/src/alloc.js","module-sync":"./dist/src/alloc.js"},"./concat":{"node":"./dist/src/concat.node.js","types":"./dist/src/concat.d.ts","import":"./dist/src/concat.js","module-sync":"./dist/src/concat.js"},"./equals":{"types":"./dist/src/equals.d.ts","import":"./dist/src/equals.js","module-sync":"./dist/src/equals.js"},"./compare":{"node":"./dist/src/compare.node.js","types":"./dist/src/compare.d.ts","import":"./dist/src/compare.js","module-sync":"./dist/src/compare.js"},"./to-string":{"node":"./dist/src/to-string.node.js","types":"./dist/src/to-string.d.ts","import":"./dist/src/to-string.js","module-sync":"./dist/src/to-string.js"},"./from-string":{"node":"./dist/src/from-string.node.js","types":"./dist/src/from-string.d.ts","import":"./dist/src/from-string.js","module-sync":"./dist/src/from-string.js"},"./xor-compare":{"types":"./dist/src/xor-compare.d.ts","import":"./dist/src/xor-compare.js","module-sync":"./dist/src/xor-compare.js"}},"gitHead":"f8983fae082a53fd073b7c03a5e3a761e6483ffb","imports":{"#alloc":{"node":"./dist/src/alloc.node.js","types":"./dist/src/alloc.d.ts","import":"./dist/src/alloc.js"},"#concat":{"node":"./dist/src/concat.node.js","types":"./dist/src/concat.d.ts","import":"./dist/src/concat.js"},"#compare":{"node":"./dist/src/compare.node.js","types":"./dist/src/compare.d.ts","import":"./dist/src/compare.js"},"#to-string":{"node":"./dist/src/to-string.node.js","types":"./dist/src/to-string.d.ts","import":"./dist/src/to-string.js"},"#from-string":{"node":"./dist/src/from-string.node.js","types":"./dist/src/from-string.d.ts","import":"./dist/src/from-string.js"},"#util/as-uint8array":{"node":"./dist/src/util/as-uint8array.node.js","types":"./dist/src/util/as-uint8array.d.ts","import":"./dist/src/util/as-uint8array.js"}},"release":{"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"release":"major","breaking":true},{"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",{"assets":["CHANGELOG.md","package.json"]}]],"branches":["main"]},"scripts":{"docs":"aegir docs","lint":"aegir lint","test":"aegir test","build":"aegir build","clean":"aegir clean","release":"aegir release","dep-check":"aegir dep-check","test:node":"aegir test -t node --cov","test:chrome":"aegir test -t browser --cov","test:firefox":"aegir test -t browser -- --browser firefox","test:chrome-webworker":"aegir test -t webworker","test:firefox-webworker":"aegir test -t webworker -- --browser firefox"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ef1133e5-9068-402f-9387-ae2a6cd73fed"}},"repository":{"url":"git+https://github.com/achingbrain/uint8arrays.git","type":"git"},"_npmVersion":"11.12.1","description":"Utility functions to make dealing with Uint8Arrays easier","directories":{},"_nodeVersion":"24.14.1","dependencies":{"multiformats":"^13.0.0"},"react-native":{"#alloc":"./dist/src/alloc.js","#concat":"./dist/src/concat.js","#compare":"./dist/src/compare.js","#to-string":"./dist/src/to-string.js","#from-string":"./dist/src/from-string.js","#util/as-uint8array":"./dist/src/util/as-uint8array.js"},"publishConfig":{"access":"public","provenance":true},"typesVersions":{"*":{"*":["*","dist/*","dist/src/*","dist/src/*/index"],"src/*":["*","dist/*","dist/src/*","dist/src/*/index"]}},"_hasShrinkwrap":false,"devDependencies":{"aegir":"^47.1.5","benchmark":"^2.1.4","@types/benchmark":"^2.1.1"},"_npmOperationalInternal":{"tmp":"tmp/uint8arrays_5.1.1_1776078447787_0.5150223150348034","host":"s3://npm-registry-packages-npm-production"},"readme":"# uint8arrays\n\n[![codecov](https://img.shields.io/codecov/c/github/achingbrain/uint8arrays.svg?style=flat-square)](https://codecov.io/gh/achingbrain/uint8arrays)\n[![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/uint8arrays/js-test-and-release.yml?branch=main\\&style=flat-square)](https://github.com/achingbrain/uint8arrays/actions/workflows/js-test-and-release.yml?query=branch%3Amain)\n\n> Utility functions to make dealing with Uint8Arrays easier\n\n# About\n\n<!--\n\n!IMPORTANT!\n\nEverything in this README between \"# About\" and \"# Install\" is automatically\ngenerated and will be overwritten the next time the doc generator is run.\n\nTo make changes to this section, please update the @packageDocumentation section\nof src/index.js or src/index.ts\n\nTo experiment with formatting, please run \"npm run docs\" from the root of this\nrepo and examine the changes made.\n\n-->\n\n`Uint8Array`s bring memory-efficient(ish) byte handling to browsers - they are similar to Node.js `Buffer`s but lack a lot of the utility methods present on that class.\n\nThis module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.\n\nSince Node.js `Buffer`s are also `Uint8Array`s, it falls back to `Buffer` internally where it makes sense for performance reasons.\n\n## alloc(size)\n\nCreate a new `Uint8Array`. When running under Node.js, `Buffer` will be used in preference to `Uint8Array`.\n\n## Example\n\n```ts\nimport { alloc } from 'uint8arrays/alloc'\n\nconst buf = alloc(100)\n```\n\n## allocUnsafe(size)\n\nCreate a new `Uint8Array`. When running under Node.js, `Buffer` will be used in preference to `Uint8Array`.\n\nOn platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.\n\n## Example\n\n```ts\nimport { allocUnsafe } from 'uint8arrays/alloc'\n\nconst buf = allocUnsafe(100)\n```\n\n## compare(a, b)\n\nCompare two `Uint8Arrays`\n\n## Example\n\n```ts\nimport { compare } from 'uint8arrays/compare'\n\nconst arrays = [\n  Uint8Array.from([3, 4, 5]),\n  Uint8Array.from([0, 1, 2])\n]\n\nconst sorted = arrays.sort(compare)\n\nconsole.info(sorted)\n// [\n//    Uint8Array[0, 1, 2]\n//    Uint8Array[3, 4, 5]\n// ]\n```\n\n## concat(arrays, \\[length])\n\nConcatenate one or more `Uint8Array`s and return a `Uint8Array` with their contents.\n\nIf you know the length of the arrays, pass it as a second parameter, otherwise it will be calculated by traversing the list of arrays.\n\n## Example\n\n```ts\nimport { concat } from 'uint8arrays/concat'\n\nconst arrays = [\n  Uint8Array.from([0, 1, 2]),\n  Uint8Array.from([3, 4, 5])\n]\n\nconst all = concat(arrays, 6)\n\nconsole.info(all)\n// Uint8Array[0, 1, 2, 3, 4, 5]\n```\n\n## equals(a, b)\n\nReturns true if the two arrays are the same array or if they have the same length and contents.\n\n## Example\n\n```ts\nimport { equals } from 'uint8arrays/equals'\n\nconst a = Uint8Array.from([0, 1, 2])\nconst b = Uint8Array.from([3, 4, 5])\nconst c = Uint8Array.from([0, 1, 2])\n\nconsole.info(equals(a, b)) // false\nconsole.info(equals(a, c)) // true\nconsole.info(equals(a, a)) // true\n```\n\n## fromString(string, encoding = 'utf8')\n\nReturns a new `Uint8Array` created from the passed string and interpreted as the passed encoding.\n\nSupports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).\n\n## Example\n\n```ts\nimport { fromString } from 'uint8arrays/from-string'\n\nconsole.info(fromString('hello world')) // Uint8Array[104, 101 ...\nconsole.info(fromString('00010203aabbcc', 'base16')) // Uint8Array[0, 1 ...\nconsole.info(fromString('AAECA6q7zA', 'base64')) // Uint8Array[0, 1 ...\nconsole.info(fromString('01234', 'ascii')) // Uint8Array[48, 49 ...\n```\n\n## toString(array, encoding = 'utf8')\n\nReturns a string created from the passed `Uint8Array` in the passed encoding.\n\nSupports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).\n\n## Example\n\n```ts\nimport { toString } from 'uint8arrays/to-string'\n\nconsole.info(toString(Uint8Array.from([104, 101...]))) // 'hello world'\nconsole.info(toString(Uint8Array.from([0, 1, 2...]), 'base16')) // '00010203aabbcc'\nconsole.info(toString(Uint8Array.from([0, 1, 2...]), 'base64')) // 'AAECA6q7zA'\nconsole.info(toString(Uint8Array.from([48, 49, 50...]), 'ascii')) // '01234'\n```\n\n## withArrayBuffer(buf)\n\n`Uint8Array`s can be backed by an `ArrayBuffer` or a `SharedArrayBuffer`.\n\nThe types of these two values have diverged in `typescript@5.7` or later.\n\nSome APIs require `Uint8Array`s backed by `ArrayBuffer`s specifically so call\n`withArrayBuffer` to ensure your `Uint8Array`s are backed the correct type.\n\n## Example\n\n```ts\nimport { withArrayBuffer } from 'uint8arrays/with-array-buffer'\n\nconst buf = new SharedArrayBuffer(10)\nconst arr = new Uint8Array(buf, 0, buf.byteLength)\n\nconst arr2 = withArrayBuffer(arr)\n\nconsole.info(arr.buffer.constructor) // [Function: SharedArrayBuffer]\nconsole.info(arr2.buffer.constructor) // [Function: ArrayBuffer]\n```\n\n## xor(a, b)\n\nReturns a `Uint8Array` containing `a` and `b` xored together.\n\n## Example\n\n```ts\nimport { xor } from 'uint8arrays/xor'\n\nconsole.info(xor(Uint8Array.from([1, 0]), Uint8Array.from([0, 1]))) // Uint8Array[1, 1]\n```\n\n## xorCompare(a, b)\n\nCompares the distances between two xor `Uint8Array`s.\n\n## Example\n\n```ts\nimport { xor } from 'uint8arrays/xor'\nimport { xorCompare } from 'uint8arrays/xor-compare'\n\nconst target = Uint8Array.from([1, 1])\nconst val1 = Uint8Array.from([1, 0])\nconst xor1 = xor(target, val1)\n\nconst val2 = Uint8Array.from([0, 1])\nconst xor2 = xor(target, val2)\n\nconsole.info(xorCompare(xor1, xor2)) // -1 or 0 or 1\n```\n\n# Install\n\n```console\n$ npm i uint8arrays\n```\n\n## Browser `<script>` tag\n\nLoading this module through a script tag will make its exports available as `Uint8arrays` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/uint8arrays/dist/index.min.js\"></script>\n```\n\n# API Docs\n\n- <https://achingbrain.github.io/uint8arrays>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](https://github.com/achingbrain/uint8arrays/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](https://github.com/achingbrain/uint8arrays/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":1776078447950,"_cnpm_publish_time":1776078447950,"dist-tags":{"latest":"6.1.1","next":"3.0.0-rc.1"}}