object-history

3.1.0 • Public • Published

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

  • 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

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.

Package Sidebar

Install

npm i object-history

Weekly Downloads

432

Version

3.1.0

License

BSD-3-Clause

Last publish

Collaborators

  • mightyiam
  • weswinham