{"name":"compact-encoding-bitfield","version":"1.1.0","description":"Compact codec for bitfields","main":"index.js","scripts":{"format":"prettier --write .","lint":"prettier --check . && lunte","test":"npm run test:node && npm run test:bare","test:node":"brittle-node --coverage test.mjs","test:bare":"brittle-bare --coverage test.mjs"},"repository":{"type":"git","url":"git+https://github.com/compact-encoding/compact-encoding-bitfield.git"},"author":{"name":"Holepunch"},"license":"Apache-2.0","bugs":{"url":"https://github.com/compact-encoding/compact-encoding-bitfield/issues"},"homepage":"https://github.com/compact-encoding/compact-encoding-bitfield#readme","imports":{"util":{"bare":"bare-utils","default":"util"}},"dependencies":{"compact-encoding":"^3.0.0"},"devDependencies":{"bare-utils":"^1.5.1","brittle":"^3.1.0","lunte":"^1.3.0","prettier":"^3.6.2","prettier-config-holepunch":"^1.0.0"},"gitHead":"1a2a7101dbf735070d66103d350e3db82d8bb9aa","_id":"compact-encoding-bitfield@1.1.0","_nodeVersion":"24.13.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-F6wliSKHi50BsBStmnsRJAzJgYSIYzdfSe3M0oHj4uQ1RcctJK/NQVD7wF51bj/DBMne2i5gUxrGUFkNZQns5w==","shasum":"dbdd1e2e7c473dcafa47b8f7ae6d715fa9e3412e","tarball":"http://registry-npm.ywwl.com/compact-encoding-bitfield/download/compact-encoding-bitfield-1.1.0.tgz","fileCount":4,"unpackedSize":15661,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCqY4tXLnKmCx4nsftF5OS/kpPV/aQ+YBI0DCDpU3W/hAIgbJ45JCH8ynKDhyG2a1J9ah/ZSJbPL6aGd5E5gKWPtqE="}],"size":5519,"noattachment":false,"key":"/compact-encoding-bitfield/-/compact-encoding-bitfield-1.1.0.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/compact-encoding-bitfield_1.1.0_1778000328829_0.11139444218938777"},"_hasShrinkwrap":false,"readme":"# compact-encoding-bitfield\n\n[compact-encoding](https://github.com/compact-encoding/compact-encoding) codec for bitfields. Uses a variable length encoding that is ABI compatible with `cenc.uint`.\n\n```sh\nnpm install compact-encoding-bitfield\n```\n\n## Usage\n\n```js\nconst cenc = require('compact-encoding')\nconst bitfield = require('compact-encoding-bitfield')\n\nconst buffer = cenc.encode(bitfield(8), 0b1110_1011)\n// <Buffer fd eb 00>\n\ncenc.decode(bitfield(8), buffer)\n// <Buffer eb>\n```\n\nBitfields are represented as buffers. For each byte, the least significant bit denotes the first bit and the most significant bit denotes the last bit. For example, bit `0` will be the least significant bit of the first byte and bit `15` will be the most significant bit of the second byte.\n\nThe encoding will convert numbers to buffers. Buffers may also be passed directly and will be returned on decode.\n\n## ABI\n\nDepending on `length`, the bitfield is stored using a variable number of bytes:\n\n1. `length < 8`: 1 byte with no prefix.\n2. `length <= 16`: 2 bytes with a `0xfd` prefix.\n3. `length <= 32`: 4 bytes with a `0xfe` prefix.\n4. `length <= 64`: 8 bytes with a `0xff` prefix.\n\n`length` must not exceed 64 bits.\n\n## License\n\nApache 2.0\n","publish_time":1778000328979,"_cnpm_publish_time":1778000328979,"dist-tags":{"latest":"1.1.0"}}