Skip to content

Commit

Permalink
Check for existence of globalThis before using, #78
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Apr 28, 2023
1 parent 58ca4ee commit 5de14a4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ try {
textEncoder = new TextEncoder()
} catch (error) {}
let extensions, extensionClasses
const Buffer = globalThis.Buffer
const Buffer = typeof globalThis === 'object' && globalThis.Buffer;
const hasNodeBuffer = typeof Buffer !== 'undefined'
const ByteArrayAllocate = hasNodeBuffer ? Buffer.allocUnsafeSlow : Uint8Array
const ByteArray = hasNodeBuffer ? Buffer : Uint8Array
Expand Down

0 comments on commit 5de14a4

Please sign in to comment.