fix notes inside object

This commit is contained in:
Felix Roos
2022-04-13 19:19:30 +02:00
parent c0f006eef1
commit 727fc2c049
2 changed files with 5 additions and 1 deletions
+3
View File
@@ -114,6 +114,9 @@ describe('dirtify', () => {
assert.deepStrictEqual(dirtify({ n: 7 }), { n: 7 });
assert.deepStrictEqual(dirtify({ n: 7, room: 0.5 }), { n: 7, room: 0.5 });
});
it('should parse notes inside object', () => {
assert.deepStrictEqual(dirtify({ n: 'c3', s: 'supersaw' }), { n: -12, s: 'supersaw' });
});
it('should dirtify .value', () => {
assert.deepStrictEqual(dirtify({ value: 61 }), { n: 1 });
assert.deepStrictEqual(dirtify({ value: 'c5' }), { n: 12 });
+2 -1
View File
@@ -96,8 +96,9 @@ export function objectify(value) {
// turns value into object that is the right format superdirt osc
export function dirtify(val) {
const obj = objectify(val);
if (obj.n && typeof obj.n === 'string') {
return { ...obj, ...objectify(obj.n) };
return { ...obj, ...dirtify(obj.n) };
}
const { value, ...rest } = obj;
if (typeof value === 'undefined') {