{"name":"bitfield","description":"a very simple bitfield implementation using buffers","version":"2.0.0","author":{"name":"Felix Boehm","email":"me@feedic.com"},"bugs":{"url":"https://github.com/fb55/bitfield/issues"},"devDependencies":{"standard":"^11.0.0","tape":"~4.9.0"},"keywords":["bitfield","buffer"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git+https://github.com/fb55/bitfield.git"},"scripts":{"test":"standard && tape tests.js"},"gitHead":"af94765651c5c6993506c2aec2cd6ee8d8595142","homepage":"https://github.com/fb55/bitfield#readme","_id":"bitfield@2.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"feross","email":"feross@feross.org"},"dist":{"integrity":"sha512-4xM4DYejOHQ/qWBfeqBXNA4mJ12PwcOibFYnH1kYh5U9BHciCqEJBqGNVnMJXUhm8mflujNRLSv7IiVQxovgjw==","shasum":"fbe6767592fe5b4c87ecf1d04126294cc1bfa837","tarball":"http://registry-npm.ywwl.com/bitfield/download/bitfield-2.0.0.tgz","fileCount":6,"unpackedSize":8266,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCH+Bj0bGkybeOcX0arCtnB95jowjRsZsg4vDSJotpFOgIgcqxyNvrCDRWYMPUTqZgZILT/onLpJ3hp1etO+4ieDl0="}],"size":3232,"noattachment":false,"key":"/bitfield/-/bitfield-2.0.0.tgz"},"maintainers":[{"name":"feedic","email":"me@feedic.com"},{"name":"feross","email":"feross@feross.org"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bitfield_2.0.0_1519105929978_0.9778634192858295"},"_hasShrinkwrap":false,"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":1519105930163,"_cnpm_publish_time":1519105930163,"dist-tags":{"latest":"5.0.1"}}