From 211334adcb8e28e7281aa6145588768f12055896 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Wed, 3 Jul 2024 21:05:10 -0500 Subject: [PATCH] fix: use isBuffer to prevent importing entire buffer lib --- package.json | 1 + src/index.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e3b411c..40d8714 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "boolean": "3.2.0", "console-polyfill": "0.3.0", "format-specifiers": "^1.0.0", + "is-buffer": "^2.0.5", "is-symbol": "^1.0.4", "iserror": "0.0.2", "merge-options": "3.0.4", diff --git a/src/index.js b/src/index.js index 780bacf..063e7f9 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,7 @@ const formatSpecifiers = require('format-specifiers'); const get = require('@strikeentco/get'); const isError = require('iserror'); const isSymbol = require('is-symbol'); +const isBuffer = require('is-buffer'); const mergeOptions = require('merge-options'); const pMapSeries = require('p-map-series'); const parseAppInfo = require('parse-app-info'); @@ -50,8 +51,11 @@ function dotifyToArray(obj) { const res = []; function recurse(obj, current) { // if it's a buffer, uint8array, or array - // eslint-disable-next-line n/prefer-global/buffer - if (Buffer.isBuffer(obj) || obj instanceof Uint8Array || Array.isArray(obj)) + if ( + isBuffer(obj) || + (obj.constructor && obj.constructor.name === 'Uint8Array') || + Array.isArray(obj) + ) return; for (const key of Reflect.ownKeys(obj)) {