1.0.0 • Published 2 years ago

boolopt v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

boolopt (boolean options)

A tiny package to get and set boolean options using bitwise operations.

Installation

npm install --save boolopt

Usage

Calling boolopt returns an object with the methods get and set on it.

import boolopt from 'boolopt';

// initialize the values (omitting them sets them to 0)
const { get, set } = boolopt(false, false, true);

// you can now access them by index
get(0); // false
get(1); // false
get(2); // true

set(1, true);

get(1); // true

It combines nicely with enums:

const OPTIONS = Object.freeze({ HUNGRY: 0, TIRED: 1 });

const { get, set } = boolopt();

set(OPTIONS.HUNGRY, true);
set(OPTIONS.TIRED, true);

License

MIT © Lion Ralfs

1.0.0

2 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

4 years ago