Merge pull request 'fix stepcat #1396' (#1398) from fix-stepcat into main

Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1398
This commit is contained in:
Alex McLean
2025-06-19 10:15:06 +02:00
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -2720,7 +2720,7 @@ export function stepcat(...timepats) {
if (timepats.length === 0) {
return nothing;
}
const findsteps = (x) => (Array.isArray(x) ? x : [x._steps, x]);
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);
+4
View File
@@ -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', () => {