From d7610011a28a9dfc0f295dd8032d435d6dd15c69 Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 25 Nov 2024 17:04:00 -0600 Subject: [PATCH] chore: docs --- README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 430ec30..2ce907d 100644 --- a/README.md +++ b/README.md @@ -59,13 +59,8 @@ On the client: socket.on('player-data', (buffer) => { // create a view over the buffer const view = new DataView(buffer); - // pass the view to the decoder - const decoded = playerSchema.decode(view); - // the decoder returns the number of bytes read and the value - console.log(decoded); // {read: 22, value: {...}} - const player = decoded.value; - // or if you're feeling elegant, - const {value: player} = playerSchema.decode(new DataView(buffer)); + // pass the view to the decoder to get the value + const player = playerSchema.decode(view); } ``` @@ -160,8 +155,9 @@ class YourCodec { decode(view: DataView, target: {byteOffset: number}): any // return the number of bytes written - encode(value: any, view: DataView, byteOffset): number + encode(value: any, view: DataView, byteOffset: number): number + // get the encoded size of a value size(value: any): number }