From bd70cce38fe5bc4f2fb97c8a4a5dc95b43d6835f Mon Sep 17 00:00:00 2001 From: valadaptive Date: Sat, 30 Mar 2024 17:14:34 -0400 Subject: [PATCH] Remove buffer imports --- etc/browser/avsc.js | 5 +---- etc/browser/lib/md5.js | 8 +++----- lib/utils.js | 3 --- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/etc/browser/avsc.js b/etc/browser/avsc.js index f4f38e7e..fbb29af4 100644 --- a/etc/browser/avsc.js +++ b/etc/browser/avsc.js @@ -8,11 +8,8 @@ */ let containers = require('../../lib/containers'), - buffer = require('buffer'), stream = require('stream'); -let Buffer = buffer.Buffer; - /** Transform stream which lazily reads a blob's contents. */ class BlobReader extends stream.Readable { constructor (blob, opts) { @@ -40,7 +37,7 @@ class BlobReader extends stream.Readable { if (evt.error) { self.emit('error', evt.error); } else { - self.push(Buffer.from(reader.result)); + self.push(reader.result); } }, false); reader.readAsArrayBuffer(blob); diff --git a/etc/browser/lib/md5.js b/etc/browser/lib/md5.js index db6ec389..3ff8d8bd 100644 --- a/etc/browser/lib/md5.js +++ b/etc/browser/lib/md5.js @@ -10,9 +10,6 @@ * */ -let buffer = require('buffer'); -let Buffer = buffer.Buffer; - function md5cycle(x, k) { let a = x[0], b = x[1], c = x[2], d = x[3]; @@ -148,9 +145,10 @@ function md5blk(s) { function md5(s) { let arr = md51(s); - let buf = Buffer.alloc(16); + let buf = new Uint8Array(16); + let dv = new DataView(buf.buffer); for (let i = 0; i < 4; i++) { - buf.writeIntLE(arr[i], i * 4, 4); + dv.setInt32(i * 4, arr[i], true); } return buf; } diff --git a/lib/utils.js b/lib/utils.js index a5d4c146..4401501d 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -5,11 +5,8 @@ /** Various utilities used across this library. */ -let buffer = require('buffer'); let platform = require('./platform'); -let Buffer = buffer.Buffer; - // Valid (field, type, and symbol) name regex. const NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;