Bitwise mask
Installation
$ npm install --save bitwise-mask
Usage
; const Directions = TOP: 1 << 0 RIGHT: 1 << 1 BOTTOM: 1 << 2 LEFT: 1 << 3 DirectionsTOP_RIGHT = bitmask; let mask = bitmask; mask = bitmask; bitmask; // true
API
mask = create(...fields)
Create a mask
with the given fields
.
field = bitmask.combine(...fields)
Combine fields
into one field
.
mask = bitmask.add(mask, ...fields)
Add fields
to mask
.
mask = bitmask.remove(mask, ...fields)
Remove fields
from mask
.
bitmask.contains(mask, ...fields)
Check if the the mask
contains the fields
and returns a boolean.
License
MIT, see LICENSE.md for more details.