Compare commits

...

4 Commits

Author SHA1 Message Date
Jade (Rose) Rowland a2c3c35e1e better error 2025-11-30 17:00:47 -05:00
Jade (Rose) Rowland a37db0c5f2 working 2025-11-30 16:57:35 -05:00
Jade (Rose) Rowland d0b5f90de2 format 2025-11-30 16:46:27 -05:00
Jade (Rose) Rowland 5a878b7099 working 2025-11-30 16:44:03 -05:00
+31 -6
View File
@@ -1456,14 +1456,39 @@ export function cat(...pats) {
* @return {Pattern}
* @example
* arrange(
* [4, "<c a f e>(3,8)"],
* [2, "<g a>(5,8)"]
* 4, "<c a f e>(3,8)",
* 2, "<g a>(5,8)"
* ).note()
*/
export function arrange(...sections) {
const total = sections.reduce((sum, [cycles]) => sum + cycles, 0);
sections = sections.map(([cycles, section]) => [cycles, section.fast(cycles)]);
return stepcat(...sections).slow(total);
export function arrange(...input) {
if (Array.isArray(input[0])) {
return arrange_deprecated(...input);
}
if (input.length % 2 !== 0) {
throw new Error('Arrange needs a length paramter for each pattern (length, pattern, length, pattern)');
}
let sects = [];
let total = 0;
for (let i = 0; i < input.length; i += 2) {
let cycles = input.at(i);
total += cycles;
let pattern = input.at(i + 1);
sects.push([cycles, pattern.fast(cycles)]);
}
return stepcat(...sects).slow(total);
}
// handle old array syntax ex:
// arrange(
// [4, "<c a f e>(3,8)"],
// [2, "<g a>(5,8)"]
// ).note()
//
function arrange_deprecated(...sects) {
const total = sects.reduce((sum, [cycles]) => sum + cycles, 0);
sects = sects.map(([cycles, pattern]) => [cycles, pattern.fast(cycles)]);
return stepcat(...sects).slow(total);
}
/**