From 7ab54e6bdf8721dca2d4283d832329ce946f4e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 18 Feb 2024 13:56:49 +0100 Subject: [PATCH] util: hoist TextDecoder out --- src/util/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/index.js b/src/util/index.js index fb9077b..8f6e128 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -62,9 +62,10 @@ export function mux(uxn, devices) { function withLineBuffer(fn) { /** @type {number[]} */ let buffer = []; + const decoder = new TextDecoder(); const flush = () => { if (buffer.length > 0) { - fn(new TextDecoder().decode(Uint8Array.from(buffer))); + fn(decoder.decode(Uint8Array.from(buffer))); buffer = []; } };