From 68a79e34545f161f8ff7e8d23a8a2b65b886053a Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 20 Mar 2017 12:34:35 -0400 Subject: [PATCH] lib/util/preconditions: Directly use Buffer.isBuffer (Cordova, RN workaround) Using "./buffer" fails on some browserify-esque platforms such as Cordova and React.Native. Fixes #108 --- lib/util/preconditions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util/preconditions.js b/lib/util/preconditions.js index 25a33b0..43afc04 100644 --- a/lib/util/preconditions.js +++ b/lib/util/preconditions.js @@ -18,8 +18,8 @@ module.exports = { argumentName = argumentName || '(unknown name)'; if (_.isString(type)) { if (type === 'Buffer') { - var BufferUtil = require('./buffer'); - if (!BufferUtil.isBuffer(argument)) { + var buffer = require('buffer'); // './buffer' fails on cordova & RN + if (!buffer.Buffer.isBuffer(argument)) { throw new errors.InvalidArgumentType(argument, type, argumentName); } } else if (typeof argument !== type) {