Tone.js/test/helper/Dispose.ts
2019-05-23 14:00:49 -04:00

17 lines
492 B
TypeScript

export function isDisposed(instance) {
for (const prop in instance) {
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);
}
}
}
}