UNPKG

arcticpackage

Version:

A library for making Arctic packages in typescript.

66 lines 1.98 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = __importDefault(require("util")); const Instance_1 = __importDefault(require("./Instance")); class Class { constructor(name, superclass, methods, properties) { this.name = name; this.superclass = superclass; this.methods = methods; this.properties = properties; } findMethod(name) { if (this.methods.has(name)) { return this.methods.get(name); } if (this.superclass != null) { return this.superclass.findMethod(name); } return null; } findProperty(name) { if (this.properties.has(name)) { return this.properties.get(name); } if (this.superclass != null) { return this.properties.get(name); } return null; } set(name, value) { this.properties.set(name, value); } setMethod(method) { this.methods.set(method.name, method); } createInstance(args) { let instance = new Instance_1.default(this); let initializer = this.findMethod(this.name); if (initializer != null) { initializer.bind(instance).call(args); } return instance; } get arity() { let initializer = this.findMethod(this.name); if (initializer == null) return 0; return initializer.arity; } call(args) { let instance = new Instance_1.default(this); let initializer = this.findMethod(this.name); if (initializer != null) { initializer.bind(instance).call(args); } return instance; } [util_1.default.inspect.custom]() { return this.name; } } exports.default = Class; //# sourceMappingURL=Class.js.map