diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index bf2dcd1d..6a33b133 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -809,15 +809,6 @@ export class Pattern { ////////////////////////////////////////////////////////////////////// // Multi-pattern functions - /** - * Stacks the given pattern(s) to the current pattern. - * @name stack - * @memberof Pattern - * @example - * s("hh*4").stack( - * note("c4(5,8)") - * ) - */ stack(...pats) { return stack(this, ...pats); } @@ -1254,11 +1245,18 @@ export function reify(thing) { /** The given items are played at the same time at the same length. * + * @name stack * @return {Pattern} * @synonyms polyrhythm, pr * @example * stack("g3", "b3", ["e4", "d4"]).note() * // "g3,b3,[e4,d4]".note() + * + * @example + * // As a chained function: + * s("hh*4").stack( + * note("c4(5,8)") + * ) */ export function stack(...pats) { // Array test here is to avoid infinite recursions.. @@ -1380,14 +1378,16 @@ export function slowcatPrime(...pats) { /** The given items are con**cat**enated, where each one takes one cycle. * + * @name cat * @param {...any} items - The items to concatenate * @synonyms slowcat * @return {Pattern} * @example * cat("e5", "b4", ["d5", "c5"]).note() * // "".note() + * * @example - * // You can also use cat as a chained function like this: + * // As a chained function: * s("hh*4").cat( * note("c4(5,8)") * ) @@ -1468,7 +1468,8 @@ export function sequence(...pats) { * seq("e5", "b4", ["d5", "c5"]).note() * // "e5 b4 [d5 c5]".note() * - * // Or as a chained function: + * @example + * // As a chained function: * s("hh*4").seq( * note("c4(5,8)") * ) diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index d0e68d9e..a3419e98 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -6976,6 +6976,27 @@ exports[`runs examples > example "segment" example index 0 1`] = ` `; exports[`runs examples > example "seq" example index 0 1`] = ` +[ + "[ 0/1 → 1/3 | note:e5 ]", + "[ 1/3 → 2/3 | note:b4 ]", + "[ 2/3 → 5/6 | note:d5 ]", + "[ 5/6 → 1/1 | note:c5 ]", + "[ 1/1 → 4/3 | note:e5 ]", + "[ 4/3 → 5/3 | note:b4 ]", + "[ 5/3 → 11/6 | note:d5 ]", + "[ 11/6 → 2/1 | note:c5 ]", + "[ 2/1 → 7/3 | note:e5 ]", + "[ 7/3 → 8/3 | note:b4 ]", + "[ 8/3 → 17/6 | note:d5 ]", + "[ 17/6 → 3/1 | note:c5 ]", + "[ 3/1 → 10/3 | note:e5 ]", + "[ 10/3 → 11/3 | note:b4 ]", + "[ 11/3 → 23/6 | note:d5 ]", + "[ 23/6 → 4/1 | note:c5 ]", +] +`; + +exports[`runs examples > example "seq" example index 1 1`] = ` [ "[ 0/1 → 1/8 | s:hh ]", "[ 1/8 → 1/4 | s:hh ]", @@ -7709,6 +7730,27 @@ exports[`runs examples > example "squiz" example index 0 1`] = ` `; exports[`runs examples > example "stack" example index 0 1`] = ` +[ + "[ 0/1 → 1/2 | note:e4 ]", + "[ 0/1 → 1/1 | note:g3 ]", + "[ 0/1 → 1/1 | note:b3 ]", + "[ 1/2 → 1/1 | note:d4 ]", + "[ 1/1 → 3/2 | note:e4 ]", + "[ 1/1 → 2/1 | note:g3 ]", + "[ 1/1 → 2/1 | note:b3 ]", + "[ 3/2 → 2/1 | note:d4 ]", + "[ 2/1 → 5/2 | note:e4 ]", + "[ 2/1 → 3/1 | note:g3 ]", + "[ 2/1 → 3/1 | note:b3 ]", + "[ 5/2 → 3/1 | note:d4 ]", + "[ 3/1 → 7/2 | note:e4 ]", + "[ 3/1 → 4/1 | note:g3 ]", + "[ 3/1 → 4/1 | note:b3 ]", + "[ 7/2 → 4/1 | note:d4 ]", +] +`; + +exports[`runs examples > example "stack" example index 1 1`] = ` [ "[ 0/1 → 1/8 | note:c4 ]", "[ 0/1 → 1/4 | s:hh ]", @@ -7749,27 +7791,6 @@ exports[`runs examples > example "stack" example index 0 1`] = ` ] `; -exports[`runs examples > example "stack" example index 0 2`] = ` -[ - "[ 0/1 → 1/2 | note:e4 ]", - "[ 0/1 → 1/1 | note:g3 ]", - "[ 0/1 → 1/1 | note:b3 ]", - "[ 1/2 → 1/1 | note:d4 ]", - "[ 1/1 → 3/2 | note:e4 ]", - "[ 1/1 → 2/1 | note:g3 ]", - "[ 1/1 → 2/1 | note:b3 ]", - "[ 3/2 → 2/1 | note:d4 ]", - "[ 2/1 → 5/2 | note:e4 ]", - "[ 2/1 → 3/1 | note:g3 ]", - "[ 2/1 → 3/1 | note:b3 ]", - "[ 5/2 → 3/1 | note:d4 ]", - "[ 3/1 → 7/2 | note:e4 ]", - "[ 3/1 → 4/1 | note:g3 ]", - "[ 3/1 → 4/1 | note:b3 ]", - "[ 7/2 → 4/1 | note:d4 ]", -] -`; - exports[`runs examples > example "steps" example index 0 1`] = ` [ "[ 0/1 → 1/4 | s:bd ]",