From 5a878b7099162996f079d3d4d02ddcf7676f8a72 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sun, 30 Nov 2025 16:44:03 -0500 Subject: [PATCH] working --- packages/core/pattern.mjs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index c2e5ca1bc..a9616b8d5 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1456,14 +1456,31 @@ export function cat(...pats) { * @return {Pattern} * @example * arrange( - * [4, "(3,8)"], - * [2, "(5,8)"] + * 4, "(3,8)", + * 2, "(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) { + 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; + } + const total = sects.reduce((sum, [cycles]) => sum + cycles, 0); + sects = sects.map(([cycles, section]) => [cycles, section.fast(cycles)]); + return stepcat(...sects).slow(total); + + + } /** @@ -1858,9 +1875,9 @@ export const { fastGap, fastgap } = register(['fastGap', 'fastgap'], function (f const newWhole = !hap.whole ? undefined : new TimeSpan( - newPart.begin.sub(begin.sub(hap.whole.begin).div(factor)), - newPart.end.add(hap.whole.end.sub(end).div(factor)), - ); + newPart.begin.sub(begin.sub(hap.whole.begin).div(factor)), + newPart.end.add(hap.whole.end.sub(end).div(factor)), + ); return new Hap(newWhole, newPart, hap.value, hap.context); }; return pat.withQuerySpanMaybe(qf).withHap(ef).splitQueries();