UNPKG

reactronic

Version:

Reactronic - Transactional Reactive State Management

25 lines (24 loc) 882 B
import { Sealant } from "./Sealant.js"; export class SealedArray extends Array { pop() { throw Sealant.error(this); } push(...items) { throw Sealant.error(this); } sort(compareFn) { throw Sealant.error(this); } splice(start, deleteCount, ...items) { throw Sealant.error(this); } unshift(...items) { throw Sealant.error(this); } [Sealant.CreateCopy]() { return this.slice(); } slice(start, end) { const result = super.slice(start, end); Object.setPrototypeOf(result, Array.prototype); return result; } } Object.defineProperty(Array.prototype, "toMutable", { configurable: false, enumerable: false, value() { return Sealant.toMutable(this); }, }); Object.defineProperty(Array.prototype, Sealant.SealedType, { value: SealedArray.prototype, configurable: false, enumerable: false, writable: false, });