An interval-based looping method for massive data
Doing simple looping basicly doesn't have big impact to your RAM/CPU resource, but, it will if you performing heavy looping with massive data, for example 100k data or > 1m data.
Default looping method like
foreach runs faster (has better performance), but also takes and spent more RAM/CPU resource continously along with the looping process—if you own more resource, I think it's not a big problem. Otherwise, using interval method doesn't harm RAM/CPU resource too much. It just uses a little bit of it and keeping the resource stable until the process is done. As a consequence, it runs slower than the default method—but still fast.
So, if you need to do looping with massive data and heavy process inside, using interval method should be a better solution.
npm install vcmloop --save
// Bowerbower install vcmloop --save
const vcmloop = ;
// Bower<script src="bower_components/vcmloop/dist/vcmloop.min.js"></script>
- number start
- number stop
- function fn
- function end [optional]
- number delay [optional]
- default 0
Here is basic
You can pass an
end argument to run once after the synchronous looping process is done.
;// output:// 0// 1// 2// 3// 4// end
You can set duration or
delay for interval process.
You may do this in an asynchronous looping process to make sure your code runs correctly:
var len = 10;var lenX = len - 1;var start = 0;;
Copyright © 2019 Dali Kewara.