From 8399c9a67ef4b704e6d53dd84ce53e1f7b26584a Mon Sep 17 00:00:00 2001 From: Yadd Date: Wed, 19 Jan 2022 21:07:35 +0100 Subject: [PATCH] Add fix for big-endian platforms (Closes: #85) --- lib/to-buffer.js | 54 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/lib/to-buffer.js b/lib/to-buffer.js index ef0d4d4..1679248 100644 --- a/lib/to-buffer.js +++ b/lib/to-buffer.js @@ -1,12 +1,64 @@ var Buffer = require('safe-buffer').Buffer +function swapBytes(buf, size) { + var bytes = new Uint8Array(buf.slice()); + var len = bytes.length; + var holder; + + if (size == 2) { + //16 bit + for (var i = 0; i