UNPKG

class-o-mat

Version:

ALPHA VERSION ONLY: class-o-mats will help to create getter-setter functionality with validations that can be attached to a container class for easier coding. Some basic validations are included. class-o-mats also has the ability to store params as bloc

47 lines (32 loc) 685 B
import Bunyan from 'bunyan'; const log = Bunyan.createLogger({name: "FieldCopier"}); import { NONE, COPY } from '../constants/types'; /** * manages parameters for copying a field to the next * ClassOMat */ class FieldCopier { TYPE = COPY; constructor(parent, key=NONE) { this._params = { key, parent, as: key } } $() { return this._params.parent._addCopiedField(this); } as(as=NONE) { if (as === NONE) return this._params.as; this._params.as = as; return this; } as$(as=NONE) { return this.as(as).$(); } copyField(key) { return this.$().copyField(key); } } export default FieldCopier;