@@ -60,7 +60,7 @@ var interpret = function interpret(self, data) {
6060 var word = words [ 0 ] || [ ] ;
6161 var letter = word [ 0 ] ;
6262 var arg = word [ 1 ] ;
63- var cmd = ( letter + arg ) . replace ( '.' , '_' ) ;
63+ var cmd = letter + arg ;
6464 var args = { } ;
6565
6666 if ( _lodash2 . default . includes ( [ 'G' , 'M' ] , letter ) ) {
@@ -80,6 +80,11 @@ var interpret = function interpret(self, data) {
8080 args = _lodash2 . default . zipObject ( words ) ; // returns an object composed from arrays of property names and values.
8181 }
8282
83+ if ( typeof self . handlers [ cmd ] === 'function' ) {
84+ var func = self . handlers [ cmd ] ;
85+ func ( args ) ;
86+ }
87+
8388 if ( typeof self [ cmd ] === 'function' ) {
8489 var func = self [ cmd ] . bind ( self ) ;
8590 func ( args ) ;
@@ -88,14 +93,20 @@ var interpret = function interpret(self, data) {
8893} ;
8994
9095var GCodeInterpreter = ( function ( ) {
91- function GCodeInterpreter ( ) {
96+ function GCodeInterpreter ( options ) {
9297 _classCallCheck ( this , GCodeInterpreter ) ;
9398
9499 this . cmd = '' ;
100+ this . handlers = { } ;
95101 this . _callbacks = {
96102 'data' : [ ] ,
97103 'end' : [ ]
98104 } ;
105+
106+ options = options || { } ;
107+ options . handlers = options . handlers || { } ;
108+
109+ this . handlers = options . handlers ;
99110 }
100111
101112 _createClass ( GCodeInterpreter , [ {
0 commit comments