Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit b192c68

Browse files
authored
Merge pull request #1312 from daslyfe/jade/bug/as_single_param
bugfix: Allow single param to be used in the as function
2 parents f652c2c + dccfefa commit b192c68

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

packages/core/controls.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,11 +1766,14 @@ export const getControlName = (alias) => {
17661766
* Sets properties in a batch.
17671767
*
17681768
* @name as
1769-
* @param {Array} mapping the control names that are set
1769+
* @param {String | Array} mapping the control names that are set
17701770
* @example
17711771
* "c:.5 a:1 f:.25 e:.8".as("note:clip")
1772+
* @example
1773+
* "{0@2 0.25 0 0.5 .3 .5}%8".as("begin").s("sax_vib").clip(1)
17721774
*/
17731775
export const as = register('as', (mapping, pat) => {
1776+
mapping = Array.isArray(mapping) ? mapping : [mapping];
17741777
return pat.fmap((v) => {
17751778
v = Array.isArray(v) ? v : [v];
17761779
v = Object.fromEntries(mapping.map((prop, i) => [getControlName(prop), v[i]]));

test/__snapshots__/examples.test.mjs.snap

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,39 @@ exports[`runs examples > example "as" example index 0 1`] = `
933933
]
934934
`;
935935

936+
exports[`runs examples > example "as" example index 1 1`] = `
937+
[
938+
"[ 0/1 → 1/4 | begin:0 s:sax_vib clip:1 ]",
939+
"[ 1/4 → 3/8 | begin:0.25 s:sax_vib clip:1 ]",
940+
"[ 3/8 → 1/2 | begin:0 s:sax_vib clip:1 ]",
941+
"[ 1/2 → 5/8 | begin:0.5 s:sax_vib clip:1 ]",
942+
"[ 5/8 → 3/4 | begin:0.3 s:sax_vib clip:1 ]",
943+
"[ 3/4 → 7/8 | begin:0.5 s:sax_vib clip:1 ]",
944+
"[ (7/8 → 1/1) ⇝ 9/8 | begin:0 s:sax_vib clip:1 ]",
945+
"[ 7/8 ⇜ (1/1 → 9/8) | begin:0 s:sax_vib clip:1 ]",
946+
"[ 9/8 → 5/4 | begin:0.25 s:sax_vib clip:1 ]",
947+
"[ 5/4 → 11/8 | begin:0 s:sax_vib clip:1 ]",
948+
"[ 11/8 → 3/2 | begin:0.5 s:sax_vib clip:1 ]",
949+
"[ 3/2 → 13/8 | begin:0.3 s:sax_vib clip:1 ]",
950+
"[ 13/8 → 7/4 | begin:0.5 s:sax_vib clip:1 ]",
951+
"[ 7/4 → 2/1 | begin:0 s:sax_vib clip:1 ]",
952+
"[ 2/1 → 17/8 | begin:0.25 s:sax_vib clip:1 ]",
953+
"[ 17/8 → 9/4 | begin:0 s:sax_vib clip:1 ]",
954+
"[ 9/4 → 19/8 | begin:0.5 s:sax_vib clip:1 ]",
955+
"[ 19/8 → 5/2 | begin:0.3 s:sax_vib clip:1 ]",
956+
"[ 5/2 → 21/8 | begin:0.5 s:sax_vib clip:1 ]",
957+
"[ 21/8 → 23/8 | begin:0 s:sax_vib clip:1 ]",
958+
"[ 23/8 → 3/1 | begin:0.25 s:sax_vib clip:1 ]",
959+
"[ 3/1 → 25/8 | begin:0 s:sax_vib clip:1 ]",
960+
"[ 25/8 → 13/4 | begin:0.5 s:sax_vib clip:1 ]",
961+
"[ 13/4 → 27/8 | begin:0.3 s:sax_vib clip:1 ]",
962+
"[ 27/8 → 7/2 | begin:0.5 s:sax_vib clip:1 ]",
963+
"[ 7/2 → 15/4 | begin:0 s:sax_vib clip:1 ]",
964+
"[ 15/4 → 31/8 | begin:0.25 s:sax_vib clip:1 ]",
965+
"[ 31/8 → 4/1 | begin:0 s:sax_vib clip:1 ]",
966+
]
967+
`;
968+
936969
exports[`runs examples > example "attack" example index 0 1`] = `
937970
[
938971
"[ 0/1 → 1/4 | note:c3 attack:0 ]",

0 commit comments

Comments
 (0)