mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-15 16:17:58 +00:00
don't merge object when the type is AudioParam, AudioNode or AudioBuffer
addresses standardized-audio-context/#642
This commit is contained in:
parent
560ac489af
commit
94a9f78704
1 changed files with 9 additions and 4 deletions
|
@ -1,8 +1,15 @@
|
|||
import { RecursivePartial } from "./Interface";
|
||||
import { isAudioBuffer, isAudioNode, isAudioParam } from "./AdvancedTypeCheck";
|
||||
import { isDefined, isObject, isUndef } from "./TypeCheck";
|
||||
|
||||
type BaseToneOptions = import("../Tone").BaseToneOptions;
|
||||
|
||||
/**
|
||||
* Some objects should not be merged
|
||||
*/
|
||||
function noCopy(key: string, arg: any): boolean {
|
||||
return key === "value" || isAudioParam(arg) || isAudioNode(arg) || isAudioBuffer(arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively merge an object
|
||||
* @param target the object to merge into
|
||||
|
@ -18,9 +25,7 @@ export function deepMerge(target: any, ...sources: any[]): any {
|
|||
|
||||
if (isObject(target) && isObject(source)) {
|
||||
for (const key in source) {
|
||||
// values with the key 'value' are an exception
|
||||
// they don't get deep merged
|
||||
if (key === "value") {
|
||||
if (noCopy(key, source[key])) {
|
||||
target[key] = source[key];
|
||||
} else if (isObject(source[key])) {
|
||||
if (!target[key]) { Object.assign(target, { [key]: {} }); }
|
||||
|
|
Loading…
Reference in a new issue