moving toJSON implementation to the BaseContext

This commit is contained in:
Yotam Mann 2021-01-04 09:57:52 -05:00
parent 16859ff2e2
commit f04581863c
3 changed files with 10 additions and 16 deletions

View file

@ -20,8 +20,8 @@ export type ExcludedFromBaseAudioContext =
// the subset of the BaseAudioContext which Tone.Context implements.
export type BaseAudioContextSubset = Omit<
BaseAudioContext,
ExcludedFromBaseAudioContext
BaseAudioContext,
ExcludedFromBaseAudioContext
>;
export type ContextLatencyHint = AudioContextLatencyCategory;
@ -149,7 +149,14 @@ export abstract class BaseContext
abstract immediate(): Seconds;
abstract toJSON(): Record<string, any>;
/*
* This is a placeholder so that JSON.stringify does not throw an error
* This matches what JSON.stringify(audioContext) returns on a native
* audioContext instance.
*/
toJSON(): Record<string, any> {
return {};
}
readonly isOffline: boolean = false;
}

View file

@ -625,13 +625,4 @@ export class Context extends BaseContext {
intervalFn();
return id;
}
/*
* This is a placeholder so that JSON.stringify does not throw an error
* This matches what JSON.stringify(audioContext) returns on a native
* audioContext instance.
*/
toJSON() {
return {};
}
}

View file

@ -197,9 +197,5 @@ export class DummyContext extends BaseContext {
return 0;
}
toJSON() {
return {};
}
readonly isOffline: boolean = false;
}