Tone.js/test/helper/Dispose.ts

18 lines
492 B
TypeScript
Raw Normal View History

2019-05-23 18:00:49 +00:00
export function isDisposed(instance) {
for (const prop in instance) {
2019-04-12 14:37:47 +00:00
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) &&
!instance.constructor.prototype[prop]) {
if (member !== null) {
throw Error("property was not completely disposed: " + prop);
}
}
}
2019-05-23 18:00:49 +00:00
}