stackCenter/Centre changes, fix from merge, snapshot

This commit is contained in:
tyow
2026-10-07 16:44:43 -04:00
parent 29a4e30042
commit 5148066b01
3 changed files with 16 additions and 20 deletions
+13 -9
View File
@@ -886,6 +886,10 @@ export class Pattern {
return stackRight(this, ...pats);
}
stackCenter(...pats) {
return stackCenter(this, ...pats);
}
stackCentre(...pats) {
return stackCentre(this, ...pats);
}
@@ -1666,7 +1670,7 @@ function _stackWith(func, pats) {
}
/**
* The input patterns are aligned to the left, with silence padded to the shorter pattern(s) in the final steps if there's a stepcount disparity. See also `stackRight` and `stackCentre/stackCenter`
* The input patterns are aligned to the left, with silence padded to the shorter pattern(s) in the final steps if there's a stepcount disparity. See also `stackRight` and `stackCenter/stackCentre`
*
* @name stackLeft
* @tags temporal, stepwise, combiners
@@ -1685,7 +1689,7 @@ export function stackLeft(...pats) {
}
/**
* The input patterns are aligned to the right, with silence padded to the shorter pattern(s) in the initial steps if there's a stepcount disparity. See also `stackLeft` and `stackCentre/stackCenter`
* The input patterns are aligned to the right, with silence padded to the shorter pattern(s) in the initial steps if there's a stepcount disparity. See also `stackLeft` and `stackCenter/stackCentre`
*
* @name stackRight
* @tags temporal, stepwise, combiners
@@ -1705,17 +1709,17 @@ export function stackRight(...pats) {
/**
* The input patterns are aligned to the right, with silence padded to the shorter pattern(s) in the initial steps if there's a stepcount disparity. See also `stackLeft` and `stackRight`
* @name stackCentre
* @name stackCenter
* @tags temporal, stepwise, combiners
* @synonyms stackCenter
* @synonyms stackCentre
* @return {Pattern}
* @example
* stackCentre("0 1 2 3", "3 4", "[4 5 6] 7 8 9 10").scale("c:minor").note()
* stackCenter("0 1 2 3", "3 4", "[4 5 6] 7 8 9 10").scale("c:minor").note()
* @example
* // chainable
* "0 1 2 3".stackCentre("3 4", "[4 5 6] 7 8 9 10").scale("c:minor").note()
* "0 1 2 3".stackCenter("3 4", "[4 5 6] 7 8 9 10").scale("c:minor").note()
*/
export function stackCentre(...pats) {
export function stackCenter(...pats) {
return _stackWith(
(steps, pats) =>
pats.map((pat) => {
@@ -1729,8 +1733,8 @@ export function stackCentre(...pats) {
);
}
export function stackCenter(pats) {
return stackCentre(pats);
export function stackCentre(...pats) {
return stackCenter(...pats);
}
/**
+1
View File
@@ -6,6 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th
import { Hap } from './hap.mjs';
import { Pattern, fastcat, pure, register, reify, silence, stack, sequenceP, isPattern } from './pattern.mjs';
import { _mod } from './util.mjs';
import Fraction from './fraction.mjs';
import { id, keyAlias, getCurrentKeyboardState } from './util.mjs';
+2 -11
View File
@@ -7908,15 +7908,6 @@ exports[`runs examples > example "midi" example index 0 1`] = `
]
`;
exports[`runs examples > example "midi" example index 1 1`] = `
[
"[ 0/1 → 1/1 | note:c4 midichan:1 ]",
"[ 1/1 → 2/1 | note:c4 midichan:1 ]",
"[ 2/1 → 3/1 | note:c4 midichan:1 ]",
"[ 3/1 → 4/1 | note:c4 midichan:1 ]",
]
`;
exports[`runs examples > example "midibend" example index 0 1`] = `
[
"[ 0/1 → 1/1 | note:c4 midibend:0 ]",
@@ -13144,7 +13135,7 @@ exports[`runs examples > example "stack" example index 1 1`] = `
]
`;
exports[`runs examples > example "stackCentre" example index 0 1`] = `
exports[`runs examples > example "stackCenter" example index 0 1`] = `
[
"[ 0/1 → 1/15 | note:G3 ]",
"[ 1/15 → 2/15 | note:Ab3 ]",
@@ -13201,7 +13192,7 @@ exports[`runs examples > example "stackCentre" example index 0 1`] = `
]
`;
exports[`runs examples > example "stackCentre" example index 1 1`] = `
exports[`runs examples > example "stackCenter" example index 1 1`] = `
[
"[ 0/1 → 1/15 | note:G3 ]",
"[ 1/15 → 2/15 | note:Ab3 ]",