UNPKG

aztec

Version:

Node Js Framework for creating API Services

41 lines (33 loc) 840 B
import { Handler } from './handler.class'; export class Base { readonly(keys: string[]) { this.readOnlyKeys = keys; } set(key: string, value: any): void { if (this.readOnlyKeys) { this.readOnlyKeys.forEach(roKey => { if (roKey !== key) { this[key] = value; } else { Handler.userError( `svc.set(${key}, ${value}). "${key}" property is the internal variable, and cannot be overwritten. `); } }); } else { this[key] = value; } } get(key: string): any { return this[key]; } enable(key: string): void { this[key] = this[`${key}-disabled`]; delete this[`${key}-disabled`]; } disable(key: string): void { this[`${key}-disabled`] = this[key]; delete this[key]; } protected readOnlyKeys: string[]; }