UNPKG

@udraft/core

Version:

uDraft is a language and stack agnostic code-generation tool that simplifies full-stack development by converting a single YAML file into code for rapid development.

39 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UField = void 0; class UField { constructor(name, type) { this._attributes = []; this._name = name; this._type = type; } $name() { return this._name; } $type() { return this._type; } $attribute(attribute) { const a = this._attributes.find((attr) => typeof attribute == "string" ? attr.$name() == attribute : attr.$name() == attribute.$name()); return a ? a : null; } $attributes() { return [...this._attributes]; } $clone(name) { return new UField(name, this.$type()).attributes(this.$attributes()); } attributes(attributes) { this.remove(attributes); this._attributes = this._attributes.concat(attributes); return this; } remove(attributes) { this._attributes = this._attributes.filter((attribute) => !attributes.some((a) => a.$name() == attribute.$name())); return this; } } exports.UField = UField; //# sourceMappingURL=field.js.map