node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »


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.



Gives birth to instances

  • initial {Object}: The initial history point
  • options {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 a history point object

  • obj {Object}: The history point
  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


Copyright © 2015 PolicyStat LLC

Released under the BSD-3-Clause license.