Skip to content

PolicyStat/object-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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 a history point object

Params

  • obj {Object}: The history point

Example

history.add({
  foo: 'bar',
  bar: 'foo'
})

Go back one history point

Makes all backward history forgotten

Makes all forward history forgotten

Go forward one history point

  • returns {Object}: "Current" history point
  • returns {Number}: Number of history points backwards
  • returns {Number}: Number of history points forward

License

Copyright © 2015 PolicyStat LLC

Released under the BSD-3-Clause license.

About

JavaScript Object history (undo/redo)

Resources

Stars

Watchers

Forks

Packages

No packages published