brand-music
Version:
Strongly typed music theory library
45 lines (43 loc) • 1.22 kB
JavaScript
import {
all,
isNonNegativeInt
} from "./chunk-YLMQSMVX.js";
// src/internal/refined/TwelveBits.ts
var isTwelveBits = (v) => isNonNegativeInt(v) && v < 1 << 12;
var EMPTY = 0;
var ALL = 4095;
var masked = (v) => v & ALL;
var one = (value) => 1 << value;
var fromValues = (...values2) => values2.map(one).reduce(union);
var values = (a) => all(0, 11).filter((value) => has(a, value));
var complement = (a) => masked(~a);
var union = (a, b) => a | b;
var intersection = (a, b) => a & b;
var symmetricDifference = (a, b) => a ^ b;
var difference = (a, b) => intersection(a, complement(b));
var has = (a, value) => Boolean(intersection(a, fromValues(value)));
var add = (a, value) => union(a, fromValues(value));
var remove = (a, value) => intersection(a, complement(fromValues(value)));
var toggle = (a, value) => symmetricDifference(a, fromValues(value));
var isSuperset = (a, of) => !intersection(complement(a), of);
var isSubset = (a, of) => isSuperset(of, a);
export {
isTwelveBits,
EMPTY,
ALL,
masked,
fromValues,
values,
complement,
union,
intersection,
symmetricDifference,
difference,
has,
add,
remove,
toggle,
isSuperset,
isSubset
};
//# sourceMappingURL=chunk-2U4535RW.js.map