mimicry.module(function baseModule () { let counter = 0; class Base { constructor () { this._id = ++counter; this._uncyclic = []; } get className () { return this.constructor.name; } get id () { return this._id; } destructor () { for (let i = 0; i < this._uncyclic.length; ++i) { try { this._uncyclic[i].call(this); } catch (e) { //log probably } } for (let key in this) { if (this.hasOwnProperty(key)) { this[key] = undefined; delete this[key]; } } this.destroyed = true; } recycle (/*Function*/fn) { this._uncyclic.push(fn); } } return Base; });