MCPcopy Create free account
hub / github.com/microsoft/SandDance / createBuffer

Function createBuffer

docs/tests/v2/es6/js/sanddance.js:78440–78457  ·  view source on GitHub ↗
(that, length)

Source from the content-addressed store, hash-verified

78438}
78439
78440function createBuffer (that, length) {
78441 if (kMaxLength() < length) {
78442 throw new RangeError('Invalid typed array length')
78443 }
78444 if (Buffer.TYPED_ARRAY_SUPPORT) {
78445 // Return an augmented `Uint8Array` instance, for best performance
78446 that = new Uint8Array(length)
78447 that.__proto__ = Buffer.prototype
78448 } else {
78449 // Fallback: Return an object instance of the Buffer class
78450 if (that === null) {
78451 that = new Buffer(length)
78452 }
78453 that.length = length
78454 }
78455
78456 return that
78457}
78458
78459/**
78460 * The Buffer constructor returns instances of `Uint8Array` that have their

Callers 5

allocFunction · 0.70
allocUnsafeFunction · 0.70
fromStringFunction · 0.70
fromArrayLikeFunction · 0.70
fromObjectFunction · 0.70

Calls 1

kMaxLengthFunction · 0.85

Tested by

no test coverage detected