From 47be6d7769cde921eb919431d3aa74a6c00f1be5 Mon Sep 17 00:00:00 2001 From: foomoon Date: Sat, 16 Dec 2023 13:02:42 -0600 Subject: [PATCH] arraybuffer fix --- dist/lib/frame.js | 3 ++- src/lib/frame.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/lib/frame.js b/dist/lib/frame.js index b9a2787..26b5d40 100644 --- a/dist/lib/frame.js +++ b/dist/lib/frame.js @@ -21,7 +21,8 @@ export class Frame { * @returns {Uint8Array} */ toOctet() { - let output = new Uint8Array(this.leds.length * 3); + let buffer = new ArrayBuffer(this.leds.length * 3); + let output = new Uint8Array(buffer); let offset = 0; this.leds.forEach((led) => { output.set(led.toOctet(), offset); diff --git a/src/lib/frame.ts b/src/lib/frame.ts index d652f3f..453c0c2 100644 --- a/src/lib/frame.ts +++ b/src/lib/frame.ts @@ -26,7 +26,8 @@ export class Frame { * @returns {Uint8Array} */ toOctet(): Uint8Array { - let output = new Uint8Array(this.leds.length * 3); + let buffer = new ArrayBuffer(this.leds.length * 3); + let output = new Uint8Array(buffer); let offset = 0; this.leds.forEach((led) => { output.set(led.toOctet(), offset);