{"_id":"quickbit-universal@2.2.1","bugs":{"url":"https://github.com/holepunchto/quickbit-universal/issues"},"dist":{"shasum":"f67c1bc11940b9425d956f82acd71405c809fabb","tarball":"http://registry-npm.ywwl.com/quickbit-universal/download/quickbit-universal-2.2.1.tgz","fileCount":5,"integrity":"sha512-OwHA5udZkQMKlw0KZmp0V7VpdGvZwe5tO8NyoMKferbxadvAP6H4OWTJyOh1FaxojBHI5crguQTmhrLEoc3p/A==","signatures":[{"sig":"MEUCIE5lkVY+5qvEMZ7L6ALeI9lrbx2cMLPpCPn0gVXuJ9CvAiEA/bJ/IhPq9LXcjNEfLNMu5w8l27PNuBnk9uDUGjZaKdI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDz+WPXDc7yRJqlmda16UOLQh7Dn43QMM+1yA+k2jZLsAIgcztjz0rcqkFOaLYSAgcBi3J4CoHCKs+xEMOfiwFV1Jo="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/quickbit-universal@2.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":25303,"size":7354,"noattachment":false,"key":"/quickbit-universal/-/quickbit-universal-2.2.1.tgz"},"main":"index.js","name":"quickbit-universal","author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"browser":{"./index.js":"./fallback.js"},"gitHead":"c5cc80e7cb706c75b461594c895c949acfd9f789","license":"ISC","scripts":{"lint":"prettier --check . && lunte","test":"npm run test:node && npm run test:bare","format":"prettier --write . && lunte --fix","test:bare":"brittle-bare --coverage test.mjs","test:node":"brittle-node --coverage test.mjs"},"version":"2.2.1","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"53b6ae3a-6309-4cbf-974b-91032859831b"}},"homepage":"https://github.com/holepunchto/quickbit-universal#readme","repository":{"url":"git+https://github.com/holepunchto/quickbit-universal.git","type":"git"},"_npmVersion":"11.19.1","description":"Universal wrapper for libquickbit with a JavaScript fallback","directories":{},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_nodeVersion":"24.22.1","dependencies":{"b4a":"^1.6.0","simdle-universal":"^1.1.0"},"_hasShrinkwrap":false,"devDependencies":{"lunte":"^1.8.6","brittle":"^3.1.0","prettier":"^3.6.2","prettier-config-holepunch":"^2.0.0"},"optionalDependencies":{"quickbit-native":"^2.2.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/quickbit-universal_2.2.1_1793123508396_0.16426417216003875"},"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":1793123508640,"_cnpm_publish_time":1793123508640,"dist-tags":{"latest":"2.2.1"}}