How to use the isBuffer function from safe-buffer

Find comprehensive JavaScript safe-buffer.isBuffer code examples handpicked from public code repositorys.

219
220
221
222
223
224
225
226
227
var OurUint8Array = global.Uint8Array || function () {};
function _uint8ArrayToBuffer(chunk) {
  return Buffer.from(chunk);
}
function _isUint8Array(obj) {
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
}

/*</replacement>*/
fork icon95
star icon0
watch icon1

2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
         typeof arg === 'symbol' ||  // ES6 symbol
         typeof arg === 'undefined';
}
exports.isPrimitive = isPrimitive;


exports.isBuffer = Buffer.isBuffer;


function objectToString(o) {
  return Object.prototype.toString.call(o);
}
fork icon0
star icon4
watch icon0

+ 23 other calls in file

1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
if (typeof val === 'number') {
  for (i = start; i < end; ++i) {
    this[i] = val
  }
} else {
  var bytes = Buffer.isBuffer(val)
    ? val
    : Buffer.from(val, encoding)
  var len = bytes.length
  if (len === 0) {
fork icon0
star icon4
watch icon0

+ 27 other calls in file

3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
} else if (clone.__isRegExp(parent)) {
	child = new RegExp(parent.source, __getRegExpFlags(parent));
	if (parent.lastIndex) child.lastIndex = parent.lastIndex;
} else if (clone.__isDate(parent)) {
	child = new Date(parent.getTime());
} else if (useBuffer && Buffer.isBuffer(parent)) {
	if (Buffer.allocUnsafe) {
		// Node.js >= 4.5.0
		child = Buffer.allocUnsafe(parent.length);
	} else {
fork icon1
star icon3
watch icon2

+ 2 other calls in file

1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
  }
};
req.setHtml = function (html) {
  if (!html || html == null) {
    htmlBody = null;
  } else if (typeof html === 'string' || Buffer.isBuffer(html)) {
    htmlBody = html;
    location = null;
    htmlUrl = null;
  }
fork icon0
star icon0
watch icon1

+ 8 other calls in file

366
367
368
369
370
371
372
373
374
375
376
  return qs.stringify(query);
}


exports.toBuffer = function(data, req) {
  data = queryToString(data, req);
  if (!data || Buffer.isBuffer(data)) {
    return data && data.length && data;
  }
  if (typeof data !== 'string') {
    try {
fork icon0
star icon0
watch icon1

+ 8 other calls in file

3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
})

SAXStream.prototype.write = function (data) {
  if (typeof Buffer === 'function' &&
    typeof Buffer.isBuffer === 'function' &&
    Buffer.isBuffer(data)) {
    if (!this._decoder) {
      var SD = require('string_decoder').StringDecoder
      this._decoder = new SD('utf8')
    }
fork icon0
star icon0
watch icon1

+ 31 other calls in file