UNPKG

@antv/g6

Version:

graph visualization frame work

50 lines (36 loc) 1.83 kB
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileOverview * The base class for complex class * @author huangtonger@aliyun.com */ var Util = require('./util/'); var EventEmitter = require('wolfy87-eventemitter'); var Base = function (_EventEmitter) { _inherits(Base, _EventEmitter); Base.prototype.getDefaultCfg = function getDefaultCfg() { return {}; }; function Base(cfg) { _classCallCheck(this, Base); var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); var defaultCfg = _this.getDefaultCfg(); _this._cfg = Util.mix({}, defaultCfg, cfg); return _this; } Base.prototype.get = function get(name) { return this._cfg[name]; }; Base.prototype.set = function set(name, value) { this._cfg[name] = value; }; Base.prototype.destroy = function destroy() { this._cfg = {}; this.removeAllListeners(); this.destroyed = true; }; return Base; }(EventEmitter); module.exports = Base;