object-history
v3.1.0
Published
Object History
Downloads
1,623
Readme
object-history
JavaScript Object history
Behind the scenes
For cloning, UltraDeepClone. For diff/apply, changeset.
Old browsers
Works in IE8 with es5-shim
. Perhaps IE7, as well.
API
History
Gives birth to instances
initial
{Object}: The initial history pointoptions
{Object}:limit
:{Number}
Remember this many backward points
var History = require('object-history')
var initial = {foo: 'bar', name: 'victoria'}
var history = new History(initial, {limit: 33})
.add
Add a history point object
obj
{Object}: The history point
history.add({
foo: 'bar',
bar: 'foo'
})
.backward
Go back one history point
.forgetAllBackward
Makes all backward history forgotten
.forgetAllForward
Makes all forward history forgotten
.forward
Go forward one history point
.get
returns
{Object}: "Current" history point
.lengthBackward
returns
{Number}: Number of history points backwards
.lengthForward
returns
{Number}: Number of history points forward
License
Copyright © 2015 PolicyStat LLC
Released under the BSD-3-Clause license.