UNPKG

p5

Version:

[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)

26 lines (25 loc) • 575 B
//#region src/core/States.js var States = class { #modified = {}; constructor(initialState) { for (const key in initialState) this[key] = initialState[key]; } setValue(key, value) { if (!(key in this.#modified)) this.#modified[key] = this[key]; this[key] = value; } takeDiff() { const diff = this.#modified; this.#modified = {}; return diff; } getModified() { return this.#modified; } applyDiff(prevModified) { for (const key in this.#modified) this[key] = this.#modified[key]; this.#modified = prevModified; } }; //#endregion export { States };