{"name":"bitfield","description":"a simple bitfield, compliant with the BitTorrent spec","version":"4.0.0","author":{"name":"Felix Boehm","email":"me@feedic.com"},"funding":{"url":"https://github.com/sponsors/fb55"},"sideEffects":false,"main":"lib/index.js","types":"lib/index.d.ts","directories":{"lib":"lib/"},"bugs":{"url":"https://github.com/fb55/bitfield/issues"},"devDependencies":{"@types/jest":"^26.0.0","@types/node":"^14.11.8","@typescript-eslint/eslint-plugin":"^4.4.1","@typescript-eslint/parser":"^4.4.1","coveralls":"*","eslint":"^7.11.0","eslint-config-prettier":"^6.0.0","eslint-plugin-node":"^11.1.0","jest":"^26.5.3","prettier":"^2.0.5","ts-jest":"^26.1.0","typescript":"^4.0.2"},"engines":{"node":">=8"},"keywords":["bitfield","buffer","bittorrent"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/fb55/bitfield.git"},"scripts":{"test":"jest --coverage && npm run lint","coverage":"cat coverage/lcov.info | coveralls","lint":"npm run lint:es && npm run lint:prettier","lint:es":"eslint .","lint:prettier":"npm run prettier -- --check","format":"npm run format:es && npm run format:prettier","format:es":"npm run lint:es -- --fix","format:prettier":"npm run prettier -- --write","prettier":"prettier '**/*.{js,ts,md,json,yml}'","build":"tsc","prepare":"npm run build"},"jest":{"preset":"ts-jest","testEnvironment":"node"},"prettier":{"tabWidth":4},"gitHead":"75b7eb70caa5603421037943c3616565a9f353e4","homepage":"https://github.com/fb55/bitfield#readme","_id":"bitfield@4.0.0","_nodeVersion":"15.0.1","_npmVersion":"7.0.3","dist":{"integrity":"sha512-jtuSG9CQr5yoHFuvhgf50+DH8Aezl3C/mMSfqdG4DqP7Kqe34uBUtCEHPN9oWaldTm96/i7y5e778SnM5ES4rw==","shasum":"3094123c870030dc6198a283d779639bd2a8e256","tarball":"http://registry-npm.ywwl.com/bitfield/download/bitfield-4.0.0.tgz","fileCount":6,"unpackedSize":12112,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnDMDCRA9TVsSAnZWagAA5acQAJNF/pRiM+ZyKKY3Hy1G\nKbQDLPU7myyogNTBNvStvi5nK1cxyDxxrSqBy1rEGbRekFWPpBR5wLpmIk74\nmoJTTv4xZW5co4YbFCINr3aa3iAWfGZZvAfBgysCyX0jHhmmhQebPpAwKlmZ\navyVrfs4vdzZiZj1cQCpq/cTQn5gvt88W78bEFnwdt/LPqMHIiCCAoIGI0vc\ngP708mvssVOvAALDlxV+HHr8A92Ss8hzkYag911aT0ftJ8szbzqxFLWAsZlb\nUvu7Hxah1BzVbh3hLFacjmMEjon/CJsG1cQb58nm+L+flRM/KYgtAFUVzpiP\nOW4oAlnt3wibhOs0xeNiRkrP2LuHl0QHXybR086rbjIARde5RvDlIVIRxRrA\ni+L0VlSbIs7wAhU9AadyZ1H4lRCV+5rDJFKgLskdzsUEK1xF7af4PR0bSux1\n9SqGzUhTYG7MI0Nk/1r1mc5ZPwfDNTAvD2FLgIuMI6Q9GtiReIvgLyzkoCQE\ntewU3oBSfPyokz7QduqmRXgsrQd8rDcHy+p/GsqAgOjQKWIK12WQaCvi9VR+\nhm3U4UL2qg3Pci15pcQ4Kls/h4vwm7pK1V7sQc4no+D/s9q0n0dhV/c2TwMf\n4nrR3MLmz4Zb1a7sSsjAsqMQTWRmTHlcqi3Ly7mxqY8/a/IuDjXpVBOFZH6J\nQW14\r\n=nITW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICtRZjazpILTJYRN61sIvxyBMNsgWATK9kj6pviZEx0BAiBmq/1B7TuQE+zPYC2hiUddRR+tW9I60E4QRWCDkn40Cw=="}],"size":4001,"noattachment":false,"key":"/bitfield/-/bitfield-4.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"feross","email":"feross@feross.org"},{"name":"feedic","email":"me@feedic.com"}],"_npmUser":{"name":"feedic","email":"me@feedic.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bitfield_4.0.0_1604072194788_0.6582520568726633"},"_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":1604072194940,"_cnpm_publish_time":1604072194940,"dist-tags":{"latest":"5.0.1"}}