Skip to content

Commit 2478545

Browse files
committed
Update README.md
1 parent 3a590d2 commit 2478545

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

README.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ Run this example with babel-node:
5656
```js
5757
import { GCodeToolpath } from 'gcode-toolpath';
5858

59-
let toolpaths = [];
60-
let gcode = new GCodeToolpath({
61-
addLine: (modalState, v1, v2) => {
62-
var motion = modalState.motion;
63-
toolpaths.push({ motion: motion, v1: v1, v2: v2 });
64-
},
65-
addArcCurve: (modalState, v1, v2, v0) => {
66-
var motion = modalState.motion;
67-
toolpaths.push({ motion: motion, v1: v1, v2: v2, v0: v0 });
68-
}
69-
});
70-
7159
const GCODE = [
7260
'N1 G17 G20 G90 G94 G54',
7361
'N2 G0 Z0.25',
@@ -82,9 +70,28 @@ const GCODE = [
8270
'N11 G00 X0. Y0. Z0.25'
8371
].join('\n');
8472

85-
gcode.loadFromString(GCODE, (err, results) => {
86-
console.log(toolpaths);
73+
let toolpaths = [];
74+
let gcode = new GCodeToolpath({
75+
addLine: (modalState, v1, v2) => {
76+
var motion = modalState.motion;
77+
toolpaths.push({ motion: motion, v1: v1, v2: v2 });
78+
},
79+
addArcCurve: (modalState, v1, v2, v0) => {
80+
var motion = modalState.motion;
81+
toolpaths.push({ motion: motion, v1: v1, v2: v2, v0: v0 });
82+
}
8783
});
84+
85+
gcode
86+
.loadFromString(GCODE, (err, results) => {
87+
console.log(toolpaths);
88+
})
89+
.on('data', (data) => {
90+
// 'data' event listener
91+
})
92+
.on('end', (results) => {
93+
// 'end' event listener
94+
});
8895
```
8996

9097
and you will see the output as below:

0 commit comments

Comments
 (0)