{"name":"uint8arrays","version":"3.1.0","description":"Utility functions to make dealing with Uint8Arrays easier","main":"./cjs/src/index.js","author":{"name":"Alex Potsides","email":"alex@achingbrain.net"},"homepage":"https://github.com/achingbrain/uint8arrays","bugs":{"url":"https://github.com/achingbrain/uint8arrays/issues"},"types":"types/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/achingbrain/uint8arrays.git"},"scripts":{"test":"aegir test","lint":"aegir ts -p check && aegir lint","release":"aegir release","release-minor":"aegir release --type minor","release-major":"aegir release --type major","build":"aegir build"},"license":"MIT","dependencies":{"multiformats":"^9.4.2"},"devDependencies":{"@types/benchmark":"^2.1.1","aegir":"^35.0.0","benchmark":"^2.1.4","util":"^0.12.4"},"eslintConfig":{"extends":"ipfs","parserOptions":{"sourceType":"module"},"ignorePatterns":["!.aegir.js"]},"typesVersions":{"*":{"*":["types/src","types/src/*"]}},"exports":{".":{"browser":"./esm/src/index.js","require":"./cjs/src/index.js","import":"./esm/src/index.js"},"./alloc":{"browser":"./esm/src/alloc.js","require":"./cjs/src/alloc.js","import":"./esm/src/alloc.js"},"./compare":{"browser":"./esm/src/compare.js","require":"./cjs/src/compare.js","import":"./esm/src/compare.js"},"./concat":{"browser":"./esm/src/concat.js","require":"./cjs/src/concat.js","import":"./esm/src/concat.js"},"./equals":{"browser":"./esm/src/equals.js","require":"./cjs/src/equals.js","import":"./esm/src/equals.js"},"./from-string":{"browser":"./esm/src/from-string.js","require":"./cjs/src/from-string.js","import":"./esm/src/from-string.js"},"./to-string":{"browser":"./esm/src/to-string.js","require":"./cjs/src/to-string.js","import":"./esm/src/to-string.js"},"./xor":{"browser":"./esm/src/xor.js","require":"./cjs/src/xor.js","import":"./esm/src/xor.js"}},"contributors":[{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"Irakli Gozalishvili","email":"contact@gozala.io"},{"name":"Cayman","email":"caymannava@gmail.com"},{"name":"Hugo Dias","email":"hugomrdias@gmail.com"},{"name":"Mircea Nistor","email":"mirceanis@gmail.com"},{"name":"Rafael Ramalho","email":"rafazelramalho19@gmail.com"},{"name":"Vasco Santos","email":"vasco.santos@ua.pt"}],"browser":{".":"./cjs/src/index.js","./alloc":"./cjs/src/alloc.js","./compare":"./cjs/src/compare.js","./concat":"./cjs/src/concat.js","./equals":"./cjs/src/equals.js","./from-string":"./cjs/src/from-string.js","./to-string":"./cjs/src/to-string.js","./xor":"./cjs/src/xor.js"},"gitHead":"56329d16d6ca575c9638f3abb9601b8a034783b8","_id":"uint8arrays@3.1.0","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"integrity":"sha512-ei5rfKtoRO8OyOIor2Rz5fhzjThwIHJZ3uyDPnDHTXbP0aMQ1RN/6AI5B5d9dBxJOU+BvOAk7ZQ1xphsX8Lrog==","shasum":"8186b8eafce68f28bd29bd29d683a311778901e2","tarball":"http://registry-npm.ywwl.com/uint8arrays/download/uint8arrays-3.1.0.tgz","fileCount":52,"unpackedSize":88318,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4x4bkRuL2qU9z/NebQOv9SI/7FUXr6zYVHm95nc/L/AIhAL3KjtjBs42tmFmKLinyUCtlk1tN+9Ys7xFKov6q1bIk"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6StDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoHXw//YnU7+jTnGOTNk+t6j+aDXB+UtENOKwflaCKWrwcdtvWwsWbV\r\n0QQijCrzM+NaSzMOn05OpQqO630RNH4QXxYkQo17+pGGwi6njaw/vNFHrvls\r\nwj/Ho/K/o6A/H4t1cc0KUawh6cA+jKDlCvk0KZKZrXtRzdLBeeZIDwZsl2OK\r\nE0HyWogdy4YG+su0icout+BKicmKQ9NWg/V72rtvBVaOMyJT/dSBxfR56mD1\r\nYiw3avLQ8qxqy3xuRXYLGPjsUO1UVPT2tS2gLTgYlunBz/ptVsf6R4RCqWa1\r\n5+z18inO64+/LypJFlso9mbfd6EQJrtX6qmkgkyTNZw7a8tgDaHf63jImqle\r\n+JgTBWoSRDGFjYV7J7tnARpwJJ2p41ZsFP0Lh4L+VB/nZ3UkMFJIskKiQlbH\r\nwBMjzo4AdQex6MIqULSBFkHw2qB9DF6mcvTRSJ5w+ZxK5XAgmj19zOY4Q4AD\r\ndESlwS9lhJu7YpGXOUt721ecssbU/makB5/iM3cL234PJ6ltXQ0VBOvuUSL/\r\n9oivCT9w8eOXzhgiiA5/Hjufm3Bor8+jNWLTIN10XvN7NQ+wA1TtQjy6pDr4\r\nitlQIvdRwc075Q9gGgmb2nveh1EogxVIq8yZBYaHKHBdRzCU5VnP3q6UK3U6\r\nr/cesCewWAGqDq1HNEqjAW2LlvQSIYra5lE=\r\n=zbOB\r\n-----END PGP SIGNATURE-----\r\n","size":23096,"noattachment":false,"key":"/uint8arrays/-/uint8arrays-3.1.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/uint8arrays_3.1.0_1659448131473_0.8408186800063251"},"_hasShrinkwrap":false,"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```js\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```js\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```js\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```js\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```js\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```js\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```js\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## xor(a, b)\n\nReturns a `Uint8Array` containing `a` and `b` xored together.\n\n### Example\n\n```js\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 it's 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](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":1659448131625,"_cnpm_publish_time":1659448131625,"dist-tags":{"latest":"6.1.1","next":"3.0.0-rc.1"}}