Tone.js/test/helper/Dispose.ts

19 lines
509 B
TypeScript
Raw Normal View History

export function isDisposed(instance): void {
2019-05-23 18:00:49 +00:00
for (const prop in instance) {
if (instance.hasOwnProperty(prop)) {
const member = instance[prop];
if (typeof member !== "function" &&
typeof member !== "string" &&
typeof member !== "number" &&
typeof member !== "boolean" &&
typeof member !== "undefined" &&
prop !== "preset" &&
!(member instanceof AudioContext)) {
if (member !== null) {
throw Error("property was not completely disposed: " + prop);
}
2019-04-12 14:37:47 +00:00
}
}
}
2019-05-23 18:00:49 +00:00
}