{"name":"bits-to-bytes","version":"1.0.0","description":"Functions for doing bit manipulation of typed arrays","main":"index.js","scripts":{"test":"standard && brittle test.mjs"},"repository":{"type":"git","url":"git+https://github.com/hypercore-skunkworks/bits-to-bytes.git"},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","bugs":{"url":"https://github.com/hypercore-skunkworks/bits-to-bytes/issues"},"homepage":"https://github.com/hypercore-skunkworks/bits-to-bytes#readme","dependencies":{"b4a":"^1.5.0"},"devDependencies":{"brittle":"^2.3.1","standard":"^17.0.0"},"gitHead":"2129a5e05830eba5d60dda17e0cdb2a22b488594","_id":"bits-to-bytes@1.0.0","_nodeVersion":"17.8.0","_npmVersion":"8.5.5","dist":{"integrity":"sha512-JkXBe+CXcpJg/Hr4AOAzqdj1OQOjY0Z7h32kK/bnc0ERSZoJNQRrGuhOAb5wtkBp2Tn+cAubyNA/VNhpUYvDqg==","shasum":"024655c7c065f5a002e23bc1cc04ee55e22970ca","tarball":"http://registry-npm.ywwl.com/bits-to-bytes/download/bits-to-bytes-1.0.0.tgz","fileCount":4,"unpackedSize":4010,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDTAW8gQj/CjZ3O44YazEGwaWsD19HoLOLlb8+9LYtjtgIgahEmwiUtCuBSagRoYNlB8u/kS9Ky83NZwgjuCtA7ulY="}],"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","size":1833,"noattachment":false,"key":"/bits-to-bytes/-/bits-to-bytes-1.0.0.tgz"},"_npmUser":{"name":"kasperisager","email":"kasperisager@gmail.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":"kasperisager@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bits-to-bytes_1.0.0_1651563615622_0.9621398594110937"},"_hasShrinkwrap":false,"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","publish_time":1651563615765,"_cnpm_publish_time":1651563615765,"dist-tags":{"latest":"1.3.0"}}