123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- define([], function () {
- var destroyedPrototypes = new WeakMap();
- var emptyFunction = function emptyFunction() {};
- var MemUtil = function () {
- function MemUtil() {
- _classCallCheck(this, MemUtil);
- }
-
- 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) {
-
- 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;
- });
|