From a5fab1cef7d5b60efed3e90bcfbd4692484e2492 Mon Sep 17 00:00:00 2001 From: neonp Date: Tue, 2 Jan 2024 06:38:44 +0000 Subject: [PATCH] fix: length const --- packages/protocol-parser/src/parsers/buffer-preparsed.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/protocol-parser/src/parsers/buffer-preparsed.ts b/packages/protocol-parser/src/parsers/buffer-preparsed.ts index e1ee9fbd20..c0cd54aa33 100644 --- a/packages/protocol-parser/src/parsers/buffer-preparsed.ts +++ b/packages/protocol-parser/src/parsers/buffer-preparsed.ts @@ -12,7 +12,8 @@ export default class PreparsedLengthBuffer implements P if (cursor.subByteOffset > 0) throw new Error('Cross byte value are not supported'); - const result = buffer.subarray(cursor.offset, cursor.offset + Number(message[this.lengthProperty])); + const length = Number(message[this.lengthProperty]); + const result = buffer.subarray(cursor.offset, cursor.offset + length); cursor.offset += length; return result; }