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

Function fromArrayBuffer

docs/app/js/sanddance-app.js:113025–113035  ·  view source on GitHub ↗
(array, byteOffset, length)

Source from the content-addressed store, hash-verified

113023 return fromArrayLike(arrayView);
113024}
113025function fromArrayBuffer(array, byteOffset, length) {
113026 if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError('"offset" is outside of buffer bounds');
113027 if (array.byteLength < byteOffset + (length || 0)) throw new RangeError('"length" is outside of buffer bounds');
113028 var buf;
113029 if (byteOffset === undefined && length === undefined) buf = new Uint8Array(array);
113030 else if (length === undefined) buf = new Uint8Array(array, byteOffset);
113031 else buf = new Uint8Array(array, byteOffset, length);
113032 // Return an augmented `Uint8Array` instance
113033 Object.setPrototypeOf(buf, Buffer.prototype);
113034 return buf;
113035}
113036function fromObject(obj) {
113037 if (Buffer.isBuffer(obj)) {
113038 var len = checked(obj.length) | 0;

Callers 2

fromFunction · 0.70
fromArrayViewFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected