UNPKG

@thisisagile/easy

Version:

Straightforward library for building domain-driven microservice architectures

9 lines (6 loc) 343 B
import { Construct, ofConstruct } from '../types/Constructor'; export class State { constructor(protected readonly state: any = {}) {} protected get = <T>(key: string, alt?: Construct<T>): T => this.state[key] ?? (this.state[key] = ofConstruct(alt)); protected set = <T>(key: string, value: Construct<T>): T => this.get(key, value); }