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

Function alloc

bitcore-message.js:463–477  ·  view source on GitHub ↗
(that, size, fill, encoding)

Source from the content-addressed store, hash-verified

461}
462
463function alloc (that, size, fill, encoding) {
464 assertSize(size)
465 if (size <= 0) {
466 return createBuffer(that, size)
467 }
468 if (fill !== undefined) {
469 // Only pay attention to encoding if it's a string. This
470 // prevents accidentally sending in a number that would
471 // be interpretted as a start offset.
472 return typeof encoding === 'string'
473 ? createBuffer(that, size).fill(fill, encoding)
474 : createBuffer(that, size).fill(fill)
475 }
476 return createBuffer(that, size)
477}
478
479/**
480 * Creates a new filled Buffer instance.

Callers 1

bitcore-message.jsFile · 0.85

Calls 2

assertSizeFunction · 0.85
createBufferFunction · 0.85

Tested by

no test coverage detected