From 21584fceee9d717ffb7483855bc750d1ead4553e Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Tue, 23 Feb 2021 17:32:54 +0100 Subject: [PATCH] fix: Buffer not using global in browser (#260) --- lib/bn.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bn.js b/lib/bn.js index f86d196..c9773da 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -50,7 +50,11 @@ var Buffer; try { - Buffer = require('buffer').Buffer; + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } } catch (e) { }