MCPcopy Index your code
hub / github.com/nodejs/node / fromArrayBuffer

Function fromArrayBuffer

lib/buffer.js:525–552  ·  view source on GitHub ↗
(obj, byteOffset, length)

Source from the content-addressed store, hash-verified

523}
524
525function fromArrayBuffer(obj, byteOffset, length) {
526 // Convert byteOffset to integer
527 if (byteOffset === undefined) {
528 byteOffset = 0;
529 } else {
530 byteOffset = +byteOffset;
531 if (NumberIsNaN(byteOffset))
532 byteOffset = 0;
533 }
534
535 const maxLength = obj.byteLength - byteOffset;
536
537 if (maxLength < 0)
538 throw new ERR_BUFFER_OUT_OF_BOUNDS('offset');
539
540 if (length !== undefined) {
541 // Convert length to non-negative integer.
542 length = +length;
543 if (length > 0) {
544 if (length > maxLength)
545 throw new ERR_BUFFER_OUT_OF_BOUNDS('length');
546 } else {
547 length = 0;
548 }
549 }
550
551 return new FastBuffer(obj, byteOffset, length);
552}
553
554function fromArrayLike(obj) {
555 const { length } = obj;

Callers 1

buffer.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…