brand-music
Version:
Strongly typed music theory library
142 lines (134 loc) • 4.71 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all2) => {
for (var name in all2)
__defProp(target, name, { get: all2[name], enumerable: true });
};
var __copyProps = (to, from3, except, desc) => {
if (from3 && typeof from3 === "object" || typeof from3 === "function") {
for (let key of __getOwnPropNames(from3))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/PitchClassSet.ts
var PitchClassSet_exports = {};
__export(PitchClassSet_exports, {
ALL: () => ALL3,
EMPTY: () => EMPTY2,
add: () => add2,
difference: () => difference2,
from: () => from2,
fromRaw: () => fromRaw,
fromRawMasked: () => fromRawMasked,
fromRawUnknown: () => fromRawUnknown,
has: () => has2,
hasShape: () => hasShape2,
intersection: () => intersection2,
isSubset: () => isSubset2,
isSuperset: () => isSuperset2,
mark: () => mark,
markRaw: () => markRaw,
markRawUnknown: () => markRawUnknown,
remove: () => remove2,
symmetricDifference: () => symmetricDifference2,
toggle: () => toggle2,
toggleAll: () => toggleAll,
union: () => union2,
values: () => values2
});
module.exports = __toCommonJS(PitchClassSet_exports);
// src/internal/refined/Int.ts
var isInt = (v) => Number.isInteger(v);
// src/internal/refined/Literal.ts
var is = (start, end) => (v) => Number.isSafeInteger(v) && start <= v && v <= end;
var all = (start, end) => (
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
[...Array(end - start + 1)].map((_, i) => start + i)
);
// src/internal/PitchClass.ts
var min = 0;
var max = 11;
var hasShape = is(min, max);
var from = (v) => v;
var const_ = (value) => value;
var MIN = const_(min);
var MAX = const_(max);
var ALL = all(min, max).map(const_);
// src/internal/refined/NonNegative.ts
var isNonNegative = (v) => typeof v === "number" && v >= 0;
// src/internal/refined/NonNegativeInt.ts
var isNonNegativeInt = (v) => isInt(v) && isNonNegative(v);
// src/internal/refined/TwelveBits.ts
var isTwelveBits = (v) => isNonNegativeInt(v) && v < 1 << 12;
var EMPTY = 0;
var ALL2 = 4095;
var masked = (v) => v & ALL2;
var one = (value) => 1 << value;
var fromValues = (...values3) => values3.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);
// src/internal/PitchClassSet.ts
var hasShape2 = isTwelveBits;
var mark = (_v) => true;
var markRaw = (v) => hasShape2(v);
var markRawUnknown = (v) => hasShape2(v);
var fromRaw = (v) => v;
var fromRawMasked = (v) => fromRaw(masked(v));
var fromRawUnknown = (v) => isTwelveBits(v) ? fromRaw(v) : void 0;
var EMPTY2 = fromRaw(EMPTY);
var ALL3 = fromRaw(ALL2);
var from2 = (...values3) => fromRaw(fromValues(...values3));
var toggleAll = (pcs) => fromRaw(complement(pcs));
var union2 = (a, b) => fromRaw(union(a, b));
var intersection2 = (a, b) => fromRaw(intersection(a, b));
var symmetricDifference2 = (a, b) => fromRaw(symmetricDifference(a, b));
var difference2 = (a, b) => fromRaw(difference(a, b));
var has2 = (pcs, pc) => has(pcs, pc);
var add2 = (pcs, pc) => fromRaw(add(pcs, pc));
var remove2 = (pcs, pc) => fromRaw(remove(pcs, pc));
var toggle2 = (pcs, pc) => fromRaw(toggle(pcs, pc));
var isSuperset2 = (value, of) => isSuperset(value, of);
var isSubset2 = (value, of) => isSubset(value, of);
var values2 = (pcs) => values(pcs).map(from);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ALL,
EMPTY,
add,
difference,
from,
fromRaw,
fromRawMasked,
fromRawUnknown,
has,
hasShape,
intersection,
isSubset,
isSuperset,
mark,
markRaw,
markRawUnknown,
remove,
symmetricDifference,
toggle,
toggleAll,
union,
values
});
//# sourceMappingURL=PitchClassSet.cjs.map