From 95193b0bfd4b4e2c2e0c6ef216b4331e2f037cf4 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 19 Jun 2025 08:18:20 +0100 Subject: [PATCH 1/4] a test for #1396 --- packages/core/test/pattern.test.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/test/pattern.test.mjs b/packages/core/test/pattern.test.mjs index 45a1e2a98..b93d80f25 100644 --- a/packages/core/test/pattern.test.mjs +++ b/packages/core/test/pattern.test.mjs @@ -52,6 +52,7 @@ import { stackCentre, stepcat, sometimes, + expand } from '../index.mjs'; import { steady } from '../signal.mjs'; @@ -1179,6 +1180,9 @@ describe('Pattern', () => { it('calculates undefined steps as the average', () => { expect(sameFirst(stepcat(pure(1), pure(2), pure(3).setSteps(undefined)), fastcat(1, 2, 3))); }); + it('works with auto-reified values', () => { + expect(sameFirst(stepcat(expand(3, 'bd'), 'rim'), stepcat(expand(3, 'bd'), pure('rim')))) + }); }); describe('shrink', () => { it('can shrink', () => { From 440f1cb081c0947ba3ba8b00b33f4dcc74bafe98 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 19 Jun 2025 08:27:23 +0100 Subject: [PATCH 2/4] reify arguments of stepcat --- packages/core/pattern.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 76b02c21e..59833aea7 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2720,6 +2720,7 @@ export function stepcat(...timepats) { return nothing; } const findsteps = (x) => (Array.isArray(x) ? x : [x._steps, x]); + timepats = timepats.map(reify); timepats = timepats.map(findsteps); if (timepats.find((x) => x[0] === undefined)) { const times = timepats.map((a) => a[0]).filter((x) => x !== undefined); From a1d181d6097057542ca7dd943a2a8105330f52d5 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 19 Jun 2025 08:27:41 +0100 Subject: [PATCH 3/4] format --- packages/core/test/pattern.test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/test/pattern.test.mjs b/packages/core/test/pattern.test.mjs index b93d80f25..07bdcdda7 100644 --- a/packages/core/test/pattern.test.mjs +++ b/packages/core/test/pattern.test.mjs @@ -52,7 +52,7 @@ import { stackCentre, stepcat, sometimes, - expand + expand, } from '../index.mjs'; import { steady } from '../signal.mjs'; @@ -1181,7 +1181,7 @@ describe('Pattern', () => { expect(sameFirst(stepcat(pure(1), pure(2), pure(3).setSteps(undefined)), fastcat(1, 2, 3))); }); it('works with auto-reified values', () => { - expect(sameFirst(stepcat(expand(3, 'bd'), 'rim'), stepcat(expand(3, 'bd'), pure('rim')))) + expect(sameFirst(stepcat(expand(3, 'bd'), 'rim'), stepcat(expand(3, 'bd'), pure('rim')))); }); }); describe('shrink', () => { From c01b4c651c54603fd295fc4750e77d9858123b1e Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 19 Jun 2025 09:06:53 +0100 Subject: [PATCH 4/4] don't trash lists passed to timecat --- packages/core/pattern.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 59833aea7..6441b7568 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2719,8 +2719,7 @@ export function stepcat(...timepats) { if (timepats.length === 0) { return nothing; } - const findsteps = (x) => (Array.isArray(x) ? x : [x._steps, x]); - timepats = timepats.map(reify); + const findsteps = (x) => (Array.isArray(x) ? x : [x._steps ?? 1, x]); timepats = timepats.map(findsteps); if (timepats.find((x) => x[0] === undefined)) { const times = timepats.map((a) => a[0]).filter((x) => x !== undefined);