Skip to content

Instantly share code, notes, and snippets.

@anton-voron
anton-voron / bitmask-crud.js
Created November 8, 2021 12:34 — forked from mediaupstream/bitmask-crud.js
Store CRUD settings in 2 bytes with bitmasks
const CREATE = 0
const READ = 1
const UPDATE = 2
const DELETE = 3
const add = (a, b) => a |= (1 << b)
const remove = (a, b) => a &= ~(1 << b)
const has = (a, b) => ((a & (1 << b)) > 0)
const bin = (a) => (s).toString(2)