diff --git a/docs/_snowpack/link/strudel.js b/docs/_snowpack/link/strudel.js index 62c75709..47d7536e 100644 --- a/docs/_snowpack/link/strudel.js +++ b/docs/_snowpack/link/strudel.js @@ -338,7 +338,7 @@ class Pattern { } every(n, func) { var pats = Array(n - 1).fill(this); - pats.unshift(this); + pats.unshift(func(this)); return slowcat(...pats); } append(other) { diff --git a/strudel.mjs b/strudel.mjs index 36684df9..0b16e35d 100644 --- a/strudel.mjs +++ b/strudel.mjs @@ -484,7 +484,7 @@ class Pattern { every(n, func) { var pats = Array(n-1).fill(this) - pats.unshift(this) + pats.unshift(func(this)) return slowcat(...pats) } diff --git a/test/pattern.test.mjs b/test/pattern.test.mjs index c9fb8e0b..6a0c4fa2 100644 --- a/test/pattern.test.mjs +++ b/test/pattern.test.mjs @@ -163,12 +163,12 @@ describe('Pattern', function() { // ) // }) // }) - // describe('every()', () => { - // it('Can apply a function every 3rd time', () => { - // assert.deepStrictEqual( - // pure("a").every(3, x => x._fast(2)._fast(3)).firstCycle, - // sequence(sequence("a", "a"), "a", "a").firstCycle - // ) - // }) - // }) + describe('every()', () => { + it('Can apply a function every 3rd time', () => { + assert.deepStrictEqual( + pure("a").every(3, x => x._fast(2))._fast(3).firstCycle, + sequence(sequence("a", "a"), "a", "a").firstCycle + ) + }) + }) })