UNPKG

@benev/slate

Version:
25 lines 634 B
export class Slice { #options; constructor(options) { this.#options = options; } get state() { return this.#options.getter(this.#options.parent.state); } transmute(fun) { this.#options.parent.transmute(state => { const x1 = this.#options.getter(state); const x2 = fun(x1); const new_state = this.#options.setter(state, x2); return new_state; }); } slice({ getter, setter }) { return new Slice({ parent: this, getter, setter, }); } } //# sourceMappingURL=slice.js.map