allow calling all multiple times
This commit is contained in:
parent
8e0f23e081
commit
0003ce174e
1 changed files with 6 additions and 3 deletions
|
|
@ -113,8 +113,9 @@ export function repl({
|
||||||
* all(x => x.pianoroll())
|
* all(x => x.pianoroll())
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
let allTransforms = [];
|
||||||
const all = function (transform) {
|
const all = function (transform) {
|
||||||
allTransform = transform;
|
allTransforms.push(transform);
|
||||||
return silence;
|
return silence;
|
||||||
};
|
};
|
||||||
/** Applies a function to each of the running patterns separately. This is intended for future use with upcoming 'stepwise' features. See `all` for a version that applies the function to all the patterns stacked together into a single pattern.
|
/** Applies a function to each of the running patterns separately. This is intended for future use with upcoming 'stepwise' features. See `all` for a version that applies the function to all the patterns stacked together into a single pattern.
|
||||||
|
|
@ -202,8 +203,10 @@ export function repl({
|
||||||
} else if (eachTransform) {
|
} else if (eachTransform) {
|
||||||
pattern = eachTransform(pattern);
|
pattern = eachTransform(pattern);
|
||||||
}
|
}
|
||||||
if (allTransform) {
|
if (allTransforms.length) {
|
||||||
pattern = allTransform(pattern);
|
for (let i in allTransforms) {
|
||||||
|
pattern = allTransforms[i](pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!isPattern(pattern)) {
|
if (!isPattern(pattern)) {
|
||||||
const message = `got "${typeof evaluated}" instead of pattern`;
|
const message = `got "${typeof evaluated}" instead of pattern`;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue