bit-prefix-len

0.2.0 • Public • Published

bit-prefix-len

Returns the bit prefix length of a buffer -- the number of consecutive 0s or 1s. This is useful for all sorts of crypto things.

> var bitPrefixLen = require('bit-prefix-len')
> bitPrefixLen(0, new Buffer('0000abc00abc', 'hex'))
16
> bitPrefixLen(0, new Buffer('800000000000', 'hex'))
0
> bitPrefixLen(1, new Buffer('fffffffffffe', 'hex'))
47
> bitPrefixLen(1, new Buffer('ff00', 'hex'))
8

Package Sidebar

Install

npm i bit-prefix-len

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • jbenet