Cancel changes to JavaScript object values (add/update/delete properties, add item into Map/Set, etc.)
npm install object-rollback

!Supported Node.js version: >=8.3.0
!Type Definitions: TypeScript




Cancel changes to JavaScript object values (add/update/delete properties, add item into [Map]/[Set], etc.)
[Map]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map
[Set]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set
``sh`
npm install object-rollback
`js
const { ObjectState } = require('object-rollback');
const someValue = {
a: 1,
b: 2,
c: [ 1, 2, 3 ],
};
console.log(someValue); // { a: 1, b: 2, c: [ 1, 2, 3 ] }
const state = new ObjectState(someValue);
someValue.b = 200;
someValue.x = 42;
someValue.c.push(9);
console.log(someValue); // { a: 1, b: 200, c: [ 1, 2, 3, 9 ], x: 42 }
state.rollback();
console.log(someValue); // { a: 1, b: 2, c: [ 1, 2, 3 ] }
`
[ECMAScript 2019]: https://www.ecma-international.org/ecma-262/10.0
* Error - test codeError
* EvalError
* RangeError
* ReferenceError
* SyntaxError
* TypeError
* URIError
* Date
* - test codeRegExp
* - test codeArray
* - test codeMap
* - test codeSet
* - test codeTypedArray
* - test codeInt8Array
* Uint8Array
* Uint8ClampedArray
* Int16Array
* Uint16Array
* Int32Array
* Uint32Array
* BigInt64Array
* BigUint64Array
* Float32Array
* Float64Array
* DataView
* - test code
[Node.js]: https://nodejs.org
* Buffer - test code
* URL - test code
To run the test suite, first install the dependencies, then run npm test:
`sh``
npm install
npm test
see CONTRIBUTING.md