@@ -56,18 +56,6 @@ Run this example with babel-node:
56
56
``` js
57
57
import { GCodeToolpath } from ' gcode-toolpath' ;
58
58
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
-
71
59
const GCODE = [
72
60
' N1 G17 G20 G90 G94 G54' ,
73
61
' N2 G0 Z0.25' ,
@@ -82,9 +70,28 @@ const GCODE = [
82
70
' N11 G00 X0. Y0. Z0.25'
83
71
].join (' \n ' );
84
72
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
+ }
87
83
});
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
+ });
88
95
```
89
96
90
97
and you will see the output as below:
0 commit comments