1.0.0 • Published 2 years ago

nv-facutil-simple-pipe v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

nv-facutil-simple-pipe

  • for message-channel testing, useless
  • using message-channel to sequenlize tasks

install

  • npm install nv-facutil-simple-pipe

usage

example

    const {Scache,Acache,Pipe,creat} = require("nv-facutil-simple-pipe")


    var [head,tail]= creat([
       [(msg,self)=>[true,msg+1],'sync'],
       [(msg,self)=>[true,msg+1],'sync'],
       [(msg,self)=>[true,msg+1],'sync']
    ])


    > head.input(10)
    true
    > tail.take()
    13
    > tail.take()

    const {setTimeout} = require("timers/promises");

    var [head,tail]= creat([
       [async (msg,self)=>{await setTimeout(2000);return([true,msg+1])},'async'],
       [async (msg,self)=>{await setTimeout(2000);return([true,msg+1])},'async'],
       [async (msg,self)=>{await setTimeout(2000);return([true,msg+1])},'async']
    ])

    p= tail.take()
    > p
    Promise {
      <pending>,
      [Symbol(async_id_symbol)]: 507,
      [Symbol(trigger_async_id_symbol)]: 5,
      [Symbol(destroyed)]: { destroyed: false }
    }
    head.input(66)

    > p
    Promise {
      <pending>,
      [Symbol(async_id_symbol)]: 71,
      [Symbol(trigger_async_id_symbol)]: 5,
      [Symbol(destroyed)]: { destroyed: false }
    }

    //after 6s
    > p
    Promise {
      69,
      [Symbol(async_id_symbol)]: 255,
      [Symbol(trigger_async_id_symbol)]: 5,
      [Symbol(destroyed)]: { destroyed: false }
    }
    >

METHODS

    head.$conn_from            head.$conn_to              head.$disconn              head.$following_count_
    head.$head_                head.$index_               head.$insert_after         head.$insert_before
    head.$is_head              head.$is_lonely            head.$is_tail              head.$length_
    head.$srcdst_              head.$tail_                head.close                 head.constructor
    head.input                 head.take

    head.$next_                head.$prev_                head.cache                 head.handler
    head.mode


    

LICENSE

  • ISC