Package Exports
- fbit-field
- fbit-field/compiler
- fbit-field/compiler.js
- fbit-field/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fbit-field) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
bit-field
Simple bit field for some systems: rights, permissions, configs and more...
How to use BitField
class?
This is utility-class for comfort work with bits. It can:
- compare bits:
BitField.equals
,new BitField().has
- summarize bits:
BitField.summarize
,BitField.add
,new BitField().add
- subtract bits:
BitField.remove
,new BitField().remove
- takes logarithm2 of bits (big integers):
BitField.logarithm2
- takes max bit of bits (find big integer):
BitField.max
import { BitField } from "fbit-field";
// BitField.equals
// compares two values
BitField.equals(1n, 1n); // true
BitField.equals(1n, "1"); // true
BitField.equals(1n, 2n); // false
BitField.equals(1n, "2"); // false
// BitField.summarize
// summurize values
BitField.summarize(1n, 2n, 4n); // 7n
BitField.summarize(2n, 2n, 4n); // 6n
BitField.summarize(1n, 4n); // 5n
BitField.summarize(1n, 1n); // 1n
BitField.summarize(1n); // 1n
// BitField.add
// summurize values
BitField.add(1n, 2n, 4n); // 7n
BitField.add(2n, 2n, 4n); // 6n
BitField.add(1n, 4n); // 5n
BitField.add(1n, 1n); // 1n
// BitField.remove
// subtract values
BitField.remove(7n, 4n, 2n); // 1n
BitField.remove(14n, 4n, 2n); // 8n
BitField.remove(14n, 4n, 2n, 1n); // 8n
BitField.remove(14n, 1n); // 14n
// BitField.logarithm2
// takes the logarithm of a number
BitField.logarithm2(1n << 10n); // 10n
BitField.logarithm2(1n << MULTIPLIER); // MULTIPLIER
BitField.logarithm2(2n << 10n); // 11n
BitField.logarithm2(4n << 10n); // 12n
// BitField.max
// takes max value of values
BitField.max(1n, 2n, 3n, 4n); // 4n
// new BitField().add
// summurize values
new BitField(1n).add(2n, 4n); // 7n
new BitField(2n).add(2n, 4n); // 6n
new BitField(1n).add(4n); // 5n
new BitField(1n).add(1n); // 1n
// new BitField().remove
// subtract values
new BitField(7n).remove(4n, 2n); // 1n
new BitField(14n).remove(4n, 2n); // 8n
new BitField(14n).remove(4n, 2n, 1n); // 8n
new BitField(14n).remove(1n); // 14n
// new BitField().has
// checking bits equals
new BitField(1n).has(1n); // true
new BitField(1n).has("1"); // true
new BitField(1n).has(2n); // false
new BitField(1n).has("2"); // false
How to use BitBuilder
class?
...so hard to night-me, can continue tomorrow?...