pass all the args through patternify, to properly support sequences as args

This commit is contained in:
alex 2022-02-08 16:15:43 +00:00
parent 89ee94e953
commit d6c22d516b
2 changed files with 14 additions and 8 deletions

View File

@ -431,16 +431,16 @@ class Pattern {
return fastQuery.withEventTime(t => t.div(factor)) return fastQuery.withEventTime(t => t.div(factor))
} }
fast(factor) { fast(...factor) {
return this._patternify(Pattern.prototype._fast)(factor) return this._patternify(Pattern.prototype._fast)(...factor)
} }
_slow(factor) { _slow(factor) {
return this._fast(1/factor) return this._fast(1/factor)
} }
slow(factor) { slow(...factor) {
return this._patternify(Pattern.prototype._slow)(factor) return this._patternify(Pattern.prototype._slow)(...factor)
} }
_early(offset) { _early(offset) {
@ -449,8 +449,8 @@ class Pattern {
return this.withQueryTime(t => t.add(offset)).withEventTime(t => t.sub(offset)) return this.withQueryTime(t => t.add(offset)).withEventTime(t => t.sub(offset))
} }
early(factor) { early(...factor) {
return this._patternify(Pattern.prototype._early)(factor) return this._patternify(Pattern.prototype._early)(...factor)
} }
_late(offset) { _late(offset) {
@ -459,8 +459,8 @@ class Pattern {
} }
late(factor) { late(...factor) {
return this._patternify(Pattern.prototype._late)(factor) return this._patternify(Pattern.prototype._late)(...factor)
} }
when(binary_pat, func) { when(binary_pat, func) {

View File

@ -98,6 +98,12 @@ describe('Pattern', function() {
// .fast(sequence(1,silence) is a quick hack to cut an event in two.. // .fast(sequence(1,silence) is a quick hack to cut an event in two..
assert.deepStrictEqual(pure("a").fast(sequence(1,4)).firstCycle, stack(pure("a").fast(sequence(1,silence)), sequence(silence, ["a","a"])).firstCycle) assert.deepStrictEqual(pure("a").fast(sequence(1,4)).firstCycle, stack(pure("a").fast(sequence(1,silence)), sequence(silence, ["a","a"])).firstCycle)
}) })
it('defaults to accepting sequences', function () {
assert.deepStrictEqual(
sequence(1,2,3).fast(sequence(1.5,2)).firstCycle,
sequence(1,2,3).fast(1.5,2).firstCycle
)
})
}) })
describe('_slow()', function () { describe('_slow()', function () {
it('Makes things slower', function () { it('Makes things slower', function () {