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

Function Buffer

bitcore-message.js:389–404  ·  view source on GitHub ↗

* The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of * `Uint8Array`, so the returned instances will have all the node `Buffer` methods * and the `Uint8Array` methods. Square bracket notation wo

(arg, encodingOrOffset, length)

Source from the content-addressed store, hash-verified

387 */
388
389function Buffer (arg, encodingOrOffset, length) {
390 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
391 return new Buffer(arg, encodingOrOffset, length)
392 }
393
394 // Common case.
395 if (typeof arg === 'number') {
396 if (typeof encodingOrOffset === 'string') {
397 throw new Error(
398 'If encoding is specified then the first argument must be a string'
399 )
400 }
401 return allocUnsafe(this, arg)
402 }
403 return from(this, arg, encodingOrOffset, length)
404}
405
406Buffer.poolSize = 8192 // not used by this implementation
407

Callers

nothing calls this directly

Calls 2

allocUnsafeFunction · 0.85
fromFunction · 0.85

Tested by

no test coverage detected