From 5fbd1453b4e06ce0dd4579605ba0ceb777eed62a Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 9 Dec 2022 10:40:31 +0100 Subject: [PATCH] can now add bare numbers to numeral object props --- packages/core/value.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/core/value.mjs b/packages/core/value.mjs index 7eb89013..49f66bd1 100644 --- a/packages/core/value.mjs +++ b/packages/core/value.mjs @@ -7,6 +7,12 @@ This program is free software: you can redistribute it and/or modify it under th import { curry } from './util.mjs'; export function unionWithObj(a, b, func) { + if (typeof b?.value === 'number') { + // https://github.com/tidalcycles/strudel/issues/262 + const numKeys = Object.keys(a).filter((k) => typeof a[k] === 'number'); + const numerals = Object.fromEntries(numKeys.map((k) => [k, b.value])); + b = Object.assign(b, numerals); + } const common = Object.keys(a).filter((k) => Object.keys(b).includes(k)); return Object.assign({}, a, b, Object.fromEntries(common.map((k) => [k, func(a[k], b[k])]))); }