1.0.7 • Published 3 years ago

@jswork/next-loop-execute v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

next-loop-execute

Loop execute for next.

version license size download

installation

npm install -S @jswork/next-loop-execute

usage

import '@jswork/next-loop-execute';

const fetchApi = function ({ count }) {
  return fetch('https://api.github.com/users/afeiship').then(res=>res.json());
}

// loop 3 times:
nx.loopExecute({
  interval: 200,
  timeout: 10 * 1000,
  interrupt: (res)=>{
    return false;
  },
  callback: (data) => {
    console.log(data);
    return fetch('https://api.github.com/users/afeiship').then((res) => res.json());
  },
  done: (res) => {
    return res.data.status === 'FINISHED';
  }
}).then((res) => {
  console.log('DONE:', res);
})

license

Code released under the MIT license.