{"name":"bitfield","version":"5.0.0","keywords":["bitfield","buffer","bittorrent"],"author":{"name":"Felix Boehm","email":"me@feedic.com"},"license":"MIT","_id":"bitfield@5.0.0","maintainers":[{"name":"fb55","email":"me@feedic.com"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"feross","email":"feross@feross.org"}],"homepage":"https://github.com/fb55/bitfield#readme","bugs":{"url":"https://github.com/fb55/bitfield/issues"},"dist":{"shasum":"8b1dae5becf8308cb57a6cce294d0adb248c0fd4","tarball":"http://registry-npm.ywwl.com/bitfield/download/bitfield-5.0.0.tgz","fileCount":7,"integrity":"sha512-mjCDDq1GnUbfn3DuE9xop5vb0E0DQZpwUY8Tjj60y4ND29E7MTu89RTfGVHfyZexTFj/SgOreRmGMbnp7/mc2g==","signatures":[{"sig":"MEQCIHkcMROeOox1eigS/tffrj8FbVVzILSK1IM2xjZVgyGwAiBB1XuSl75BaiiZ45R9/WfDsP6nY2ivkHEeW1e6KO4lSA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/bitfield@5.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":19099,"size":5244,"noattachment":false,"key":"/bitfield/-/bitfield-5.0.0.tgz"},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"funding":{"url":"https://github.com/sponsors/fb55"},"gitHead":"bae0df9896619507837bba03c618f60fa7f7945d","scripts":{"lint":"npm run lint:es && npm run lint:biome","test":"npm run test:vi && npm run lint","build":"tsc","format":"npm run format:es && npm run format:biome","lint:es":"eslint .","prepare":"npm run build","test:vi":"vitest run","format:es":"npm run lint:es -- --fix","lint:biome":"biome check .","format:biome":"biome check --write ."},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:4ee2a5ab-0b17-4058-906d-cb19bb01a752"}},"repository":{"url":"git+https://github.com/fb55/bitfield.git","type":"git"},"_npmVersion":"11.9.0","description":"a simple bitfield, compliant with the BitTorrent spec","directories":{},"sideEffects":false,"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.0.3","vitest":"^4.0.18","globals":"^17.4.0","typescript":"^5.9.3","@types/node":"^25.5.0","@biomejs/biome":"^2.4.7","@eslint/compat":"^2.0.3","typescript-eslint":"^8.57.1","eslint-config-biome":"^2.1.3","@feedic/eslint-config":"^0.2.3"},"_npmOperationalInternal":{"tmp":"tmp/bitfield_5.0.0_1773752077040_0.9756607696382849","host":"s3://npm-registry-packages-npm-production"},"readme":"# bitfield\n\nA simple bitfield, compliant with the BitTorrent spec.\n\n    npm install bitfield\n\n#### Example\n\n```js\nimport Bitfield from \"bitfield\";\n\nconst field = new Bitfield(256); // Create a bitfield with 256 bits.\n\nfield.set(128); // Set the 128th bit.\nfield.set(128, true); // Same as above.\n\nfield.get(128); // `true`\nfield.get(200); // `false` (all values are initialised to `false`)\nfield.get(1e3); // `false` (out-of-bounds is also false)\n\nfield.set(128, false); // Set the 128th bit to 0 again.\n\nfield.buffer; // The buffer used by the bitfield.\n```\n\n## Class: BitField\n\n### Constructors\n\n- [constructor](#constructor)\n\n### Properties\n\n- [buffer](#buffer)\n\n### Methods\n\n- [forEach](#foreach)\n- [get](#get)\n- [set](#set)\n\n## Constructors\n\n### constructor\n\n\\+ **new BitField**(`data?`: number \\| Uint8Array, `opts?`: BitFieldOptions): `BitField`\n\n#### Parameters:\n\n| Name    | Type                 | Default value | Description                                                                                                                                                                                                                                                       |\n| ------- | -------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `data`  | number \\| Uint8Array | 0             | Either a number representing the maximum number of supported bytes, or a Uint8Array.                                                                                                                                                                              |\n| `opts?` | { grow: number }     | { grow: 0 }   | <p>**grow:**<p>If you `set` an index that is out-of-bounds, the bitfield will automatically grow so that the bitfield is big enough to contain the given index, up to the given size (in bit). <p>If you want the Bitfield to grow indefinitely, pass `Infinity`. |\n\n**Returns:** `BitField`\n\n## Properties\n\n### buffer\n\n• **buffer**: Uint8Array\n\nThe internal storage of the bitfield.\n\n## Methods\n\n### forEach\n\n▸ **forEach**(`fn`: (bit: boolean, index: number) => void, `start?`: number, `end?`: number): void\n\nLoop through the bits in the bitfield.\n\n#### Parameters:\n\n| Name    | Type                                  | Default value           | Description                                                 |\n| ------- | ------------------------------------- | ----------------------- | ----------------------------------------------------------- |\n| `fn`    | (bit: boolean, index: number) => void | -                       | Function to be called with the bit value and index.         |\n| `start` | number                                | 0                       | Index of the first bit to look at.                          |\n| `end`   | number                                | this.buffer.length \\* 8 | Index of the first bit that should no longer be considered. |\n\n**Returns:** void\n\n---\n\n### get\n\n▸ **get**(`i`: number): boolean\n\nGet a particular bit.\n\n#### Parameters:\n\n| Name | Type   | Description            |\n| ---- | ------ | ---------------------- |\n| `i`  | number | Bit index to retrieve. |\n\n**Returns:** boolean\n\nA boolean indicating whether the `i`th bit is set.\n\n---\n\n### set\n\n▸ **set**(`i`: number, `value?`: boolean): void\n\nSet a particular bit.\n\nWill grow the underlying array if the bit is out of bounds and the `grow` option is set.\n\n#### Parameters:\n\n| Name    | Type    | Default value | Description                                  |\n| ------- | ------- | ------------- | -------------------------------------------- |\n| `i`     | number  | -             | Bit index to set.                            |\n| `value` | boolean | true          | Value to set the bit to. Defaults to `true`. |\n\n**Returns:** void\n\n---\n\n### setAll\n\n▸ **setAll**(`array`: `ArrayLike<boolean>`, `offset?`: number): void\n\nSet the bits in the bitfield to the values in the given array.\n\n#### Parameters:\n\n| Name     | Type                 | Default value | Description                           |\n| -------- | -------------------- | ------------- | ------------------------------------- |\n| `array`  | `ArrayLike<boolean>` | -             | Array of booleans to set the bits to. |\n| `offset` | number               | 0             | Index of the first bit to set.        |\n\n**Returns:** void\n\n## License\n\nMIT\n","publish_time":1773752077169,"_cnpm_publish_time":1773752077169,"dist-tags":{"latest":"5.0.1"}}