{"_id":"bits-to-bytes","_rev":"6-aad3a4eda829cfce4fb2d6280e95adcf","name":"bits-to-bytes","dist-tags":{"latest":"1.3.0"},"versions":{"1.0.0":{"name":"bits-to-bytes","version":"1.0.0","author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","_id":"bits-to-bytes@1.0.0","maintainers":[{"name":"kasperisager","email":"kasperisager@gmail.com"}],"homepage":"https://github.com/hypercore-skunkworks/bits-to-bytes#readme","bugs":{"url":"https://github.com/hypercore-skunkworks/bits-to-bytes/issues"},"dist":{"shasum":"024655c7c065f5a002e23bc1cc04ee55e22970ca","tarball":"https://registry.npmjs.org/bits-to-bytes/-/bits-to-bytes-1.0.0.tgz","fileCount":4,"integrity":"sha512-JkXBe+CXcpJg/Hr4AOAzqdj1OQOjY0Z7h32kK/bnc0ERSZoJNQRrGuhOAb5wtkBp2Tn+cAubyNA/VNhpUYvDqg==","signatures":[{"sig":"MEUCIQDTAW8gQj/CjZ3O44YazEGwaWsD19HoLOLlb8+9LYtjtgIgahEmwiUtCuBSagRoYNlB8u/kS9Ky83NZwgjuCtA7ulY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4010,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJicNxfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmppkg//Zjkv4qS6P6i2GqU2U7t99GZDTF4pEt28dixWq40I5ITaFhTP\r\n6C+Fqlkyag8g/4HtxOPRCk1VRh8CnFy2v0aHwPb7pAeLUswqG4CnyfxRnCnt\r\nATB9Iw9SbDywZ5QFpYzdfz+UDgTv2wr+jWpC0QAxOxGLm+gG9Zgh23/DI+XG\r\nacAz604ieSDFeN5iTP4Zt48FbRuhjtszL68HNrOa/pKFzp6V0KylH7CRWXvl\r\n+B5CiRGTb2HM8KTMClHjpQKOQxeH8U5J3t967eqyayE0sQlbaoZrv9Co/1lD\r\nLTV3UqOdTMW9ePdvxBnwQYENhympJtwuWmnp0XTBSWPzXdUxgx5FPVwpwk0Q\r\nw9mnTKKoraJ40j9o619pCzoZebQk9g35Kxm8RH5g2mfkcYoL+grTlZY1CI/J\r\nf28WqKHYH3ACxNWAQu1x6c4T7akhifV6Xt2+j2rwAKGy05zddiFY6XlOZKk8\r\nmTvZAN8JJOxbSEvv6L2SsSphk73LfvFM8HDkrA9VhegO2HR+bxqZxL1Y0yF5\r\nFAV7mcB/r+bm5Rgkcwxx8stI4aiWhiHAekznEyoBJ/8vvbgw5nTBRskP4w2+\r\nJPkmLtoHOBLEYDFCsuga8yI9IXdr/SLR3CAc4nsebsJoqH86MwI3jqg5SiSR\r\nMlRH9LZewdLchr+Z5lKjRSm/qs0HvpLftwM=\r\n=LJ5H\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"2129a5e05830eba5d60dda17e0cdb2a22b488594","scripts":{"test":"standard && brittle test.mjs"},"_npmUser":{"name":"kasperisager","email":"kasperisager@gmail.com"},"repository":{"url":"git+https://github.com/hypercore-skunkworks/bits-to-bytes.git","type":"git"},"_npmVersion":"8.5.5","description":"Functions for doing bit manipulation of typed arrays","directories":{},"_nodeVersion":"17.8.0","dependencies":{"b4a":"^1.5.0"},"_hasShrinkwrap":false,"devDependencies":{"brittle":"^2.3.1","standard":"^17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bits-to-bytes_1.0.0_1651563615622_0.9621398594110937","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"bits-to-bytes","version":"1.1.0","author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","_id":"bits-to-bytes@1.1.0","maintainers":[{"name":"kasperisager","email":"kasperisager@hey.com"}],"homepage":"https://github.com/hypercore-skunkworks/bits-to-bytes#readme","bugs":{"url":"https://github.com/hypercore-skunkworks/bits-to-bytes/issues"},"dist":{"shasum":"4bd92911fdf785221718715395be6a868f0e744a","tarball":"https://registry.npmjs.org/bits-to-bytes/-/bits-to-bytes-1.1.0.tgz","fileCount":4,"integrity":"sha512-S9ORj0Gh5Wsr1mqg2CToyvSr75UPk/LYiRdzilydQQLovXIiwPB67axVgHqeXPV7wfVXq3gwiI6ltp4t38FTww==","signatures":[{"sig":"MEQCIBfmpqPXkpN6FFDcx+Y6QUgABHF59PwMy5kpw3EOmmgQAiBKF2MNHal+Lq4RoYsP5M/W/VLATZ3oZ1qka2F6ucaivw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5090,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitXnAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq9tQ/8Cwd4Kzlvq7h5jRH09Xbd+ktAhXPWgpuTN2T4l6MyRBwUQB8j\r\nl4oqmZAwPdsjB9CtcQXSdtma+GD7D4Y12ObpEWRjk+4QDYOpo72RP0tJwNiH\r\ni2zLKEmFiUKqlGaFlPs51zXWtLQlaILt+tsmxhbYE0GPqogeKLWZZ3VnpCWN\r\nfSZCWN0E93O6nNCAAuO51F+wj5k6RZkgQ1GJeIA3iCGsPGbBOOZ2rhpBkLMZ\r\nU9J3kDlE9yw8j+fozSKBk504utqKc5rkvrHyfuf7Q12/PT9iNSMkVP1gfhbh\r\nt/t5Mr+LGZNFvdnFmbx92Li3YYvK5U0tStsrHob6PIuCRWVFvOx6TXqIcsDj\r\nLe4PwqH9upcx2y3AgC5xj3A8aK6igOwvi+QW6jFjxitbNC2bYjUMmFlLGVGe\r\njnUpo7w/WwOGxOZm7XxC6gpyASRloFKo8EMiY4gdanmA9tu9TtDCMjU/wKz6\r\nmy270yt9jtBe1nmOqDEa4csUaOw5wq80kEYS9GzaekzFgfd3L51xQMUE9ar5\r\nLj47Cum2qqX4uQW+x3X95RXXnlKLE6zgOtuxXZbxYWhPQtFYH0tvVWSvAGdF\r\nuqnw/QYWX1rM4ytc/DT+vDI2iWVp55qe8avNsIevo8wQS/NYwh6Lut7E/wzo\r\n9NkSwRSmhr4GparWBRe5WLtryTO0WcntSjA=\r\n=DTQn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"be0635f8c7f158b6845b4d4a247ffa5455ccf47f","scripts":{"test":"standard && brittle test.mjs"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"repository":{"url":"git+https://github.com/hypercore-skunkworks/bits-to-bytes.git","type":"git"},"_npmVersion":"8.6.0","description":"Functions for doing bit manipulation of typed arrays","directories":{},"_nodeVersion":"18.0.0","dependencies":{"b4a":"^1.5.0"},"_hasShrinkwrap":false,"devDependencies":{"brittle":"^2.3.1","standard":"^17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bits-to-bytes_1.1.0_1656060352790_0.593065714563898","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"bits-to-bytes","version":"1.2.0","author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","_id":"bits-to-bytes@1.2.0","maintainers":[{"name":"kasperisager","email":"kasperisager@hey.com"}],"homepage":"https://github.com/hypercore-skunkworks/bits-to-bytes#readme","bugs":{"url":"https://github.com/hypercore-skunkworks/bits-to-bytes/issues"},"dist":{"shasum":"9cc3b44787e9c92e73a1bc3d6a59629c782ae518","tarball":"https://registry.npmjs.org/bits-to-bytes/-/bits-to-bytes-1.2.0.tgz","fileCount":4,"integrity":"sha512-yKmcM3hmH3DE1KjZjf2/jWSbmegUaobAWLcOSuOAdhuFaLJi3NHpL8DxTVn4KYXEcBQ+8kZ9wsMS4AhNidPY2g==","signatures":[{"sig":"MEQCIHZEdaygfKjMjqfy859xB7hwLhLfr9pKlpSi6oK9N6oPAiBQE6gtcjPEwujENj5VCuz9OC/m0LKvcYhDkr4A2k4KvQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6090,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiwuXpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoitA//WknxD+2oSFhdR114bq8KxIu553y1mkMmjHfX3fbLRf/04dJf\r\nA/oemc9pst8dcb+hOzuHfibWfnKBgC/DiJg5JthAWrmMyOBRwe9RAs9jtlR+\r\nLhh30zM/blg/JzFE6T5E4YaH8YdjzECgXzr9g5d5yW7Cq1zDpEjAkd3Ub7Kz\r\nhZuFlaTLiUX6fjOdVK+cx3bjGkGkroAn/Wp0hwavEzAmrnD2IZn9FbvUknNd\r\nv61v2EqpQlDilN4yZECIkdHiDrTfniSxoBfic76+MU1IPiLwG9ub6STyIPDU\r\n6nS6oCa8LpXwB/JPFbW7QnoHUPpSNG4kHokel+0vMl38NjfRAqR9HoMBenSy\r\nEcg9Xh8gfyWnzTRcQQL7ZGbXkuGrZuM9JlL42nnXz6m1fBOUFVVi/DrlMJER\r\nsWjC7pd75464HODReDm5E+XBzR5VHCnw0Q6NY8zuOTG+XgmEd3e/vil5l1W8\r\nTsZ8VIRujHK8s/Kw+6s0a7mcEqktLuJ6TqIfCk14i0W2vtwU7rS7OxhrXNtt\r\npHLNh3QufWdZ8tWfpr8Ua8eovE8ko0Af/F+2R8pghSxtZWUyjgMTJ6pS9GVZ\r\n8n02P3Nm3lAcy8gPeTyaCT5srzJgb3AzSqUv3zN2KlMa2iZoo++gGuS2g+VH\r\nzbLiH01xo6Q146gFeH5Mt7cdvFX8PhYAL2g=\r\n=/BTe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"cf33b0d2f033c31c5e1f363508948c88ed9d921a","scripts":{"test":"standard && brittle test.mjs"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"repository":{"url":"git+https://github.com/hypercore-skunkworks/bits-to-bytes.git","type":"git"},"_npmVersion":"8.12.1","description":"Functions for doing bit manipulation of typed arrays","directories":{},"_nodeVersion":"18.4.0","dependencies":{"b4a":"^1.5.0"},"_hasShrinkwrap":false,"devDependencies":{"brittle":"^2.3.1","standard":"^17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bits-to-bytes_1.2.0_1656940009406_0.3559307164082539","host":"s3://npm-registry-packages"}},"1.3.0":{"name":"bits-to-bytes","version":"1.3.0","author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","_id":"bits-to-bytes@1.3.0","maintainers":[{"name":"kasperisager","email":"kasperisager@hey.com"}],"homepage":"https://github.com/holepunchto/bits-to-bytes#readme","bugs":{"url":"https://github.com/holepunchto/bits-to-bytes/issues"},"dist":{"shasum":"b6b0b547ff5747b0609a42e31a0b57212f09f4e7","tarball":"https://registry.npmjs.org/bits-to-bytes/-/bits-to-bytes-1.3.0.tgz","fileCount":4,"integrity":"sha512-OJoHTpFXS9bXHBCekGTByf3MqM8CGblBDIduKQeeVVeiU9dDWywSSirXIBYGgg3d1zbVuvnMa1vD4r6PA0kOKg==","signatures":[{"sig":"MEQCIAwYqzW/dz34G3GEE6rfeAjEZTpmEjFx0Ia57ya3MfOtAiBPekAOBhHTNw71VtTm3iIoXtCRdz3m0Qu3Oqm7lC5D6w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6906,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi67JjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqrYw//chTzDtWYo5HAXioEgqD9rWxwYj0l2F5ne4oAwmowynaadNdu\r\ntktwaMWrenvxjnS3/b5CBEK5Spkrbuv9bIntQP8o7/uUArjv/yysoHsXg+EV\r\nGMQIk6MLQex+mb0wct230/j56bYxXjGFwwx01/5VzkOQhNAvCtbhTdF2ipxG\r\n21PBcGtOom45mt/73uUO8CjcUCaPNqWwJa9tjfKIPMdRgE8v4Lk/arz2xxXA\r\n0XAOkvY8rUzmWW0EoGb6KXYZGzu9qFdYk9TY2iemodPZOyQPDhFM0fLyhkqB\r\nkdYRjlUdyiqEvP2J0vU3SwCcQ27rS0Ubyq4y54Q+PRIeRunQ/3GNmifk6azv\r\ncW8UAXnszVHMUWVHPwWqyJGngL7MCFrkoODSDs8k8p6AyiBqIBvtjuw/dyQp\r\n4CgipYsYU50mfJMnHgzNOtPJhyTJaQFPB4ZSMf+3ILrHe52o3/S9xpeDkGoH\r\nqKvkRbv+UKq4HfggS6byLC9wJkqJRzSpuQTAgRHmzQF3qym5LU+wXIS9Yeuw\r\nyFRZ82iIor8i0pHLgVXorD0L6tyP7b6HxUmL/pEoCni3TDFf5bDNozcp0JRQ\r\nRWn2dyk+Zz7yxSYFFuNzDPzJpED1aAwyES2AdAYD9LoFFvZQbgjAGfqvcFT8\r\nzvwfIIHzGDyqD5q5vdyidUHU1dMWtAQKX/8=\r\n=4NJ8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"be16066c605a370ce4fe3be5ee0d6c97260aa885","scripts":{"test":"standard && brittle test.mjs"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"repository":{"url":"git+https://github.com/holepunchto/bits-to-bytes.git","type":"git"},"_npmVersion":"8.16.0","description":"Functions for doing bit manipulation of typed arrays","directories":{},"_nodeVersion":"18.7.0","dependencies":{"b4a":"^1.5.0"},"_hasShrinkwrap":false,"devDependencies":{"brittle":"^2.3.1","standard":"^17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bits-to-bytes_1.3.0_1659613795507_0.22013667484842037","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-05-03T07:40:15.621Z","modified":"2026-03-31T20:45:26.554Z","1.0.0":"2022-05-03T07:40:15.765Z","1.1.0":"2022-06-24T08:45:52.905Z","1.2.0":"2022-07-04T13:06:49.570Z","1.3.0":"2022-08-04T11:49:55.750Z"},"bugs":{"url":"https://github.com/holepunchto/bits-to-bytes/issues"},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","homepage":"https://github.com/holepunchto/bits-to-bytes#readme","repository":{"url":"git+https://github.com/holepunchto/bits-to-bytes.git","type":"git"},"description":"Functions for doing bit manipulation of typed arrays","maintainers":[{"email":"mathiasbuus@gmail.com","name":"mafintosh"}],"readme":"# Bits to Bytes\n\nFunctions for doing bit manipulation of typed arrays.\n\n```npm\nnpm i bits-to-bytes\n```\n\n## Usage\n\n```js\nconst bits = require('bits-to-bytes')\n\nconst buffer = Uint8Array.from([0b11001000])\n\nbits.get(buffer, 3)\n// true\n```\n\n`buffer` may be any typed array with a `number` element type, including `Uint8Array`, `Uint16Array`, and `Uint32Array`.\n\n## API\n\n#### `const n = bits.byteLength(size)`\n\nGet the number of bytes required to contain `size` bits.\n\n#### `const b = bits.get(buffer, bit)`\n\nGet the given bit, which will either be `true` (set) or `false` (unset).\n\n#### `const changed = bits.set(buffer, bit[, value])`\n\nSet the given bit to `value`, which defaults to `true`. Returns `true` if the bit changed, otherwise `false`.\n\n#### `const changed = bits.setRange(buffer, start, end[, value])`\n\nSet the given bit range to `value`, which defaults to `true`. Returns `true` if any of the bits changed, otherwise `false`.\n\nIf you don't need the additional information about whether any of the bits changed, consider `bits.fill()` as a more performant alternative.\n\n#### `buffer = bits.fill(buffer, value[, start[, end]])`\n\nFill the given bit range with `value`. `start` defaults to `0` and `end` defaults to the bit length of the array. Returns the modified array.\n\n#### `const b = bits.toggle(buffer, bit)`\n\nToggle the given bit, returning its new value.\n\n#### `const changed = bits.remove(buffer, bit)`\n\nUnset the given bit. Returns `true` if the bit was set, otherwise `false`.\n\n#### `const changed = bits.removeRange(buffer, start, end)`\n\nUnset the given bit range. Returns `true` if any of the bits were set, otherwise `false`.\n\n#### `const index = bits.indexOf(buffer, value[, position])`\n\nReturn the index of the first occurrence of `value`, or `-1` if not found. If `position` is given, return the first index that is greater than or equal to `position`.\n\n#### `const index = bits.lastIndexOf(buffer, value[, position])`\n\nReturn the index of the last occurrence of `value`, or `-1` if not found. If `position` is given, return the last index that is less than or equal to `position`.\n\n#### `const buffer = bits.of(...values)`\n\nCreate a buffer containing the given bits.\n\n#### `const buffer = bits.from(values)`\n\nCreate a buffer containing the given bits.\n\n#### `const iterator = bits.iterator(buffer)`\n\nCreate an iterator over bits.\n\n## License\n\nISC\n","readmeFilename":"README.md"}