'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: BI Dashboard *| (C) Copyright IBM Corp. 2019 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ /** * Event helper class **/ define([], function () { var destroyedPrototypes = new WeakMap(); var emptyFunction = function emptyFunction() {}; var MemUtil = function () { function MemUtil() { _classCallCheck(this, MemUtil); } /** * Destroy an object - clear all attribute and set all functions to empty functions */ MemUtil.destroy = function destroy(object) { var destroyedProto = destroyedPrototypes.get(object.__proto__); if (!destroyedProto) { destroyedProto = {}; destroyedPrototypes.set(object.__proto__, destroyedProto); for (var prop in object.__proto__) { if (typeof object.__proto__[prop] === 'function') { destroyedProto[prop] = emptyFunction; } } } for (var _prop in object) { // clear everything referenced by this object in case someone is still holding on to it. if (Object.prototype.hasOwnProperty.call(object, _prop)) { if (typeof object[_prop] === 'function') { object[_prop] = emptyFunction; } else { delete object[_prop]; } } } object.__proto__ = destroyedProto; object.__destroyed__ = true; }; MemUtil.isDestroyed = function isDestroyed(object) { return object.__destroyed__; }; return MemUtil; }(); return MemUtil; }); //# sourceMappingURL=MemUtil.js.map