{"name":"bitfield","description":"a very simple bitfield implementation using buffers","version":"3.0.0","author":{"name":"Felix Boehm","email":"me@feedic.com"},"bugs":{"url":"https://github.com/fb55/bitfield/issues"},"devDependencies":{"standard":"^12.0.1","tape":"~4.11.0"},"engines":{"node":">=8"},"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":"089a5e88bce38059444fb18e1f7d48a974a05060","homepage":"https://github.com/fb55/bitfield#readme","_id":"bitfield@3.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.10.0","dist":{"integrity":"sha512-hJmWKucJQfdSkQPDPBKmWogM9s8+NOSzDT9QVbJbjinXaQ0bJKPu/cn98qRWy3PDNWtKw4XaoUP3XruGRIKEgg==","shasum":"b2d32c707866d42f016ae9bd8469999a9f51b59c","tarball":"http://registry-npm.ywwl.com/bitfield/download/bitfield-3.0.0.tgz","fileCount":4,"unpackedSize":4121,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdJmbtCRA9TVsSAnZWagAAwvIP/ihRb9mlo+UKWbGGi4TQ\n73fBUjRDkFJUMNlS/qmz7aF9+MDJAvPnvwlx/lbNGVulGpyEP2ySvfNiU4bz\nJ5flL8QMFhgV+elWfVPfsVP4WcYqjIyTZOFDARL+YYSGlprlKilZeP+cmoYW\nJl4lagUZnxqwh7GApUSIfKu6xeWch6EepQf2OjRUX4snkpF1BWCZ9Ra4Er+y\nuUYmkSN2kfK77szZMtDzMicSABAlXr8zxA9BkvJsxB90imtCOEc+fDr7sVgs\nEE5r5gxxP1mv4cSyeMJ/CF7wVKCdAlQw3nWC9Fw3Q0k95Hf1MiFM9nX6B/mw\nAYhR8K2b+c89r0aDx6yNSmRY4p9dFG1ZYeh2YU/Kin1FECdD/fWV/GNPU5u2\nK/FCDHI8X+bWlSt8yJBOucwiR3U/FcVUfLv9yxc2sw7sT3LiAPBmirgES9wG\n4e8fjl+faB48Lk4bYhXuf3/zjEPLydOgh0AN6kgftrG5cyNMF5rkztriK7yA\nOGkvf9d3WwDyiDRr4MqVN4kxH1QKLgKzmXkrVh3Ds6S3Hxyw+oOkvEBmREda\n3kiUxUbrNGKhxfvNf+KwjqR62xkowxTjUNAK+Nobf3uWWbPa2MEu+SpkV0z/\n4omcpxnxBcarrNjhu0uyBMkrKKI8ZJEsu/Tz/1BH2ep7eZupso45e+GfUbw+\n0mWP\r\n=lTJZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDZhr9svZKyVvx0Ndpgef/erkwVa63oq/cI8IlUbYsGAwIgX0v0AO6UyZsjx6qlj1QvPDTAhIEu8YlQFOQY7rBKavU="}],"size":2222,"noattachment":false,"key":"/bitfield/-/bitfield-3.0.0.tgz"},"maintainers":[{"name":"feedic","email":"me@feedic.com"},{"name":"feross","email":"feross@feross.org"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmUser":{"name":"feross","email":"feross@feross.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bitfield_3.0.0_1562797805025_0.9306880264885444"},"_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":1562797805269,"_cnpm_publish_time":1562797805269,"dist-tags":{"latest":"5.0.1"}}