Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/afeiship/next-operation-history
Operation history for next.
https://github.com/afeiship/next-operation-history
history next operation redo undo
Last synced: 8 days ago
JSON representation
Operation history for next.
- Host: GitHub
- URL: https://github.com/afeiship/next-operation-history
- Owner: afeiship
- License: mit
- Created: 2020-03-27T08:35:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-22T06:15:09.000Z (about 4 years ago)
- Last Synced: 2024-12-10T10:26:15.638Z (12 days ago)
- Topics: history, next, operation, redo, undo
- Language: JavaScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-operation-history
> Operation history for next.[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]## installation
```bash
npm install -S @jswork/next-operation-history
```## structure
```js
{
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
```js
{
max: 10,
engine: 'local', // session
prefix: 'nx'
}
```## methods
| api | params | description |
| ------- | ------- | ---------------------------------------- |
| reset | - | Set index/data to default options value. |
| last | - | Get last index. |
| at | -/index | Get 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. |
| go | index | Move to the index. |
| push | data | Push data to items. |
| replace | data | Replace the last item. |
| add | data | Add to the store without judgement. |
| del | id | Remove all the equal id elements. |## properties
| api | description |
| ------ | --------------------------- |
| next | Property: can forward? |
| prev | Property: can back? |
| length | Property: data size |
| index | Property: Pointer |
| data | Property: the original data |## usage
```js
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
```## license
Code released under [the MIT license](https://github.com/afeiship/next-operation-history/blob/master/LICENSE.txt).[version-image]: https://img.shields.io/npm/v/@jswork/next-operation-history
[version-url]: https://npmjs.org/package/@jswork/next-operation-history[license-image]: https://img.shields.io/npm/l/@jswork/next-operation-history
[license-url]: https://github.com/afeiship/next-operation-history/blob/master/LICENSE.txt[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-operation-history
[size-url]: https://github.com/afeiship/next-operation-history/blob/master/dist/next-operation-history.min.js[download-image]: https://img.shields.io/npm/dm/@jswork/next-operation-history
[download-url]: https://www.npmjs.com/package/@jswork/next-operation-history