File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -605,16 +605,21 @@ export class Parser {
605605 return this . setNextParser ( "buffer" , varName , options ) ;
606606 }
607607
608- wrapped ( varName : string , options : ParserOptions ) : this {
609- if ( ! options . length && ! options . readUntil ) {
610- throw new Error ( "length or readUntil must be defined for wrapped." ) ;
608+ wrapped ( varName : string | ParserOptions , options ?: ParserOptions ) : this {
609+ if ( typeof options !== "object" && typeof varName === "object" ) {
610+ options = varName ;
611+ varName = "" ;
611612 }
612613
613- if ( ! options . wrapper || ! options . type ) {
614+ if ( ! options || ! options . wrapper || ! options . type ) {
614615 throw new Error ( "Both wrapper and type must be defined for wrapped." ) ;
615616 }
616617
617- return this . setNextParser ( "wrapper" , varName , options ) ;
618+ if ( ! options . length && ! options . readUntil ) {
619+ throw new Error ( "length or readUntil must be defined for wrapped." ) ;
620+ }
621+
622+ return this . setNextParser ( "wrapper" , varName as string , options ) ;
618623 }
619624
620625 array ( varName : string , options : ParserOptions ) : this {
You can’t perform that action at this time.
0 commit comments