MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / fromArrayBuffer

Function fromArrayBuffer

lib/models/dav.js:2117–2145  ·  view source on GitHub ↗
(that, array, byteOffset, length)

Source from the content-addressed store, hash-verified

2115}
2116
2117function fromArrayBuffer (that, array, byteOffset, length) {
2118 array.byteLength; // this throws if `array` is not a valid ArrayBuffer
2119
2120 if (byteOffset < 0 || array.byteLength < byteOffset) {
2121 throw new RangeError('\'offset\' is out of bounds')
2122 }
2123
2124 if (array.byteLength < byteOffset + (length || 0)) {
2125 throw new RangeError('\'length\' is out of bounds')
2126 }
2127
2128 if (byteOffset === undefined && length === undefined) {
2129 array = new Uint8Array(array);
2130 } else if (length === undefined) {
2131 array = new Uint8Array(array, byteOffset);
2132 } else {
2133 array = new Uint8Array(array, byteOffset, length);
2134 }
2135
2136 if (Buffer.TYPED_ARRAY_SUPPORT) {
2137 // Return an augmented `Uint8Array` instance, for best performance
2138 that = array;
2139 that.__proto__ = Buffer.prototype;
2140 } else {
2141 // Fallback: Return an object instance of the Buffer class
2142 that = fromArrayLike(that, array);
2143 }
2144 return that
2145}
2146
2147function fromObject (that, obj) {
2148 if (internalIsBuffer(obj)) {

Callers 1

fromFunction · 0.85

Calls 1

fromArrayLikeFunction · 0.85

Tested by

no test coverage detected