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

Method _readHostObject

lib/v8.js:475–494  ·  view source on GitHub ↗

* Used to read some kind of host object, i.e. an * object that is created by native C++ bindings. * @returns {any}

()

Source from the content-addressed store, hash-verified

473 * @returns {any}
474 */
475 _readHostObject() {
476 const typeIndex = this.readUint32();
477 const ctor = arrayBufferViewIndexToType(typeIndex);
478 const byteLength = this.readUint32();
479 const byteOffset = this._readRawBytes(byteLength);
480 const BYTES_PER_ELEMENT = ctor.BYTES_PER_ELEMENT || 1;
481
482 const offset = this.buffer.byteOffset + byteOffset;
483 if (offset % BYTES_PER_ELEMENT === 0) {
484 return new ctor(this.buffer.buffer,
485 offset,
486 byteLength / BYTES_PER_ELEMENT);
487 }
488 // Copy to an aligned buffer first.
489 const buffer_copy = Buffer.allocUnsafe(byteLength);
490 buffer_copy.set(new Uint8Array(this.buffer.buffer, this.buffer.byteOffset + byteOffset, byteLength));
491 return new ctor(buffer_copy.buffer,
492 buffer_copy.byteOffset,
493 byteLength / BYTES_PER_ELEMENT);
494 }
495}
496
497/**

Callers

nothing calls this directly

Calls 2

setMethod · 0.45

Tested by

no test coverage detected