actually apply the function in every

This commit is contained in:
alex 2022-02-07 19:00:43 +00:00
parent e12bcea613
commit d3f4dcacff
3 changed files with 10 additions and 10 deletions

View File

@ -338,7 +338,7 @@ class Pattern {
} }
every(n, func) { every(n, func) {
var pats = Array(n - 1).fill(this); var pats = Array(n - 1).fill(this);
pats.unshift(this); pats.unshift(func(this));
return slowcat(...pats); return slowcat(...pats);
} }
append(other) { append(other) {

View File

@ -484,7 +484,7 @@ class Pattern {
every(n, func) { every(n, func) {
var pats = Array(n-1).fill(this) var pats = Array(n-1).fill(this)
pats.unshift(this) pats.unshift(func(this))
return slowcat(...pats) return slowcat(...pats)
} }

View File

@ -163,12 +163,12 @@ describe('Pattern', function() {
// ) // )
// }) // })
// }) // })
// describe('every()', () => { describe('every()', () => {
// it('Can apply a function every 3rd time', () => { it('Can apply a function every 3rd time', () => {
// assert.deepStrictEqual( assert.deepStrictEqual(
// pure("a").every(3, x => x._fast(2)._fast(3)).firstCycle, pure("a").every(3, x => x._fast(2))._fast(3).firstCycle,
// sequence(sequence("a", "a"), "a", "a").firstCycle sequence(sequence("a", "a"), "a", "a").firstCycle
// ) )
// }) })
// }) })
}) })