MCPcopy Index your code
hub / github.com/cncjs/gcode-parser / iterateArray

Function iterateArray

src/index.js:41–61  ·  view source on GitHub ↗
(arr = [], opts = {}, iteratee = noop, done = noop)

Source from the content-addressed store, hash-verified

39// @param {function} iteratee The iteratee invoked per element.
40// @param {function} done The done invoked after the loop has finished.
41const iterateArray = (arr = [], opts = {}, iteratee = noop, done = noop) => {
42 if (typeof opts === 'function') {
43 done = iteratee;
44 iteratee = opts;
45 opts = {};
46 }
47
48 opts.batchSize = opts.batchSize || 1;
49
50 const loop = (i = 0) => {
51 for (let count = 0; i < arr.length && count < opts.batchSize; ++i, ++count) {
52 iteratee(arr[i], i, arr);
53 }
54 if (i < arr.length) {
55 timers.setImmediate(() => loop(i));
56 return;
57 }
58 done();
59 };
60 loop();
61};
62
63// @param {string} line The G-code line
64const parseLine = (() => {

Callers 1

_transformMethod · 0.85

Calls 1

loopFunction · 0.85

Tested by

no test coverage detected