helper.js

1.4.18 • Public • Published

helper.js

delay(fn, duration=0)

setTimeout shortcut

  delay(function(){
    //...
  }, 5000)

wait(obj, resolved=true, duration)

test async function

async function fetch(){
  try{
    let data = await wait({
      code: 0
    });
  }catch(e){
    console.error(e)  
  }
}

queuer()

simple queue manager

  let queue = queuer();
  
  queue.exec(()=>{
    console.log(1)
  })
  queue.exec(()=>{
    console.log(2)
  });
  
  wait().then(()=>{
    queue.ready();
  })
  
  queue.exec(()=>{
    console.log(3)
  })
  
  //result: 1, 2, 3

Readme

Keywords

Package Sidebar

Install

npm i helper.js

Weekly Downloads

39

Version

1.4.18

License

none

Last publish

Collaborators

  • yinxiong