File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,22 @@ Parse a `Buffer`/`Uint8Array` object `buffer` with this parser and return the
9595resulting object. When ` parse(buffer) ` is called for the first time, the
9696associated parser code is compiled on-the-fly and internally cached.
9797
98+ ### encode(object)
99+ Encode an object ` object ` with this parser and return the resulting buffer.
100+
101+ ``` typescript
102+ const parser = new Parser ()
103+ .int8 (' age' )
104+ .string (' name' , { zeroTerminated: true });
105+
106+ const buffer = parser .encode ({
107+ age: 25 ,
108+ name: ' John'
109+ });
110+
111+ // Results in: <Buffer 19 4a 6f 68 6e 00>
112+ ```
113+
98114### create(constructorFunction)
99115Set the constructor function that should be called to create the object
100116returned from the ` parse ` method.
You can’t perform that action at this time.
0 commit comments