Fix for squeezejoin and functions using it, including bite (#1286)

This commit is contained in:
Alex McLean 2025-02-11 09:02:34 +00:00 committed by GitHub
parent 3575fc3cc8
commit 84581b22aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -1820,7 +1820,10 @@ export const { fastGap, fastgap } = register(['fastGap', 'fastgap'], function (f
export const focus = register('focus', function (b, e, pat) { export const focus = register('focus', function (b, e, pat) {
b = Fraction(b); b = Fraction(b);
e = Fraction(e); e = Fraction(e);
return pat._fast(Fraction(1).div(e.sub(b))).late(b.cyclePos()); return pat
._early(b.sam())
._fast(Fraction(1).div(e.sub(b)))
._late(b);
}); });
export const { focusSpan, focusspan } = register(['focusSpan', 'focusspan'], function (span, pat) { export const { focusSpan, focusspan } = register(['focusSpan', 'focusspan'], function (span, pat) {

View File

@ -1265,4 +1265,14 @@ describe('Pattern', () => {
expect(s('bev').chop(8).loopAt(2)._steps).toStrictEqual(Fraction(4)); expect(s('bev').chop(8).loopAt(2)._steps).toStrictEqual(Fraction(4));
}); });
}); });
describe('bite', () => {
it('works with uneven patterns', () => {
sameFirst(
fastcat(slowcat('a', 'b', 'c', 'd', 'e'), slowcat(1, 2, 3, 4, 5))
.bite(2, stepcat(pure(0), pure(1).expand(2)))
.fast(5),
stepcat(slowcat('a', 'b', 'c', 'd', 'e'), slowcat(1, 2, 3, 4, 5).expand(2)).fast(5),
);
});
});
}); });