From 25f762c393b0d6320a64838daeeb5e4251c26d23 Mon Sep 17 00:00:00 2001 From: kdiab Date: Fri, 20 Sep 2024 23:38:21 -0400 Subject: [PATCH 1/5] remove redundant example for cat, update snapshot --- packages/core/pattern.mjs | 11 ----------- test/__snapshots__/examples.test.mjs.snap | 23 ----------------------- 2 files changed, 34 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index b94198f3..f08520cb 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -839,17 +839,6 @@ export class Pattern { seq(...pats) { return sequence(this, ...pats); } - - /** - * Appends the given pattern(s) to the next cycle. - * @name cat - * @memberof Pattern - * @synonyms slowcat - * @example - * s("hh*4").cat( - * note("c4(5,8)") - * ) - */ cat(...pats) { return cat(this, ...pats); } diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index a74987d9..55c6b2cb 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -1379,29 +1379,6 @@ exports[`runs examples > example "brandBy" example index 0 1`] = ` `; exports[`runs examples > example "cat" example index 0 1`] = ` -[ - "[ 0/1 → 1/4 | s:hh ]", - "[ 1/4 → 1/2 | s:hh ]", - "[ 1/2 → 3/4 | s:hh ]", - "[ 3/4 → 1/1 | s:hh ]", - "[ 1/1 → 9/8 | note:c4 ]", - "[ 5/4 → 11/8 | note:c4 ]", - "[ 11/8 → 3/2 | note:c4 ]", - "[ 13/8 → 7/4 | note:c4 ]", - "[ 7/4 → 15/8 | note:c4 ]", - "[ 2/1 → 9/4 | s:hh ]", - "[ 9/4 → 5/2 | s:hh ]", - "[ 5/2 → 11/4 | s:hh ]", - "[ 11/4 → 3/1 | s:hh ]", - "[ 3/1 → 25/8 | note:c4 ]", - "[ 13/4 → 27/8 | note:c4 ]", - "[ 27/8 → 7/2 | note:c4 ]", - "[ 29/8 → 15/4 | note:c4 ]", - "[ 15/4 → 31/8 | note:c4 ]", -] -`; - -exports[`runs examples > example "cat" example index 0 2`] = ` [ "[ 0/1 → 1/1 | note:e5 ]", "[ 1/1 → 2/1 | note:b4 ]", From c225b4719fefd572f6b92da769abfdf4829bd975 Mon Sep 17 00:00:00 2001 From: kdiab Date: Sat, 21 Sep 2024 11:01:00 -0400 Subject: [PATCH 2/5] Combine examples for cat --- packages/core/pattern.mjs | 6 +++++- test/__snapshots__/examples.test.mjs.snap | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index f08520cb..c1b39820 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1396,7 +1396,11 @@ export function slowcatPrime(...pats) { * @example * cat("e5", "b4", ["d5", "c5"]).note() * // "".note() - * + * @example + * // You can also use cat as a chained function like this: + * s("hh*4").cat( + * note("c4(5,8)") + * ) */ export function cat(...pats) { return slowcat(...pats); diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 55c6b2cb..f4e6f56e 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -1388,6 +1388,29 @@ exports[`runs examples > example "cat" example index 0 1`] = ` ] `; +exports[`runs examples > example "cat" example index 1 1`] = ` +[ + "[ 0/1 → 1/4 | s:hh ]", + "[ 1/4 → 1/2 | s:hh ]", + "[ 1/2 → 3/4 | s:hh ]", + "[ 3/4 → 1/1 | s:hh ]", + "[ 1/1 → 9/8 | note:c4 ]", + "[ 5/4 → 11/8 | note:c4 ]", + "[ 11/8 → 3/2 | note:c4 ]", + "[ 13/8 → 7/4 | note:c4 ]", + "[ 7/4 → 15/8 | note:c4 ]", + "[ 2/1 → 9/4 | s:hh ]", + "[ 9/4 → 5/2 | s:hh ]", + "[ 5/2 → 11/4 | s:hh ]", + "[ 11/4 → 3/1 | s:hh ]", + "[ 3/1 → 25/8 | note:c4 ]", + "[ 13/4 → 27/8 | note:c4 ]", + "[ 27/8 → 7/2 | note:c4 ]", + "[ 29/8 → 15/4 | note:c4 ]", + "[ 15/4 → 31/8 | note:c4 ]", +] +`; + exports[`runs examples > example "ceil" example index 0 1`] = ` [ "[ 0/1 → 1/4 | note:42 ]", From 717e4a2c1dd1b0c6b69dd1648022c904f303947d Mon Sep 17 00:00:00 2001 From: kdiab Date: Sun, 22 Sep 2024 10:31:50 -0400 Subject: [PATCH 3/5] Combine examples for seq and remove extra entry --- packages/core/pattern.mjs | 19 ++++++++----------- test/__snapshots__/examples.test.mjs.snap | 21 --------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index c1b39820..bf2dcd1d 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -826,16 +826,6 @@ export class Pattern { return sequence(this, ...pats); } - /** - * Appends the given pattern(s) to the current pattern. - * @name seq - * @memberof Pattern - * @synonyms sequence, fastcat - * @example - * s("hh*4").seq( - * note("c4(5,8)") - * ) - */ seq(...pats) { return sequence(this, ...pats); } @@ -1471,12 +1461,19 @@ export function sequence(...pats) { } /** Like **cat**, but the items are crammed into one cycle. - * @synonyms fastcat, sequence + * @name seq + * @memberof Pattern + * @synonyms sequence, fastcat * @example * seq("e5", "b4", ["d5", "c5"]).note() * // "e5 b4 [d5 c5]".note() * + * // Or as a chained function: + * s("hh*4").seq( + * note("c4(5,8)") + * ) */ + export function seq(...pats) { return fastcat(...pats); } diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index f4e6f56e..d0e68d9e 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -7016,27 +7016,6 @@ exports[`runs examples > example "seq" example index 0 1`] = ` ] `; -exports[`runs examples > example "seq" example index 0 2`] = ` -[ - "[ 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 "seqPLoop" example index 0 1`] = ` [ "[ 0/1 → 1/8 | s:bd ]", From 2c16a37a68b1a089c7ce11d8f9d509cf711dbab5 Mon Sep 17 00:00:00 2001 From: kdiab Date: Sun, 22 Sep 2024 10:42:46 -0400 Subject: [PATCH 4/5] Combine examples for stack, match wording for cat, stack and seq --- packages/core/pattern.mjs | 23 +++++---- test/__snapshots__/examples.test.mjs.snap | 63 +++++++++++++++-------- 2 files changed, 54 insertions(+), 32 deletions(-) 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 ]", From e9e7e0254731db81d71667ec7bd30de9a0c41837 Mon Sep 17 00:00:00 2001 From: Khalid Date: Thu, 26 Sep 2024 17:58:59 -0400 Subject: [PATCH 5/5] Fixed access to merged description in factories.mdx --- packages/core/pattern.mjs | 4 ---- website/src/pages/learn/factories.mdx | 12 ------------ 2 files changed, 16 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 6a33b133..fec26804 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1245,7 +1245,6 @@ 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 @@ -1378,7 +1377,6 @@ 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} @@ -1461,8 +1459,6 @@ export function sequence(...pats) { } /** Like **cat**, but the items are crammed into one cycle. - * @name seq - * @memberof Pattern * @synonyms sequence, fastcat * @example * seq("e5", "b4", ["d5", "c5"]).note() diff --git a/website/src/pages/learn/factories.mdx b/website/src/pages/learn/factories.mdx index a823bfed..6a2e165b 100644 --- a/website/src/pages/learn/factories.mdx +++ b/website/src/pages/learn/factories.mdx @@ -25,26 +25,14 @@ These are the equivalents used by the Mini Notation: -You can also use cat as a chained function like this: - - - ## seq -Or as a chained function: - - - ## stack -As a chained function: - - - ## s_cat