@@ -442,21 +442,27 @@ const buffer = Buffer.from([2, /* left */ 1, 1, 0, /* right */ 0]);
442442parser .parse (buffer);
443443```
444444
445- ### wrapped(name[ , options] )
446- Read data then wrap it by transforming it by a function for further parsing.
447- It works similarly to a buffer where it reads a block of data. But instead of returning the buffer it
448- will pass it on to a parser for further processing.
449- - ` wrapper ` - (Required) A function taking a buffer and returning a buffer (` (x: Buffer | Uint8Array ) => Buffer | Uint8Array ` )
450- transforming the buffer into a buffer expected by ` type ` .
451- - ` type ` - (Required) A ` Parser ` object to parse the result of wrapper.
445+ ### wrapped([ name,] options)
446+ Read data, then wrap it by transforming it by a function for further parsing.
447+ It works similarly to a buffer where it reads a block of data. But instead of
448+ returning the buffer it will pass the buffer on to a parser for further processing.
449+
450+ The result will be stored in the key ` name ` . If ` name ` is an empty string or
451+ ` null ` , or if it is omitted, the parsed result is directly embedded into the
452+ current object.
453+
454+ - ` wrapper ` - (Required) A function taking a buffer and returning a buffer
455+ (` (x: Buffer | Uint8Array ) => Buffer | Uint8Array ` ) transforming the buffer
456+ into a buffer expected by ` type ` .
457+ - ` type ` - (Required) A ` Parser ` object to parse the buffer returned by ` wrapper ` .
452458- ` length ` - (either ` length ` or ` readUntil ` is required) Length of the
453- buffer. Can be a number, string or a function. Use number for statically
454- sized buffers, string to reference another variable and function to do some
459+ buffer. Can be a number, string or a function. Use a number for statically
460+ sized buffers, a string to reference another variable and a function to do some
455461 calculation.
456462- ` readUntil ` - (either ` length ` or ` readUntil ` is required) If ` "eof" ` , then
457463 this parser will read till it reaches the end of the ` Buffer ` /` Uint8Array `
458464 object. If it is a function, this parser will read the buffer until the
459- function returns true.
465+ function returns ` true ` .
460466
461467``` javascript
462468const zlib = require (" zlib" );
@@ -478,9 +484,10 @@ const mainParser = Parser.start()
478484 // E.g. decompress data and return it for further parsing
479485 return zlib .inflateRawSync (buffer);
480486 },
481- // The parser to run the dec
487+ // The parser to run on the decompressed data
482488 type: textParser,
483489 });
490+
484491mainParser .parse (buffer);
485492```
486493
0 commit comments