MCPcopy Create free account
hub / github.com/bitpay/bitcore-message / createBuffer

Function createBuffer

bitcore-message.js:360–377  ·  view source on GitHub ↗
(that, length)

Source from the content-addressed store, hash-verified

358}
359
360function createBuffer (that, length) {
361 if (kMaxLength() < length) {
362 throw new RangeError('Invalid typed array length')
363 }
364 if (Buffer.TYPED_ARRAY_SUPPORT) {
365 // Return an augmented `Uint8Array` instance, for best performance
366 that = new Uint8Array(length)
367 that.__proto__ = Buffer.prototype
368 } else {
369 // Fallback: Return an object instance of the Buffer class
370 if (that === null) {
371 that = new Buffer(length)
372 }
373 that.length = length
374 }
375
376 return that
377}
378
379/**
380 * The Buffer constructor returns instances of `Uint8Array` that have their

Callers 5

allocFunction · 0.85
allocUnsafeFunction · 0.85
fromStringFunction · 0.85
fromArrayLikeFunction · 0.85
fromObjectFunction · 0.85

Calls 1

kMaxLengthFunction · 0.85

Tested by

no test coverage detected