All files / lib/internal heap_utils.js

100% Statements 41/41
100% Branches 5/5
100% Functions 3/3
100% Lines 41/41

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 4223x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 16x 16x 16x 16x 16x 23x 23x 13x 13x 13x 23x 23x 14x 14x 14x 14x 14x 23x 23x 1026x 1026x 23x 23x 23x 23x 23x  
'use strict';
const {
  Symbol
} = primordials;
const {
  kUpdateTimer,
  onStreamRead,
} = require('internal/stream_base_commons');
const { owner_symbol } = require('internal/async_hooks').symbols;
const { Readable } = require('stream');
 
const kHandle = Symbol('kHandle');
 
class HeapSnapshotStream extends Readable {
  constructor(handle) {
    super({ autoDestroy: true });
    this[kHandle] = handle;
    handle[owner_symbol] = 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
  }
}
 
module.exports = {
  HeapSnapshotStream
};