MCPcopy Create free account
hub / github.com/RubyLouvre/anu / fromArrayBuffer

Function fromArrayBuffer

test/babel.js:45950–45978  ·  view source on GitHub ↗
(that, array, byteOffset, length)

Source from the content-addressed store, hash-verified

45948 }
45949
45950 function fromArrayBuffer(that, array, byteOffset, length) {
45951 array.byteLength; // this throws if `array` is not a valid ArrayBuffer
45952
45953 if (byteOffset < 0 || array.byteLength < byteOffset) {
45954 throw new RangeError('\'offset\' is out of bounds');
45955 }
45956
45957 if (array.byteLength < byteOffset + (length || 0)) {
45958 throw new RangeError('\'length\' is out of bounds');
45959 }
45960
45961 if (byteOffset === undefined && length === undefined) {
45962 array = new Uint8Array(array);
45963 } else if (length === undefined) {
45964 array = new Uint8Array(array, byteOffset);
45965 } else {
45966 array = new Uint8Array(array, byteOffset, length);
45967 }
45968
45969 if (Buffer.TYPED_ARRAY_SUPPORT) {
45970 // Return an augmented `Uint8Array` instance, for best performance
45971 that = array;
45972 that.__proto__ = Buffer.prototype;
45973 } else {
45974 // Fallback: Return an object instance of the Buffer class
45975 that = fromArrayLike(that, array);
45976 }
45977 return that;
45978 }
45979
45980 function fromObject(that, obj) {
45981 if (Buffer.isBuffer(obj)) {

Callers 1

fromFunction · 0.85

Calls 1

fromArrayLikeFunction · 0.85

Tested by

no test coverage detected