Skip to content
JavaScript Object history (undo/redo)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test/unit
.editorconfig
.eslintrc
.gitignore
.travis.yml
.verb.md
README.md
VERSION
package.js

README.md

object-history NPM version Build Status js-standard-style

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

Params

  • initial {Object}: The initial history point
  • options {Object}
    - limit {Number}: Optional. Remember this many backward points

Example

var History = require('object-history')
var initial = {foo: 'bar', name: 'victoria'}
var history = new History(initial, {limit: 33})

.add

Add a history point object

Params

  • obj {Object}: The history point

Example

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.

You can’t perform that action at this time.