block-run
block run code Execute code block in sequence by channels
install
npm install block-run
api
run
- FunctionName run
- Return anything
- Description run block code in channel
- Param
name | type | require | default | Description |
---|---|---|---|---|
channel | string | must | null | block code channel |
func | Function or GeneratorFunction or AsyncFunction | must | null | block code function |
funTimeout | number | option | -1 | function timeout |
getQueue
- FunctionName getQueue
- Return object
- Description get all channel queue
- Param nothing
base example
const assert = ;const co = ;const BlockRun = ; //Promise BlockRun; let { return { };} // testChannel2 make two async function in sequence //co yield ; //asyncasync { try forlet i = 0;i<10;i++ let res = await BlockRun; assert; catche throw e; };
different
before
code:
let { return { };} async { forlet i = 0;i<10;i++ console };async { forlet i = 0;i<10;i++ console };
result:
one seconds two number
two async function run at the same time
aftar
code:
const BlockRun = ;let { return { };} async { forlet i = 0;i<10;i++ let res = await BlockRun; console };async { forlet i = 0;i<10;i++ let res = await BlockRun; console };
result:
one seconds one number
two async function run in sequence by same channel name