FIXES: palindrome abc -> abccba (#831)

* FIXES: palindrome abc -> abccba

* FIXES: tests for palindrome

---------

Co-authored-by: Bernhard Wagner <gitcommit@nosuch.biz>
This commit is contained in:
Bernhard Wagner 2023-12-05 11:15:13 +01:00 committed by GitHub
parent b374cdf47c
commit 1bca05e349
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 27 deletions

View file

@ -20,6 +20,7 @@ import {
slowcat,
cat,
sequence,
palindrome,
polymeter,
polymeterSteps,
polyrhythm,
@ -571,6 +572,18 @@ describe('Pattern', () => {
expect(sequence(1, 2, 3).firstCycle()).toStrictEqual(fastcat(1, 2, 3).firstCycle());
});
});
describe('palindrome()', () => {
it('Can create palindrome', () => {
expect(
fastcat('a', 'b', 'c')
.palindrome()
.fast(2)
.firstCycle()
.sort((a, b) => a.part.begin.sub(b.part.begin))
.map((a) => a.value),
).toStrictEqual(['a', 'b', 'c', 'c', 'b', 'a']);
});
});
describe('polyrhythm()', () => {
it('Can layer up cycles', () => {
expect(polyrhythm(['a', 'b'], ['c']).firstCycle()).toStrictEqual(