{"_id":"bits-to-bytes","_rev":"237584","name":"bits-to-bytes","description":"Functions for doing bit manipulation of typed arrays","dist-tags":{"latest":"1.3.0"},"maintainers":[{"name":"kasperisager","email":""}],"time":{"modified":"2023-03-24T16:40:04.000Z","created":"2022-05-03T07:40:15.765Z","1.3.0":"2022-08-04T11:49:55.750Z","1.2.0":"2022-07-04T13:06:49.570Z","1.1.0":"2022-06-24T08:45:52.905Z","1.0.0":"2022-05-03T07:40:15.765Z"},"users":{},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"repository":{"type":"git","url":"git+https://github.com/holepunchto/bits-to-bytes.git"},"versions":{"1.3.0":{"name":"bits-to-bytes","version":"1.3.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/holepunchto/bits-to-bytes.git"},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","bugs":{"url":"https://github.com/holepunchto/bits-to-bytes/issues"},"homepage":"https://github.com/holepunchto/bits-to-bytes#readme","dependencies":{"b4a":"^1.5.0"},"devDependencies":{"brittle":"^2.3.1","standard":"^17.0.0"},"gitHead":"be16066c605a370ce4fe3be5ee0d6c97260aa885","_id":"bits-to-bytes@1.3.0","_nodeVersion":"18.7.0","_npmVersion":"8.16.0","dist":{"shasum":"b6b0b547ff5747b0609a42e31a0b57212f09f4e7","size":2502,"noattachment":false,"key":"/bits-to-bytes/-/bits-to-bytes-1.3.0.tgz","tarball":"http://name.csiicloud.com:7001/bits-to-bytes/download/bits-to-bytes-1.3.0.tgz"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bits-to-bytes_1.3.0_1659613795507_0.22013667484842037"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-08-04T11:55:56.290Z","publish_time":1659613795750,"_cnpm_publish_time":1659613795750},"1.2.0":{"name":"bits-to-bytes","version":"1.2.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":"cf33b0d2f033c31c5e1f363508948c88ed9d921a","_id":"bits-to-bytes@1.2.0","_nodeVersion":"18.4.0","_npmVersion":"8.12.1","dist":{"shasum":"9cc3b44787e9c92e73a1bc3d6a59629c782ae518","size":2326,"noattachment":false,"key":"/bits-to-bytes/-/bits-to-bytes-1.2.0.tgz","tarball":"http://name.csiicloud.com:7001/bits-to-bytes/download/bits-to-bytes-1.2.0.tgz"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bits-to-bytes_1.2.0_1656940009406_0.3559307164082539"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-04T13:15:49.483Z","publish_time":1656940009570,"_cnpm_publish_time":1656940009570},"1.1.0":{"name":"bits-to-bytes","version":"1.1.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":"be0635f8c7f158b6845b4d4a247ffa5455ccf47f","_id":"bits-to-bytes@1.1.0","_nodeVersion":"18.0.0","_npmVersion":"8.6.0","dist":{"shasum":"4bd92911fdf785221718715395be6a868f0e744a","size":2047,"noattachment":false,"key":"/bits-to-bytes/-/bits-to-bytes-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/bits-to-bytes/download/bits-to-bytes-1.1.0.tgz"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bits-to-bytes_1.1.0_1656060352790_0.593065714563898"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-06-24T09:14:16.677Z","publish_time":1656060352905,"_cnpm_publish_time":1656060352905},"1.0.0":{"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":{"shasum":"024655c7c065f5a002e23bc1cc04ee55e22970ca","size":1833,"noattachment":false,"key":"/bits-to-bytes/-/bits-to-bytes-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/bits-to-bytes/download/bits-to-bytes-1.0.0.tgz"},"_npmUser":{"name":"kasperisager","email":"kasperisager@gmail.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bits-to-bytes_1.0.0_1651563615622_0.9621398594110937"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-03T07:40:19.683Z","publish_time":1651563615765,"_cnpm_publish_time":1651563615765}},"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","_attachments":{},"homepage":"https://github.com/holepunchto/bits-to-bytes#readme","bugs":{"url":"https://github.com/holepunchto/bits-to-bytes/issues"},"license":"ISC"}