-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Attempting to decode an array of buffers in a larger buffer seems to fail.
Here is an example:
import { defineFormat, Type } from "tinybuf";
const Entity = defineFormat(6, {
id: Type.String,
});
const GameState = defineFormat(7, {
entities: [Type.Buffer],
});
// Encode
const buffer = GameState.encode({
entities: [
Entity.encode({
id: "e1",
}),
Entity.encode({
id: "e2",
}),
Entity.encode({
id: "e3",
}),
],
});
// Decode
const payload = GameState.decode(buffer);
payload.entities.forEach((entityBuffer, index) => {
payload.entities[index] = Entity.decode(entityBuffer);
});
console.log(payload);
Here is a live example: https://codesandbox.io/p/sandbox/sxdlyg
Metadata
Metadata
Assignees
Labels
No labels