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

Function parseStream

src/index.js:246–272  ·  view source on GitHub ↗
(stream, options, callback = noop)

Source from the content-addressed store, hash-verified

244// @param {options} options The options object
245// @param {function} callback The callback function
246const parseStream = (stream, options, callback = noop) => {
247 if (typeof options === 'function') {
248 callback = options;
249 options = {};
250 }
251
252 const emitter = new events.EventEmitter();
253
254 try {
255 const results = [];
256 stream
257 .pipe(new GCodeLineStream(options))
258 .on('data', (data) => {
259 emitter.emit('data', data);
260 results.push(data);
261 })
262 .on('end', () => {
263 emitter.emit('end', results);
264 callback && callback(null, results);
265 })
266 .on('error', callback);
267 } catch (err) {
268 callback(err);
269 }
270
271 return emitter;
272};
273
274// @param {string} file The G-code path name
275// @param {options} options The options object

Callers 3

parseFileFunction · 0.85
parseStringFunction · 0.85
index.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected