Skip to content

Commit

Permalink
util: hoist TextDecoder out
Browse files Browse the repository at this point in the history
  • Loading branch information
remko committed Feb 18, 2024
1 parent 216113d commit 7ab54e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
};
Expand Down

0 comments on commit 7ab54e6

Please sign in to comment.