Pretty code now

This commit is contained in:
Martyn Eggleton 2026-06-21 13:49:11 +01:00
parent 2b2646a768
commit 6870b04fb2
No known key found for this signature in database

View file

@ -2028,9 +2028,9 @@ export const { fastGap, fastgap } = register(['fastGap', 'fastgap'], function (f
const newWhole = !hap.whole const newWhole = !hap.whole
? undefined ? undefined
: new TimeSpan( : new TimeSpan(
newPart.begin.sub(begin.sub(hap.whole.begin).div(factor)), newPart.begin.sub(begin.sub(hap.whole.begin).div(factor)),
newPart.end.add(hap.whole.end.sub(end).div(factor)), newPart.end.add(hap.whole.end.sub(end).div(factor)),
); );
return new Hap(newWhole, newPart, hap.value, hap.context); return new Hap(newWhole, newPart, hap.value, hap.context);
}; };
return pat.withQuerySpanMaybe(qf).withHap(ef).splitQueries(); return pat.withQuerySpanMaybe(qf).withHap(ef).splitQueries();
@ -4133,7 +4133,6 @@ Pattern.prototype.worklet = function (src, ...inputs) {
export const worklet = (...args) => pure({}).worklet(...args); export const worklet = (...args) => pure({}).worklet(...args);
/** /**
* Creates a pattern of numbers in base b from a number or pattern of numbers * Creates a pattern of numbers in base b from a number or pattern of numbers
* limited to d digits long from the right * limited to d digits long from the right
@ -4147,29 +4146,32 @@ export const worklet = (...args) => pure({}).worklet(...args);
* $: note(base("7175 543", 10, 3)).scale("c:major").s("saw") * $: note(base("7175 543", 10, 3)).scale("c:major").s("saw")
* // $: note("1 7 5 5 4 3").scale("c:major").s("saw") * // $: note("1 7 5 5 4 3").scale("c:major").s("saw")
*/ */
export const base = (n, b = 10, d=0) => { export const base = (n, b = 10, d = 0) => {
if(Array.isArray(n)){ if (Array.isArray(n)) {
n = sequence(n); n = sequence(n);
} }
n = reify(n); n = reify(n);
b = reify(b); b = reify(b);
d = reify(d); d = reify(d);
return d.withValue(e => { return d
return b.withValue(c => { .withValue((e) => {
return n.withValue(v => { return b
let digits = []; .withValue((c) => {
let value = v; return n
while (value > 0) { .withValue((v) => {
digits.unshift(value % c); let digits = [];
value = Math.floor(value / c); let value = v;
} while (value > 0) {
if (e){ digits.unshift(value % c);
const l = digits.length; value = Math.floor(value / c);
if (l > e){ }
digits = digits.slice(-1 * e); if (e) {
} const l = digits.length;
/* if (l > e) {
digits = digits.slice(-1 * e);
}
/*
if (l < e){ if (l < e){
for (let i = l; i < e; i++) { for (let i = l; i < e; i++) {
digits.unshift("~");//0); //Would like to be padding this but ~- doesn't work digits.unshift("~");//0); //Would like to be padding this but ~- doesn't work
@ -4177,9 +4179,12 @@ export const base = (n, b = 10, d=0) => {
console.log("digits", digits); console.log("digits", digits);
} }
*/ */
} }
return sequence(digits); return sequence(digits);
}).squeezeJoin(); })
}).squeezeJoin(); .squeezeJoin();
}).squeezeJoin(); })
.squeezeJoin();
})
.squeezeJoin();
}; };