Skip to content

Commit 211334a

Browse files
committed
fix: use isBuffer to prevent importing entire buffer lib
1 parent d79e6c0 commit 211334a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"boolean": "3.2.0",
2323
"console-polyfill": "0.3.0",
2424
"format-specifiers": "^1.0.0",
25+
"is-buffer": "^2.0.5",
2526
"is-symbol": "^1.0.4",
2627
"iserror": "0.0.2",
2728
"merge-options": "3.0.4",

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const formatSpecifiers = require('format-specifiers');
88
const get = require('@strikeentco/get');
99
const isError = require('iserror');
1010
const isSymbol = require('is-symbol');
11+
const isBuffer = require('is-buffer');
1112
const mergeOptions = require('merge-options');
1213
const pMapSeries = require('p-map-series');
1314
const parseAppInfo = require('parse-app-info');
@@ -50,8 +51,11 @@ function dotifyToArray(obj) {
5051
const res = [];
5152
function recurse(obj, current) {
5253
// if it's a buffer, uint8array, or array
53-
// eslint-disable-next-line n/prefer-global/buffer
54-
if (Buffer.isBuffer(obj) || obj instanceof Uint8Array || Array.isArray(obj))
54+
if (
55+
isBuffer(obj) ||
56+
(obj.constructor && obj.constructor.name === 'Uint8Array') ||
57+
Array.isArray(obj)
58+
)
5559
return;
5660

5761
for (const key of Reflect.ownKeys(obj)) {

0 commit comments

Comments
 (0)