1.0.0 • Published 6 years ago
object-rollback v1.0.0
object-rollback
Cancel changes to JavaScript object values (add/update/delete properties, add item into Map/Set, etc.)
Install
npm install object-rollbackUsage
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 ] }Tested objects
Standard Built-in ECMAScript 2019 Objects
Error- test codeErrorEvalErrorRangeErrorReferenceErrorSyntaxErrorTypeErrorURIError
Date- test codeRegExp- test codeArray- test codeMap- test codeSet- test codeTypedArray- test codeInt8ArrayUint8ArrayUint8ClampedArrayInt16ArrayUint16ArrayInt32ArrayUint32ArrayBigInt64ArrayBigUint64ArrayFloat32ArrayFloat64Array
DataView- test code
Node.js Built-in Objects
Tests
To run the test suite, first install the dependencies, then run npm test:
npm install
npm testContributing
see CONTRIBUTING.md
1.0.0
6 years ago