] = this;
    handle.onread = onStreamRead;
  }

  _read() {
    if (this[kHandle])
      this[kHandle].readStart();
  }

  _destroy() {
    // Release the references on the handle so that
    // it can be garbage collected.
    this[kHandle][owner_symbol] = undefined;
    this[kHandle] = undefined;
  }

  [kUpdateTimer]() {
    // Does nothing
  }
}

const inspectOptions = {
  __proto__: null,
  depth: 0,
};
function queryObjects(ctor, options = kEmptyObject) {
  validateFunction(ctor, 'constructor');
  if (options !== kEmptyObject) {
    validateObject(options, 'options');
  }
  const format = options.format || 'count';
  if (format !== 'count' && format !== 'summary') {
    throw new ERR_INVALID_ARG_VALUE('options.format', format);
  }
  emitExperimentalWarning('v8.queryObjects()');
  // Matching the console API behavior - just access the .prototype.
  const objects = _queryObjects(ctor.prototype);
  if (format === 'count') {
    return objects.length;
  }
  // options.format is 'summary'.
  return ArrayPrototypeMap(objects, (object) => inspect(object, inspectOptions));
}

module.exports = {
  getHeapSnapshotOptions,
  HeapSnapshotStream,
  queryObjects,
};
