0.15.0 • Published 2 years ago

unreson v0.15.0

Weekly downloads
-
License
MPL-2.0
Repository
-
Last release
2 years ago

unreson -- undo/redo-able object wrapper

unreson provides the StateObject class that manages the state for a provided JSON-safe object. Changes to the object, no matter how deep, may be undone or redone. The state of the object can also be made temporarily immutable if the need arises.

Usage

let unreson = require('unreson')

let myObject = new unreson.StateObject({ a: 0, b: 1, c: {}, d: [0,1,2,3,4] })

console.log(myObject.state) // { a: 0, b: 1, c: {}, d: [ 0, 1, 2, 3, 4 ] }
myObject.state.c = 2
console.log(myObject.state) // { a: 0, b: 1, c: 2, d: [ 0, 1, 2, 3, 4 ] }
myObject.undo()
console.log(myObject.state) // { a: 0, b: 1, c: {}, d: [ 0, 1, 2, 3, 4 ] }
myObject.redo()
console.log(myObject.state) // { a: 0, b: 1, c: 2, d: [ 0, 1, 2, 3, 4 ] }
myObject.freeze()
console.log(myObject.frozen) // true
myObject.state.c = 3
myObject.thaw()
console.log(myObject.frozen) // false
console.log(myObject.state) // { a: 0, b: 1, c: 2, d: [ 0, 1, 2, 3, 4 ] }
0.15.0

2 years ago

0.14.0

3 years ago

0.13.0

4 years ago

0.12.0

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.3

4 years ago

0.8.1

4 years ago

0.8.2

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago