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