Skip to content

Commit bdac0af

Browse files
committed
Access global Buffer conditionally
Enables to run the code in environments where the global Buffer is undefined, i.e. in the browsers.
1 parent 4cb9129 commit bdac0af

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function parse (text, reviver, options) {
1717
const protoAction = options.protoAction || 'error'
1818
const constructorAction = options.constructorAction || 'error'
1919

20-
if (Buffer.isBuffer(text)) {
20+
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(text)) {
2121
text = text.toString()
2222
}
2323

0 commit comments

Comments
 (0)