# flags A small utility which can be used to manipulate specific bits in a sequence of bits. ## Installation ``` npm i @mightyplow/flags ``` ## set(flag, [sequence]) ⇒ number Sets one or multiple flags on a sequence of bits. **Kind**: global function | Param | Type | Default | Description | | --- | --- | --- | --- | | flag | number \| Array.<number> | | The bits which should be set | | [sequence] | number | 0 | The bit sequence to set the flags on | **Example** ```js import { set } from '@mightyplow/flags' const Option = { foo: 2 ** 0, bar: 2 ** 1, baz: 2 ** 2 } const base = 0b000; console.log(set([Option.foo, Option.baz], base).toSting(2)) // "101" ``` ## unset(flag, [sequence]) ⇒ number Unsets one or multiple flags on a sequence of bits. **Kind**: global function | Param | Type | Default | Description | | --- | --- | --- | --- | | flag | number \| Array.<number> | | The bits which should be unset | | [sequence] | number | 0 | The bit sequence to set the flags on | ## toggle(flag, [sequence]) ⇒ number Inverts one or multiple flags on a sequence of bits. **Kind**: global function | Param | Type | Default | Description | | --- | --- | --- | --- | | flag | number \| Array.<number> | | The bits which should be inverted | | [sequence] | number | 0 | The bit sequence to set the flags on | ## isset(flag, [sequence]) ⇒ boolean Check whether one or multiple flags are set. Returns only true when all requested bits are set. **Kind**: global function | Param | Type | Default | Description | | --- | --- | --- | --- | | flag | number \| Array.<number> | | The bits which should be inverted | | [sequence] | number | 0 | The bit sequence to set the flags on |