| 39 | // @param {function} iteratee The iteratee invoked per element. |
| 40 | // @param {function} done The done invoked after the loop has finished. |
| 41 | const 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 |
| 64 | const parseLine = (() => { |