next-loop-execute
Loop execute for next.
installation
npm install -S @feizheng/next-loop-execute
usage
import '@feizheng/next-loop-execute';
const fetchApi = function ({ count }) {
return fetch('https://api.github.com/users/afeiship').then(res=>res.json());
}
// loop 3 times:
nx.loopExecute({
callback: fetchApi,
done: function (res) {
console.log('res.data:', res.data);
return res.count === 3;
}
}).then(res=>{
console.log('loop DONE!', res);
});
license
Code released under the MIT license.