File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ export class BinaryToJSON {
63
63
64
64
private getValue ( br : BinaryReader , format :{ } ) : number | null | string {
65
65
const [ key , val ] = Object . entries ( format ) [ 0 ] ;
66
- if ( key === "__reserve" ) {
66
+ if ( key === "__reserve" || key === "__skip" ) {
67
67
br . seek ( br . position + Number ( val ) ) ;
68
68
return null ;
69
69
}
Original file line number Diff line number Diff line change @@ -132,17 +132,34 @@ Deno.test(
132
132
assertEquals ( 0x0001020304050607 , data [ 'dat' ] ) ;
133
133
} ,
134
134
) ;
135
- /*
136
135
Deno . test (
137
136
"complex dat" ,
138
137
function ( ) : void {
139
- const file = Deno.openSync("xxx.DAT");
138
+ /*
139
+ const file = Deno.openSync("XXX.DAT");
140
140
const buffer = Deno.readAllSync(file);
141
141
Deno.close(file.rid);
142
142
const format = JSON.parse(Deno.readTextFileSync("prct_format.json"));
143
143
const b2j = new BinaryToJSON();
144
144
const data: any = b2j.convert(buffer, format);
145
- console.log(data);
145
+ //console.log(data);
146
+ */
146
147
} ,
147
148
) ;
148
- */
149
+
150
+ Deno . test (
151
+ "skip bytes" ,
152
+ function ( ) : void {
153
+ const buffer = new ArrayBuffer ( 4 ) ;
154
+ const arry = new Uint8Array ( buffer ) ;
155
+ arry [ 0 ] = 0x0D ;
156
+ arry [ 1 ] = 0x0C ;
157
+ arry [ 2 ] = 0x0B ;
158
+ arry [ 3 ] = 0x0A ;
159
+ const format = [ { "__skip" :2 } , { "dat" :2 } ] ;
160
+ const b2j = new BinaryToJSON ( ) ;
161
+ const data : any = b2j . convert ( arry , format ) ;
162
+ console . log ( data ) ;
163
+ assertEquals ( 0x0B0A , data [ 'dat' ] ) ;
164
+ } ,
165
+ ) ;
You can’t perform that action at this time.
0 commit comments