SDK
SDK Javascript v7.x
2

bitpos #

Returns the position of the first bit set to 1 or 0 in a string, or in a substring.

[Redis documentation]

Arguments #

bitpos(key, bit, [options]);

ArgumentsTypeDescription
key
string
Key
bit
integer
Bit to look for.
Accepted values: 0, 1
options
object
Optional query arguments

options #

The options arguments can contain the following option properties:

PropertyType (default)Description
end
integer
Search ends at the provided offset
queuable
boolean (true)
If true, queues the request during downtime, until connected to Kuzzle again
start
integer
Search starts at the provided offset
timeout
number

(-1)
Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely
triggerEvents
boolean

(false)
If set to true, will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop.
Available since Kuzzle 2.31.0

Resolve #

Resolves to the position of the first bit found matching the searched value.

Usage #

try {
  await kuzzle.ms.set('key', '\x00\x00\x01');
  // Prints: 23
  console.log(await kuzzle.ms.bitpos('key', 1));
} catch (error) {
  console.error(error.message);
}