1.0.1 • Published 2 years ago
nv-facutil-simple-next-prev v1.0.1
nv-facutil-simple-next-prev
- simple next-prev data-ctx
install
- npm install nv-facutil-simple-next-prev
usage
const {Data} = require("nv-facutil-simple-next-prev")
example
var data = new Data({a:100,b:200,c:300})
/*
> data
Data { a: 100, b: 200, c: 300 }
>
> data.history_
SimpleHistory(1) [
{ a: 100, b: 200, c: 300 },
max_size: Infinity,
noexist: Symbol(noexist)
]
>
*/
data.next((r)=>{r.a=r.a+1;r.b=r.b+1;r.c=r.c+1})
/*
>
Data { a: 101, b: 201, c: 301 }
>
> data.history_
SimpleHistory(2) [
{ a: 100, b: 200, c: 300 },
{ a: 101, b: 201, c: 301 },
max_size: Infinity,
noexist: Symbol(noexist)
]
>
*/
data.next((r)=>{r.a=r.a+1;r.b=r.b+1;r.c=r.c+1})
/*
> data
Data { a: 102, b: 202, c: 302 }
>
> data.history_
SimpleHistory(3) [
{ a: 100, b: 200, c: 300 },
{ a: 101, b: 201, c: 301 },
{ a: 102, b: 202, c: 302 },
max_size: Infinity,
noexist: Symbol(noexist)
]
>
*/
data.prev()
/*
> data.prev()
Data { a: 101, b: 201, c: 301 }
>
> data
Data { a: 101, b: 201, c: 301 }
>
> data.history_
SimpleHistory(2) [
{ a: 100, b: 200, c: 300 },
{ a: 101, b: 201, c: 301 },
max_size: Infinity,
noexist: Symbol(noexist)
]
>
*/
/*
> data.prev()
Data { a: 100, b: 200, c: 300 }
>
> data.prev()
Data {}
> data.history_
SimpleHistory(0) [ max_size: Infinity, noexist: Symbol(noexist) ]
>
*/
METHODS
new Data(init_data={},copy_func=DFLT_COPY,asgn_func=DFLT_ASSIGN,max_hist_size=Infinity,none=noexist)
//getter/setter
data.assign_func_
data.copy_func_
//getter
data.history_
data.max_hist_size_
data.noexist_
data.clear()
data.prev(handle,copy_func=DFLT_COPY,asgn_func=DFLT_ASSIGN)
data.next(handle=(r)=>r,asgn_func=DFLT_ASSIGN)
APIS
- DFLT_COPY(that)
- DFLT_ASSIGN(that,O)
LICENSE
- ISC
1.0.1
2 years ago