{"name":"quickbit-universal","version":"1.1.2","description":"Universal wrapper for libquickbit with a JavaScript fallback","main":"index.js","browser":{"./index.js":"./fallback.js"},"scripts":{"test":"standard && brittle test.mjs","prebuild":"prebuildify --napi --cwd native"},"repository":{"type":"git","url":"git+https://github.com/holepunchto/quickbit-universal.git"},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","bugs":{"url":"https://github.com/holepunchto/quickbit-universal/issues"},"homepage":"https://github.com/holepunchto/quickbit-universal#readme","dependencies":{"b4a":"^1.6.0","node-gyp-build":"^4.5.0"},"devDependencies":{"brittle":"^3.1.0","napi-macros":"^2.0.0","prebuildify":"^5.0.1","standard":"^17.0.0"},"gitHead":"b83a6e2f61a26c250db3a946612126cc779b627a","_id":"quickbit-universal@1.1.2","_nodeVersion":"18.7.0","_npmVersion":"8.16.0","dist":{"integrity":"sha512-M285jhBz4f2q7u+35d5iKiw08ANm2ShpTGm/XU0kZrJct4+dZOkX3h5UpjPo3Phzrw8AiGOfqIG4zTPPwsT5Uw==","shasum":"8980e0b831642168080b7729482ead502de1dbfb","tarball":"http://registry-npm.ywwl.com/quickbit-universal/download/quickbit-universal-1.1.2.tgz","fileCount":10,"unpackedSize":253769,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAu98Aa1xehfbIpvzJFMk4dOiyeFwx2FPckYTeNNb+yAAiEAzZ2DHegaclp04bP7zmpcxQrDvh0Bqfk+2Oy+eB0CKtQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjGFysACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrPjRAAnuPI+JEPlab0rIPTDeil2s2vMT2yoC1ecpg+X9KRK4HXaysl\r\nykp8MHn83RVSIveWBYk57ecqn/Li3Qn7lUkMok3SPZtOFDUTOVs+OsbPBl/0\r\nNh59tHfCrMyexuPNGbLmLktpCvzbk6AInxQuAYWCUcjIwAJwUD8cn6J2TvKm\r\nFTRbSa0gvkRvHp3oQ7ifL/894knxnO3e99PL2bNeuKPM0BKuuXvUOF22tGaO\r\nbriT2b39ww0qlR908HftfG/zJUgxHFWtvaqHYcHlMMcuOi1d8iimq1TFJGRL\r\nFYAiXqM+2lb+Z/WaK5uMd3h4764hxVDtNtF1AkjyP+Jp460L8Z0VTzXE1AgX\r\nQqwt4XTU28pJfAgjFnpIkSmE3BjXvvsqt+UwYl71jJfZRe6cY9xqRvo7EaXp\r\nM3Roa2/57WBg1TyLukVAxQXkni0+DrY2rCBaJEGU+KG/3oB3DlsmdkjdqJJS\r\ncOXxGcaf54zXd1nRWWJRznagO7cN5OMO84tHz+gW1R5nZUG5s5nv690Mbz0h\r\nlq56T5blLAr7MYg8ryJWhPPDluaEP7MXGRlrMp6OLY+pTfqAYunyf5w7/Fy2\r\n8f5O1T49X5Hx1Olm6L7PuXTHT1KtDCbfMnWMXwP5aKv4c2YmYnvSzkJy6BE0\r\nQOqmPxNttN57b+K7RZMzsD+DN838phlnrQw=\r\n=9zUK\r\n-----END PGP SIGNATURE-----\r\n","size":78963,"noattachment":false,"key":"/quickbit-universal/-/quickbit-universal-1.1.2.tgz"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"directories":{},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"kasperisager","email":"kasperisager@hey.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/quickbit-universal_1.1.2_1662540971940_0.8542867873474307"},"_hasShrinkwrap":false,"readme":"# quickbit-universal\n\nUniversal wrapper for https://github.com/holepunchto/libquickbit with a JavaScript fallback.\n\n```sh\nnpm install quickbit-universal\n```\n\n## Usage\n\n```js\nconst { get, set, findFirst } = require('quickbit-native')\n\nconst field = Buffer.alloc(256) // 2048 bits\n\nconst changed = set(field, 1000)\n// true\n\nget(field, 1000)\n// true\n\nfindFirst(field, true)\n// 1000\n```\n\n## API\n\n#### `const b = get(field, bit)`\n\nGet the given bit, which will either be `true` (set) or `false` (unset).\n\n#### `const changed = set(field, bit[, value])`\n\nSet the given bit to `value`, which defaults to `true`. Returns `true` if the bit changed, otherwise `false`.\n\n#### `field = fill(field, value[, start[, end]])`\n\nFill the given bit range with `value`. `start` defaults to `0` and `end` defaults to the bit length of the field. Returns the modified field.\n\n#### `clear(field, chunk)`\n\nClear the bits from `field` that are set in the `{ field, offset }` chunk.\n\n#### `const i = findFirst(field, value[, position])`\n\nReturn the index of the first occurrence of `value`, or `-1` if not found. If `position` is given, return the first index that is greater than or equal to `position`.\n\n#### `const i = findLast(field, value[, position])`\n\nReturn the index of the last occurrence of `value`, or `-1` if not found. If `position` is given, return the last index that is less than or equal to `position`.\n\n### Indexing\n\n#### `const index = Index.from(fieldOrChunks)`\n\nConstruct an index of the bits in a bit field or an array of sparse `{ field, offset }` chunks.\n\n#### `const changed = index.update(bit)`\n\nUpdate the given bit in the index.\n\n#### `const position = index.skipFirst(value[, position])`\n\nSkip the first parts of the index that contain nothing but `value`. If the index contains *only* `value`, the last index of the field is returned.\n\n#### `const position = index.skipLast(value[, position])`\n\nSkip the last parts of the index that contain nothing but `value`. If the index contains *only* `value`, the first index of the field is returned.\n\n## License\n\nApache 2.0\n","publish_time":1662540972153,"_cnpm_publish_time":1662540972153,"dist-tags":{"latest":"2.2.1"}}