mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
remove dangerous arithmetic feature
This commit is contained in:
parent
9c66d9f1a7
commit
12d8cdff92
@ -22,8 +22,4 @@ describe('Value', () => {
|
|||||||
expect(valued(mul).ap(3).ap(3).value).toEqual(9);
|
expect(valued(mul).ap(3).ap(3).value).toEqual(9);
|
||||||
expect(valued(3).mul(3).value).toEqual(9);
|
expect(valued(3).mul(3).value).toEqual(9);
|
||||||
});
|
});
|
||||||
it('union bare numbers for numeral props', () => {
|
|
||||||
expect(n(3).cutoff(500).add(10).firstCycleValues).toEqual([{ n: 13, cutoff: 510 }]);
|
|
||||||
expect(n(3).cutoff(500).mul(2).firstCycleValues).toEqual([{ n: 6, cutoff: 1000 }]);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,14 +5,13 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { curry } from './util.mjs';
|
import { curry } from './util.mjs';
|
||||||
|
import { logger } from './logger.mjs';
|
||||||
|
|
||||||
export function unionWithObj(a, b, func) {
|
export function unionWithObj(a, b, func) {
|
||||||
if (typeof b?.value === 'number') {
|
if (b?.value !== undefined && Object.keys(b).length === 1) {
|
||||||
// https://github.com/tidalcycles/strudel/issues/262
|
// https://github.com/tidalcycles/strudel/issues/1026
|
||||||
const numKeys = Object.keys(a).filter((k) => typeof a[k] === 'number');
|
logger(`[warn]: dangerous arithmetic`);
|
||||||
const numerals = Object.fromEntries(numKeys.map((k) => [k, b.value]));
|
return a;
|
||||||
b = Object.assign(b, numerals);
|
|
||||||
delete b.value;
|
|
||||||
}
|
}
|
||||||
const common = Object.keys(a).filter((k) => Object.keys(b).includes(k));
|
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])])));
|
return Object.assign({}, a, b, Object.fromEntries(common.map((k) => [k, func(a[k], b[k])])));
|
||||||
|
|||||||
@ -361,8 +361,8 @@ export const echoPiano = `// "Echo piano"
|
|||||||
// @by Felix Roos
|
// @by Felix Roos
|
||||||
|
|
||||||
n("<0 2 [4 6](3,4,2) 3*2>").color('salmon')
|
n("<0 2 [4 6](3,4,2) 3*2>").color('salmon')
|
||||||
.off(1/4, x=>x.add(2).color('green'))
|
.off(1/4, x=>x.add(n(2)).color('green'))
|
||||||
.off(1/2, x=>x.add(6).color('steelblue'))
|
.off(1/2, x=>x.add(n(6)).color('steelblue'))
|
||||||
.scale('D minor')
|
.scale('D minor')
|
||||||
.echo(4, 1/8, .5)
|
.echo(4, 1/8, .5)
|
||||||
.clip(.5)
|
.clip(.5)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user