1.0.3 • Published 4 years ago

@feizheng/next-operation-history v1.0.3

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

next-operation-history

Operation history for next.

installation

npm install -S @feizheng/next-operation-history

structure

{
  max: 100,
  engine: 'local', // session
  prefix:'wbs', // wbs__operation_history@
  index: 0,  // the pointer
  data: [
    { id:'obj_hash1', value: 'json1'},
    { id:'obj_hash2', value: 'json2'},
    { id:'obj_hash3', value: 'json3'},
    { id:'obj_hash4', value: 'json4'},
  ]
}

configuration

{
  max: 10,
  engine: 'local', // session
  prefix: 'nx'
}

methods

apiparamsdescription
reset-Set index/data to default options value.
last-Get last index.
at-/indexGet current(index) item at index.
get(id)Get data by id.
gets-Get all storage data.
forward-Move index to next.
back-Move index to previous.
goindexMove to the index.
pushdataPush data to items.
replacedataReplace the last item.
adddataAdd to the store without judgement.
delidRemove all the equal id elements.

properties

apidescription
nextProperty: can forward?
prevProperty: can back?
lengthProperty: data size
indexProperty: Pointer
dataProperty: the original data

usage

import NxOperationHistory from '@feizheng/next-operation-history';

// code goes here:
const noh = new NxOperationHistory({ prefix: 'abc', max: 20, engine:'local' });

// save:
noh.push();
noh.at():

// undo
noh.back();
noh.at();

// redo
noh.forward();
noh.at();

// can next?
noh.next

// can previous?
noh.prev