UNPKG

@antv/x6

Version:

JavaScript diagramming library that uses SVG and HTML for rendering.

60 lines 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createClass = exports.inherit = void 0; var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; // eslint-disable-line no-proto }) || function (d, b) { // eslint-disable-next-line no-restricted-syntax for (var p in b) { if (Object.prototype.hasOwnProperty.call(b, p)) { d[p] = b[p]; } } }; /** * @see https://github.com/microsoft/TypeScript/blob/5c85febb0ce9d6088cbe9b09cb42f73f9ee8ea05/src/compiler/transformers/es2015.ts#L4309 */ // eslint-disable-next-line function inherit(cls, base) { extendStatics(cls, base); function tmp() { this.constructor = cls; } cls.prototype = base === null ? Object.create(base) : ((tmp.prototype = base.prototype), new tmp()); } exports.inherit = inherit; var A = /** @class */ (function () { function A() { } return A; }()); var isNativeClass = /^\s*class\s+/.test("" + A) || /^\s*class\s*\{/.test("" + /** @class */ (function () { function class_1() { } return class_1; }())); /** * Extends class with specified class name. */ // eslint-disable-next-line function createClass(className, base) { var cls; if (isNativeClass) { // eslint-disable-next-line no-new-func cls = new Function('base', "return class " + className + " extends base { }")(base); } else { // eslint-disable-next-line no-new-func cls = new Function('base', "return function " + className + "() { return base.apply(this, arguments) }")(base); inherit(cls, base); } return cls; } exports.createClass = createClass; //# sourceMappingURL=inherit.js.map