nv-facutil-simple-mq
v1.0.1
Published
nv-facutil-simple-mq =============== - simple promise mq
Downloads
1
Readme
nv-facutil-simple-mq
- simple promise mq
install
- npm install nv-facutil-simple-mq
usage
const {SimpleMq,creat_simple_taker} = require("nv-facutil-simple-mq")
example
###simple
var mq = new SimpleMq()
var wait0 = mq.take()
var wait1 = mq.take()
> wait0
Promise {
<pending>,
[Symbol(async_id_symbol)]: 58,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
> wait1
Promise {
<pending>,
[Symbol(async_id_symbol)]: 60,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
mq.put([10,20,30])
> wait0
Promise {
[ 10, 20, 30 ],
[Symbol(async_id_symbol)]: 58,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
> wait1
Promise {
<pending>,
[Symbol(async_id_symbol)]: 60,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
>
> mq
SimpleMq(0) []
>
> mq.put("123456")
> wait1
Promise {
'123456',
[Symbol(async_id_symbol)]: 58,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
>
> mq.put(100)
> mq.put(300)
> mq
SimpleMq(2) [ 100, 300 ]
>
> mq.take()
100
> mq
SimpleMq(1) [ 300 ]
> mq.take()
300
> mq
SimpleMq(0) []
>
> var wait =mq.take()
undefined
> wait
Promise {
<pending>,
[Symbol(async_id_symbol)]: 493,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
>
METHODS
###simple
- mq.put()
- mq.take(who)
- mq.pending_
- creat_taker(who,mq,cb=(msg)=>{})
APIS
LICENSE
- ISC