Merge pull request #1312 from daslyfe/jade/bug/as_single_param

bugfix: Allow single param to be used in the as function
This commit is contained in:
Felix Roos 2025-03-23 20:05:31 +01:00 committed by GitHub
commit b192c6823c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 1 deletions

View file

@ -1766,11 +1766,14 @@ export const getControlName = (alias) => {
* Sets properties in a batch.
*
* @name as
* @param {Array} mapping the control names that are set
* @param {String | Array} mapping the control names that are set
* @example
* "c:.5 a:1 f:.25 e:.8".as("note:clip")
* @example
* "{0@2 0.25 0 0.5 .3 .5}%8".as("begin").s("sax_vib").clip(1)
*/
export const as = register('as', (mapping, pat) => {
mapping = Array.isArray(mapping) ? mapping : [mapping];
return pat.fmap((v) => {
v = Array.isArray(v) ? v : [v];
v = Object.fromEntries(mapping.map((prop, i) => [getControlName(prop), v[i]]));