@nitedani/inspector-api
Advanced tools
Comparing version 0.0.1 to 0.0.2
/// <reference types="node" /> | ||
import { Session } from "inspector"; | ||
import { PassThrough } from "stream"; | ||
export default class Heap { | ||
@@ -11,4 +12,4 @@ session: Session; | ||
startTimeline(): Promise<void>; | ||
stopTimeline(): Promise<string>; | ||
takeSnapshot(): Promise<string>; | ||
stopTimeline(): PassThrough; | ||
takeSnapshot(): PassThrough; | ||
} |
@@ -23,2 +23,3 @@ "use strict"; | ||
const utils = __importStar(require("./utils")); | ||
const stream_1 = require("stream"); | ||
class Heap { | ||
@@ -45,32 +46,34 @@ session; | ||
stopTimeline() { | ||
return new Promise((resolve, reject) => { | ||
const res = []; | ||
const getChunk = (m) => { | ||
res.push(m.params.chunk); | ||
}; | ||
this.session.on("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
this.session.post("HeapProfiler.stopTrackingHeapObjects", (err) => { | ||
this.session.removeListener("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
if (err) | ||
return reject(err); | ||
resolve(res.join("")); | ||
}); | ||
const stream = new stream_1.PassThrough(); | ||
const getChunk = (m) => { | ||
stream.push(m.params.chunk); | ||
}; | ||
this.session.on("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
this.session.post("HeapProfiler.stopTrackingHeapObjects", (err) => { | ||
this.session.removeListener("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
stream.emit("finish"); | ||
stream.emit("end"); | ||
stream.end(); | ||
if (err) | ||
throw err; | ||
}); | ||
return stream; | ||
} | ||
takeSnapshot() { | ||
return new Promise((resolve, reject) => { | ||
const res = []; | ||
const getChunk = (m) => { | ||
res.push(m.params.chunk); | ||
}; | ||
this.session.on("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
this.session.post("HeapProfiler.takeHeapSnapshot", undefined, (err, _r) => { | ||
this.session.removeListener("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
if (err) | ||
return reject(err); | ||
resolve(res.join("")); | ||
}); | ||
const stream = new stream_1.PassThrough(); | ||
const getChunk = (m) => { | ||
stream.push(m.params.chunk); | ||
}; | ||
this.session.on("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
this.session.post("HeapProfiler.takeHeapSnapshot", (err, _r) => { | ||
this.session.removeListener("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
stream.emit("finish"); | ||
stream.emit("end"); | ||
stream.end(); | ||
if (err) | ||
throw err; | ||
}); | ||
return stream; | ||
} | ||
} | ||
exports.default = Heap; |
/// <reference types="node" /> | ||
import { Session } from "inspector"; | ||
import { PassThrough } from "stream"; | ||
export default class Heap { | ||
@@ -11,4 +12,4 @@ session: Session; | ||
startTimeline(): Promise<void>; | ||
stopTimeline(): Promise<string>; | ||
takeSnapshot(): Promise<string>; | ||
stopTimeline(): PassThrough; | ||
takeSnapshot(): PassThrough; | ||
} |
import * as utils from "./utils"; | ||
import { PassThrough } from "stream"; | ||
export default class Heap { | ||
@@ -23,31 +24,33 @@ session; | ||
stopTimeline() { | ||
return new Promise((resolve, reject) => { | ||
const res = []; | ||
const getChunk = (m) => { | ||
res.push(m.params.chunk); | ||
}; | ||
this.session.on("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
this.session.post("HeapProfiler.stopTrackingHeapObjects", (err) => { | ||
this.session.removeListener("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
if (err) | ||
return reject(err); | ||
resolve(res.join("")); | ||
}); | ||
const stream = new PassThrough(); | ||
const getChunk = (m) => { | ||
stream.push(m.params.chunk); | ||
}; | ||
this.session.on("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
this.session.post("HeapProfiler.stopTrackingHeapObjects", (err) => { | ||
this.session.removeListener("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
stream.emit("finish"); | ||
stream.emit("end"); | ||
stream.end(); | ||
if (err) | ||
throw err; | ||
}); | ||
return stream; | ||
} | ||
takeSnapshot() { | ||
return new Promise((resolve, reject) => { | ||
const res = []; | ||
const getChunk = (m) => { | ||
res.push(m.params.chunk); | ||
}; | ||
this.session.on("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
this.session.post("HeapProfiler.takeHeapSnapshot", undefined, (err, _r) => { | ||
this.session.removeListener("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
if (err) | ||
return reject(err); | ||
resolve(res.join("")); | ||
}); | ||
const stream = new PassThrough(); | ||
const getChunk = (m) => { | ||
stream.push(m.params.chunk); | ||
}; | ||
this.session.on("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
this.session.post("HeapProfiler.takeHeapSnapshot", (err, _r) => { | ||
this.session.removeListener("HeapProfiler.addHeapSnapshotChunk", getChunk); | ||
stream.emit("finish"); | ||
stream.emit("end"); | ||
stream.end(); | ||
if (err) | ||
throw err; | ||
}); | ||
return stream; | ||
} | ||
} |
{ | ||
"name": "@nitedani/inspector-api", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"bin": "./index.js", | ||
@@ -5,0 +5,0 @@ "types": "./index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15346
402
1