UNPKG

reactronic

Version:

Reactronic - Transactional Reactive State Management

36 lines (35 loc) 1.26 kB
import { Sealant } from "../util/Sealant.js"; import { MvccObject } from "./Mvcc.js"; export class MvccMap extends MvccObject { constructor(isSignalling, map) { super(isSignalling); this.impl = map; } clear() { this.mutable.clear(); } delete(key) { return this.mutable.delete(key); } forEach(callbackfn, thisArg) { this.impl.forEach(callbackfn, thisArg); } get(key) { return this.impl.get(key); } has(key) { return this.impl.has(key); } set(key, value) { this.mutable.set(key, value); return this; } get size() { return this.impl.size; } entries() { return this.impl.entries(); } keys() { return this.impl.keys(); } values() { return this.impl.values(); } [Symbol.toStringTag]() { return this.impl[Symbol.toStringTag]; } get mutable() { const createCopy = this.impl[Sealant.CreateCopy]; if (createCopy) return this.impl = createCopy.call(this.impl); return this.impl; } } export class TxMap extends MvccMap { constructor(args) { super(false, args !== undefined ? new Map(args) : new Map()); } } export class SxMap extends MvccMap { constructor(args) { super(true, args !== undefined ? new Map(args) : new Map()); } }