checkpoint-store
In-memory key-value store with history! Keys are strings, values are any type.
Last updated 9 years ago by kumavis .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install checkpoint-store 
SYNC missed versions from official npm registry.

Checkpoint-Store

In-memory key-value store with history! Keys are strings, values are any type.

var store = new CheckpointStore()
store.put('xyz', 'hello world')
store.checkpoint()
store.put('xyz', 'haay wuurl')

store.get('xyz') //=> 'haay wuurl'
store.revert()
store.get('xyz') //=> 'hello world'

Uses functional-red-black-tree under the hood.

api

new CheckpointStore(initialState)

creates a new store. optionally pass in the intial state as a pojo.

store.put(key, value)

sets a value. key is a string. value is any type.

store.get(key)

returns a value. key is a string. value is any type.

store.del(key)

deletes a value. key is a string.

store.checkpoint()

adds a checkpoint. state of the store can be returned to this point.

store.revert()

returns to the state of the previous checkpoint. throws an error if there are no checkpoints.

store.commit()

keeps the state and removes the previous checkpoint. throws an error if there are no checkpoints.

store.isCheckpointed()

returns true if the store has remaining checkpoints.

store.copy()

returns a new CheckpointStore with matching state and checkpoints.

store.toJSON()

returns an object (not a string!) of the current state.

Current Tags

  • 1.1.0                                ...           latest (9 years ago)

2 Versions

  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE