tests and tweaks, and add chunkBackInto
This commit is contained in:
parent
ff5b11f5ed
commit
f44caf9096
2 changed files with 30 additions and 9 deletions
|
|
@ -2530,7 +2530,21 @@ export const { fastchunk, fastChunk } = register(
|
|||
*/
|
||||
export const { chunkinto, chunkInto } = register(['chunkinto', 'chunkInto'],
|
||||
function (n, func, pat) {
|
||||
return pat.into(fastcat(true, ...Array(n - 1).fill(false)).iterback(n), func);
|
||||
return pat.into(fastcat(true, ...Array(n - 1).fill(false))._iterback(n), func);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like `chunkInto`, but moves backwards through the chunks.
|
||||
* @name chunkBackInto
|
||||
* @synonym chunkbackinto
|
||||
* @memberof Pattern
|
||||
* @example
|
||||
* sound("bd sd ht lt bd - cp lt").chunkInto(4, hurry(2))
|
||||
* .bank("tr909")
|
||||
*/
|
||||
export const { chunkbackinto, chunkBackInto } = register(['chunkbackinto', 'chunkBackInto'],
|
||||
function (n, func, pat) {
|
||||
return pat.into(fastcat(true, ...Array(n - 1).fill(false))._iter(n)._early(1), func);
|
||||
});
|
||||
|
||||
// TODO - redefine elsewhere in terms of mask
|
||||
|
|
|
|||
|
|
@ -1278,7 +1278,7 @@ describe('Pattern', () => {
|
|||
fastcat('a', 'b', 'a', 'b', 'c', 'c', 'd', 'd')
|
||||
)
|
||||
})
|
||||
})
|
||||
});
|
||||
describe('into', () => {
|
||||
it('applies a function to subcycles of a pattern', () => {
|
||||
sameFirst(
|
||||
|
|
@ -1286,12 +1286,19 @@ describe('Pattern', () => {
|
|||
fastcat('a', 'a', 'b', 'b', 'c', 'd', 'c', 'd')
|
||||
)
|
||||
})
|
||||
}),
|
||||
describe('chunkinto', () => {
|
||||
it('chunks into subcycles', () => {
|
||||
sameFirst(fastcat('a', 'b', 'c').chunkInto(3, fast(2)).fast(3),
|
||||
fastcat(fastcat('a', 'a'), 'b', 'c', 'a', fastcat('b', 'b'), 'c', 'a', 'b', fastcat('c', 'c'))
|
||||
)
|
||||
})
|
||||
});
|
||||
describe('chunkinto', () => {
|
||||
it('chunks into subcycles', () => {
|
||||
sameFirst(fastcat('a', 'b', 'c').chunkInto(3, fast(2)).fast(3),
|
||||
fastcat(fastcat('a', 'a'), 'b', 'c', 'a', fastcat('b', 'b'), 'c', 'a', 'b', fastcat('c', 'c'))
|
||||
)
|
||||
})
|
||||
});
|
||||
describe('chunkbackinto', () => {
|
||||
it('chunks into subcycles backwards', () => {
|
||||
sameFirst(fastcat('a', 'b', 'c').chunkBackInto(3, fast(2)).fast(3),
|
||||
fastcat('a', 'b', fastcat('c', 'c'), 'a', fastcat('b', 'b'), 'c', fastcat('a', 'a'), 'b', 'c')
|
||||
)
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue