@@ -64,16 +64,19 @@ const suite = (Buffer) =>
6464 } ) ;
6565 it ( 'should parse array of user defined types and have access to parent context' , function ( ) {
6666 var elementParser = new Parser ( ) . uint8 ( 'key' ) . array ( 'value' , {
67- type : " uint8" ,
67+ type : ' uint8' ,
6868 length : function ( ) {
6969 return this . $parent . valueLength ;
70- }
70+ } ,
7171 } ) ;
7272
73- var parser = Parser . start ( ) . uint16le ( 'length' ) . uint16le ( 'valueLength' ) . array ( 'message' , {
74- length : 'length' ,
75- type : elementParser ,
76- } ) ;
73+ var parser = Parser . start ( )
74+ . uint16le ( 'length' )
75+ . uint16le ( 'valueLength' )
76+ . array ( 'message' , {
77+ length : 'length' ,
78+ type : elementParser ,
79+ } ) ;
7780
7881 var buffer = Buffer . from ( [
7982 0x02 ,
@@ -97,17 +100,20 @@ const suite = (Buffer) =>
97100 } ) ;
98101 } ) ;
99102 it ( 'should parse array of user defined types and have access to root context' , function ( ) {
100- var elementParser = new Parser ( ) . uint8 ( 'key' ) . nest ( " data" , {
103+ var elementParser = new Parser ( ) . uint8 ( 'key' ) . nest ( ' data' , {
101104 type : new Parser ( ) . array ( 'value' , {
102- type : " uint8" ,
103- length : " $root.valueLength"
104- } )
105+ type : ' uint8' ,
106+ length : ' $root.valueLength' ,
107+ } ) ,
105108 } ) ;
106109
107- var parser = Parser . start ( ) . uint16le ( 'length' ) . uint16le ( 'valueLength' ) . array ( 'message' , {
108- length : 'length' ,
109- type : elementParser ,
110- } ) ;
110+ var parser = Parser . start ( )
111+ . uint16le ( 'length' )
112+ . uint16le ( 'valueLength' )
113+ . array ( 'message' , {
114+ length : 'length' ,
115+ type : elementParser ,
116+ } ) ;
111117
112118 var buffer = Buffer . from ( [
113119 0x02 ,
@@ -125,8 +131,8 @@ const suite = (Buffer) =>
125131 length : 0x02 ,
126132 valueLength : 0x02 ,
127133 message : [
128- { key : 0xca , data : { value : [ 0xd2 , 0x04 ] } } ,
129- { key : 0xbe , data : { value : [ 0xd3 , 0x04 ] } } ,
134+ { key : 0xca , data : { value : [ 0xd2 , 0x04 ] } } ,
135+ { key : 0xbe , data : { value : [ 0xd3 , 0x04 ] } } ,
130136 ] ,
131137 } ) ;
132138 } ) ;
@@ -474,7 +480,6 @@ const suite = (Buffer) =>
474480 ] ,
475481 } ) ;
476482 } ) ;
477-
478483 it ( 'should allow parent parser attributes as choice key' , function ( ) {
479484 var ChildParser = Parser . start ( ) . choice ( 'data' , {
480485 tag : function ( vars ) {
@@ -924,7 +929,7 @@ const suite = (Buffer) =>
924929 1 : Parser . start ( )
925930 . uint8 ( 'length' )
926931 . string ( 'message' , { length : 'length' } )
927- . array ( 'value' , { type : " uint8" , length : " $parent.items" } ) ,
932+ . array ( 'value' , { type : ' uint8' , length : ' $parent.items' } ) ,
928933 3 : Parser . start ( ) . int32le ( 'number' ) ,
929934 } ,
930935 } ) ;
@@ -1050,11 +1055,11 @@ const suite = (Buffer) =>
10501055 var parser = Parser . start ( )
10511056 . uint8 ( 'items' )
10521057 . nest ( 'data' , {
1053- type : Parser . start ( )
1054- . uint8 ( 'length' )
1055- . string ( 'message' , { length : 'length' } )
1056- . array ( 'value' , { type : " uint8" , length : " $parent.items" } ) ,
1057- } ) ;
1058+ type : Parser . start ( )
1059+ . uint8 ( 'length' )
1060+ . string ( 'message' , { length : 'length' } )
1061+ . array ( 'value' , { type : ' uint8' , length : ' $parent.items' } ) ,
1062+ } ) ;
10581063
10591064 var buffer = Buffer . from ( [
10601065 0x2 ,
0 commit comments