{"name":"quickbit-universal","version":"1.0.0","description":"Universal wrapper for libquickbit with a JavaScript fallback","main":"index.js","browser":{"./index.js":"./browser.js"},"scripts":{"test":"standard && brittle test.mjs"},"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":{"quickbit-native":"^1.0.0"},"devDependencies":{"b4a":"^1.6.0","brittle":"^2.3.1","standard":"^17.0.0"},"gitHead":"77aeffff7cf7593b02a2a35324c4e45e33b6922d","_id":"quickbit-universal@1.0.0","_nodeVersion":"18.7.0","_npmVersion":"8.16.0","dist":{"integrity":"sha512-RFJ8enKGBRiPc4cK7HkPT7W7ez/iIuNedM+TCxJYI0eOxcHQY/SAAvSKFccr+l5FdGsiB1N4M94ekYDAIJTqMA==","shasum":"00cb8b818b5fd8e7e45d837761a5fe589f58bf50","tarball":"http://registry-npm.ywwl.com/quickbit-universal/download/quickbit-universal-1.0.0.tgz","fileCount":5,"unpackedSize":3819,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDimiSmxxtaQhUKH88iTC1eOcf2BvEYO1Qi3ppoP/mylAiBHWirXNcJ98F5G9uK+6jGVEnl9OCGuFF/cs5J9kgnCKA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjFaf+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmot9RAAov18kH9Qed4FhSg/5mMfieEZ23LEbSCTlkrTMhWAxyJiNUQ1\r\nrWku43h05XujjQ91uZAavohPV6hJAs0BB9K3bOgmuBBqzvHUUIqQMlEapejn\r\nVPYITnwSoS8u56DOb4wrG2/5OFlxiBBwfHKQeBrvU69QIFcfzkt19EvCX7W7\r\n+wkabCa53MqK59ZH9MGSW0tpPX68N4s5o4wtrAV8UJdbhMYEhbEurdcnCBL9\r\n+ugVQA6lZpjs3L1B1Bq8/LaTdaVmJy3IZAlGa84n3NmkaFtIn0RzVdGAZ4Yz\r\nPcR4XLkWQ6EEltST48x3W8JFpvlFLP+4Jk/1W5ScB4mtBd4xOXIEokihbbCx\r\n5I8kYTF7w5xGZRNerfsmPoFagaoT9KZIwEbGbeBwLtxw4gGgEf91Gz7wkHgb\r\nm0RZpY75LhZb5TmaWSDsWRndFnh4nceoFpBhBQ3Blqp4ENxttDsEicKWRpYr\r\nFtEzxx+9M65f4mkRZ1N8QsEae2x+hQf7cSVoUhXDZpGgvZT0wawu7nrWFPc7\r\nLD+/rHLKg7ymmVms/LH889ADYok4WPcs3B+W0f2CkUZ2E6DhUs2EZsNYwqYc\r\n8n4fCT5YxeIIM5YbEK4IbtAP0FFEQvR3G4SPugcI00Q+Xs9jERNYWtRvE7un\r\nyrgQKKZ2HeTZsE9kqN/pal87HW6k3AUiHBY=\r\n=Lzbv\r\n-----END PGP SIGNATURE-----\r\n","size":1661,"noattachment":false,"key":"/quickbit-universal/-/quickbit-universal-1.0.0.tgz"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":"kasperisager@hey.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/quickbit-universal_1.0.0_1662363646529_0.35869672269399744"},"_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":1662363646663,"_cnpm_publish_time":1662363646663,"dist-tags":{"latest":"2.2.1"}}