mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
parent
6350cfdb9c
commit
283a071c86
@ -119,10 +119,10 @@ export const lcm = (...fractions) => {
|
|||||||
if (fractions.length === 0) {
|
if (fractions.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
const x = fractions.pop();
|
||||||
return fractions.reduce(
|
return fractions.reduce(
|
||||||
(lcm, fraction) => (lcm === undefined || fraction === undefined ? undefined : lcm.lcm(fraction)),
|
(lcm, fraction) => (lcm === undefined || fraction === undefined ? undefined : lcm.lcm(fraction)),
|
||||||
fraction(1),
|
x,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1209,4 +1209,40 @@ describe('Pattern', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('s_expand', () => {
|
||||||
|
it('can expand four things in half', () => {
|
||||||
|
expect(
|
||||||
|
sameFirst(
|
||||||
|
sequence(0, 1, 2, 3).s_expand(1, 0.5),
|
||||||
|
s_cat(sequence(0, 1, 2, 3), sequence(0, 1, 2, 3).s_expand(0.5)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('can expand five things in half', () => {
|
||||||
|
expect(
|
||||||
|
sameFirst(
|
||||||
|
sequence(0, 1, 2, 3, 4).s_expand(1, 0.5),
|
||||||
|
s_cat(sequence(0, 1, 2, 3, 4), sequence(0, 1, 2, 3, 4).s_expand(0.5)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('stepJoin', () => {
|
||||||
|
it('can join a pattern with a tactus of 2', () => {
|
||||||
|
expect(
|
||||||
|
sameFirst(
|
||||||
|
sequence(pure(pure('a')), pure(pure('b').setTactus(2))).stepJoin(),
|
||||||
|
s_cat(pure('a'), pure('b').setTactus(2)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('can join a pattern with a tactus of 0.5', () => {
|
||||||
|
expect(
|
||||||
|
sameFirst(
|
||||||
|
sequence(pure(pure('a')), pure(pure('b').setTactus(0.5))).stepJoin(),
|
||||||
|
s_cat(pure('a'), pure('b').setTactus(0.5)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user