Skip to content

Commit

Permalink
fix: use isBuffer to prevent importing entire buffer lib
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jul 4, 2024
1 parent d79e6c0 commit 211334a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 211334a

Please sign in to comment.