mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
PR-URL: https://github.com/nodejs/node/pull/46811 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
42 lines
828 B
JavaScript
42 lines
828 B
JavaScript
'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,
|
|
};
|