Browse Source

Merge pull request #126 from jgarzik/2017_browserify_fix

Directly use Buffer.isBuffer (Cordova, RN workaround)
patch-2
Matias Alejo Garcia 8 years ago
committed by GitHub
parent
commit
7b272e0171
  1. 4
      lib/util/preconditions.js

4
lib/util/preconditions.js

@ -18,8 +18,8 @@ module.exports = {
argumentName = argumentName || '(unknown name)'; argumentName = argumentName || '(unknown name)';
if (_.isString(type)) { if (_.isString(type)) {
if (type === 'Buffer') { if (type === 'Buffer') {
var BufferUtil = require('./buffer'); var buffer = require('buffer'); // './buffer' fails on cordova & RN
if (!BufferUtil.isBuffer(argument)) { if (!buffer.Buffer.isBuffer(argument)) {
throw new errors.InvalidArgumentType(argument, type, argumentName); throw new errors.InvalidArgumentType(argument, type, argumentName);
} }
} else if (typeof argument !== type) { } else if (typeof argument !== type) {

Loading…
Cancel
Save