From a37db0c5f230502011b9f65364ecbfd07f2597d7 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sun, 30 Nov 2025 16:57:35 -0500 Subject: [PATCH] working --- packages/core/pattern.mjs | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index e4fc91c88..a3102b34d 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1461,22 +1461,33 @@ export function cat(...pats) { * ).note() */ export function arrange(...input) { - let sects = []; - if (!Array.isArray(input[0])) { - if (input.length % 2 !== 0) { - throw new Error('Arrange needs a length paramter and a pattern'); - } - for (let i = 0; i < input.length; i += 2) { - let cycles = input.at(i); - let pattern = input.at(i + 1); - sects.push([cycles, pattern]); - } - } else { - // Handle deprecated arrange input - sects = input; + if (Array.isArray(input[0])) { + return arrange_deprecated(...input); } + + if (input.length % 2 !== 0) { + throw new Error('Arrange needs a length paramter and a 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, "(3,8)"], +// [2, "(5,8)"] +// ).note() +// +function arrange_deprecated(...sects) { const total = sects.reduce((sum, [cycles]) => sum + cycles, 0); - sects = sects.map(([cycles, section]) => [cycles, section.fast(cycles)]); + sects = sects.map(([cycles, pattern]) => [cycles, pattern.fast(cycles)]); return stepcat(...sects).slow(total); }