{"_id":"heap-snapshot-toolkit","_rev":"5-2f5c13f868cb076e7bc2c45bff788036","name":"heap-snapshot-toolkit","dist-tags":{"latest":"1.1.3"},"versions":{"1.0.0":{"name":"heap-snapshot-toolkit","version":"1.0.0","keywords":["heap","snapshot","heapsnapshot","parser","memory"],"author":{"name":"Nolan Lawson","email":"nolan@nolanlawson.com"},"license":"Apache-2.0","_id":"heap-snapshot-toolkit@1.0.0","maintainers":[{"name":"nolanlawson","email":"nolan@nolanlawson.com"}],"homepage":"https://github.com/nolanlawson/heap-snapshot-toolkit#readme","bugs":{"url":"https://github.com/nolanlawson/heap-snapshot-toolkit/issues"},"dist":{"shasum":"7868b0513967f1c1233d24249f029196a0315800","tarball":"https://registry.npmjs.org/heap-snapshot-toolkit/-/heap-snapshot-toolkit-1.0.0.tgz","fileCount":1051,"integrity":"sha512-4HpMbY0VWumPtAeP5Bkwmv8Dmz0O8fE/rypGQ+bVJfU9nodsR0ZXruzBVbMKjCV8MwyoTDWdcIilYpos740+ig==","signatures":[{"sig":"MEUCICp1Y0mXp1is/7RdWJcLELhLfJSqABTEuwU2gePYWqwKAiEAwkAC629eA0BDn2NGJvYy/qIXs9sjrEF0u6eKJv5n4So=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3673258},"main":"index.js","type":"module","types":"index.d.ts","engines":{"node":">= 18.0.0"},"gitHead":"377c58ed9cc126f421881cf7e6c67f61cf5c7f4c","scripts":{"lint":"standard","test":"node --test ./test/*.test.js","build":"bash ./scripts/build-devtools-frontend.sh"},"_npmUser":{"name":"nolanlawson","email":"nolan@nolanlawson.com"},"standard":{"ignore":["thirdparty"]},"repository":{"url":"git+https://github.com/nolanlawson/heap-snapshot-toolkit.git","type":"git"},"_npmVersion":"10.9.2","description":"Tools for parsing Chromium heap snapshot (`*.heapsnapshot`) files and doing useful things with them","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677","devDependencies":{"tsr":"^1.3.4","chai":"^5.2.0","rollup":"^4.40.0","standard":"^17.1.2","@types/node":"^22.14.1","@rollup/plugin-strip":"^3.0.4","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-replace":"^6.0.2","@rollup/plugin-virtual":"^3.0.2","@rollup/plugin-typescript":"^12.1.2","node-readable-to-web-readable-stream":"^0.4.2"},"_npmOperationalInternal":{"tmp":"tmp/heap-snapshot-toolkit_1.0.0_1745087553304_0.319001722623677","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"heap-snapshot-toolkit","version":"1.1.0","keywords":["heap","snapshot","heapsnapshot","parser","memory"],"author":{"name":"Nolan Lawson","email":"nolan@nolanlawson.com"},"license":"Apache-2.0","_id":"heap-snapshot-toolkit@1.1.0","maintainers":[{"name":"nolanlawson","email":"nolan@nolanlawson.com"}],"homepage":"https://github.com/nolanlawson/heap-snapshot-toolkit#readme","bugs":{"url":"https://github.com/nolanlawson/heap-snapshot-toolkit/issues"},"dist":{"shasum":"7b05332d220501f082056be428895ce855a95f76","tarball":"https://registry.npmjs.org/heap-snapshot-toolkit/-/heap-snapshot-toolkit-1.1.0.tgz","fileCount":712,"integrity":"sha512-3Kebe+KohQQgvdRU2TRdYspB1B+jYrGu4T3oIGruOXtgCbOv2LKH1ME3Xou9YRNRWNujtXN23qMCnYaqquBPvw==","signatures":[{"sig":"MEQCICEq+uqlV21J0sRyuL3csZGbhoAh8d4cvTQ/Q+PXo6rnAiAnanBQF7LWo5F9tOQbD4ZyDAV01QUdBDVPaLN4Pt3JLw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3139041},"main":"index.js","type":"module","types":"index.d.ts","engines":{"node":">= 18.0.0"},"gitHead":"aba104e50fa4102392d3d89b690d9f562c9d8d80","scripts":{"lint":"standard","test":"node --test ./test/*.test.js","build":"bash ./scripts/build-devtools-frontend.sh"},"_npmUser":{"name":"nolanlawson","email":"nolan@nolanlawson.com"},"standard":{"ignore":["thirdparty"]},"repository":{"url":"git+https://github.com/nolanlawson/heap-snapshot-toolkit.git","type":"git"},"_npmVersion":"10.9.2","description":"Tools for parsing Chromium heap snapshot (`*.heapsnapshot`) files and doing useful things with them","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677","devDependencies":{"tsr":"^1.3.4","chai":"^5.2.0","rollup":"^4.40.0","standard":"^17.1.2","@types/node":"^22.14.1","@rollup/plugin-strip":"^3.0.4","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-replace":"^6.0.2","@rollup/plugin-virtual":"^3.0.2","@rollup/plugin-typescript":"^12.1.2","node-readable-to-web-readable-stream":"^0.4.2"},"_npmOperationalInternal":{"tmp":"tmp/heap-snapshot-toolkit_1.1.0_1745091754640_0.6779345077982593","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"heap-snapshot-toolkit","version":"1.1.1","keywords":["heap","snapshot","heapsnapshot","parser","memory"],"author":{"name":"Nolan Lawson","email":"nolan@nolanlawson.com"},"license":"Apache-2.0","_id":"heap-snapshot-toolkit@1.1.1","maintainers":[{"name":"nolanlawson","email":"nolan@nolanlawson.com"}],"homepage":"https://github.com/nolanlawson/heap-snapshot-toolkit#readme","bugs":{"url":"https://github.com/nolanlawson/heap-snapshot-toolkit/issues"},"dist":{"shasum":"a8996aa903f4618ff4c74df1a5ce282345d220ed","tarball":"https://registry.npmjs.org/heap-snapshot-toolkit/-/heap-snapshot-toolkit-1.1.1.tgz","fileCount":10,"integrity":"sha512-ADVGavuIA9m80St1NgDqt26xqPeNr8WlDEqxsepZLXM26PD2LyfV74wwhkAPFz6lki6pyMFW4UFhYmCmGYzV6g==","signatures":[{"sig":"MEUCIGQXVKd71JuHf3MSYrWUwIQD7NI1hdA0qVqCuJceUB6jAiEA7HUZG1vXXveP3ybHoJ1pNjzTI+ekxEavLG5R3iiEFbk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":708712},"main":"index.js","type":"module","types":"index.d.ts","engines":{"node":">= 18.0.0"},"gitHead":"ce40c20ab3a1692a79423172e28244828123b818","scripts":{"lint":"standard","test":"node --test ./test/*.test.js","build":"bash ./scripts/build-devtools-frontend.sh"},"_npmUser":{"name":"nolanlawson","email":"nolan@nolanlawson.com"},"standard":{"ignore":["thirdparty"]},"repository":{"url":"git+https://github.com/nolanlawson/heap-snapshot-toolkit.git","type":"git"},"_npmVersion":"10.9.2","description":"Tools for parsing Chromium heap snapshot (`*.heapsnapshot`) files and doing useful things with them","directories":{},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677","devDependencies":{"chai":"^5.2.0","rollup":"^4.40.0","standard":"^17.1.2","@types/node":"^22.14.1","@rollup/plugin-strip":"^3.0.4","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-replace":"^6.0.2","@rollup/plugin-virtual":"^3.0.2","@microsoft/api-extractor":"^7.52.5","@rollup/plugin-typescript":"^12.1.2","node-readable-to-web-readable-stream":"^0.4.2"},"_npmOperationalInternal":{"tmp":"tmp/heap-snapshot-toolkit_1.1.1_1745700604864_0.6262821043356199","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"heap-snapshot-toolkit","version":"1.1.2","keywords":["heap","snapshot","heapsnapshot","parser","memory"],"author":{"name":"Nolan Lawson","email":"nolan@nolanlawson.com"},"license":"Apache-2.0","_id":"heap-snapshot-toolkit@1.1.2","maintainers":[{"name":"nolanlawson","email":"nolan@nolanlawson.com"}],"homepage":"https://github.com/nolanlawson/heap-snapshot-toolkit#readme","bugs":{"url":"https://github.com/nolanlawson/heap-snapshot-toolkit/issues"},"dist":{"shasum":"07d7063db0cf9cfc51c8f556feb77741f5777531","tarball":"https://registry.npmjs.org/heap-snapshot-toolkit/-/heap-snapshot-toolkit-1.1.2.tgz","fileCount":10,"integrity":"sha512-PRN5gL6vy0ni40w2DH9DLtTKSGNQRW8ZP77AXuIuNFO1MDABxN9oA5ZgyHY3hOqpU3iVXWYeSYVmp0269wZPiw==","signatures":[{"sig":"MEUCICB4tlkEEoMAbutQUNUEXRk1TIoO98lJkSPCDM5HDHPLAiEA8d4IPLhObjMNFPXTanhPPfJx5rCMaxRTOJr+a94S+Rw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":707784},"main":"index.js","pnpm":{"overrides":{"typescript":"^5.8.3"},"patchedDependencies":{"@rollup/plugin-typescript@12.1.2":"patches/@rollup__plugin-typescript@12.1.2.patch"}},"type":"module","types":"index.d.ts","engines":{"node":">= 18.0.0"},"gitHead":"aa803722476f3a411ab9518757db7a851d622edf","scripts":{"lint":"standard","test":"node --run test:types && node --run test:unit","build":"bash ./scripts/build-devtools-frontend.sh","test:unit":"node --test ./test/*.test.js","test:types":"attw --ignore-rules cjs-resolves-to-esm --pack ."},"_npmUser":{"name":"nolanlawson","actor":{"name":"nolanlawson","type":"user","email":"nolan@nolanlawson.com"},"email":"nolan@nolanlawson.com"},"standard":{"ignore":["thirdparty"]},"repository":{"url":"git+https://github.com/nolanlawson/heap-snapshot-toolkit.git","type":"git"},"_npmVersion":"10.9.2","description":"Tools for parsing Chromium heap snapshot (`*.heapsnapshot`) files and doing useful things with them","directories":{},"_nodeVersion":"22.17.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977","devDependencies":{"chai":"^5.2.0","rollup":"^4.40.2","standard":"^17.1.2","@types/node":"^22.15.18","@rollup/plugin-strip":"^3.0.4","@arethetypeswrong/cli":"^0.18.2","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-replace":"^6.0.2","@rollup/plugin-virtual":"^3.0.2","@microsoft/api-extractor":"^7.52.8","@rollup/plugin-typescript":"^12.1.2","node-readable-to-web-readable-stream":"^0.4.2"},"_npmOperationalInternal":{"tmp":"tmp/heap-snapshot-toolkit_1.1.2_1751823370722_0.40704344576080587","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"heap-snapshot-toolkit","version":"1.1.3","main":"index.js","type":"module","types":"index.d.ts","scripts":{"lint":"standard","test":"node --run test:types && node --run test:unit","test:types":"attw --ignore-rules cjs-resolves-to-esm --pack .","test:unit":"node --test ./test/*.test.js","build":"bash ./scripts/build-devtools-frontend.sh"},"author":{"name":"Nolan Lawson","email":"nolan@nolanlawson.com"},"license":"Apache-2.0","description":"Tools for parsing Chromium heap snapshot (`*.heapsnapshot`) files and doing useful things with them","repository":{"type":"git","url":"git+https://github.com/nolanlawson/heap-snapshot-toolkit.git"},"keywords":["heap","snapshot","heapsnapshot","parser","memory"],"bugs":{"url":"https://github.com/nolanlawson/heap-snapshot-toolkit/issues"},"homepage":"https://github.com/nolanlawson/heap-snapshot-toolkit#readme","engines":{"node":">= 18.0.0"},"devDependencies":{"@arethetypeswrong/cli":"^0.18.2","@microsoft/api-extractor":"^7.52.10","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-replace":"^6.0.2","@rollup/plugin-strip":"^3.0.4","@rollup/plugin-typescript":"^12.1.4","@rollup/plugin-virtual":"^3.0.2","@types/node":"^24.1.0","chai":"^5.2.1","node-readable-to-web-readable-stream":"^0.4.2","rollup":"^4.46.2","standard":"^17.1.2"},"pnpm":{"overrides":{"typescript":"^5.9.2"},"patchedDependencies":{"@rollup/plugin-typescript":"patches/@rollup__plugin-typescript.patch"}},"standard":{"ignore":["thirdparty"]},"packageManager":"pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748","_id":"heap-snapshot-toolkit@1.1.3","gitHead":"54e967fa8c6c079ad52f5c5d4497cbe73ab5936f","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-joThu2rEsDu8/l4arupRDI1qP4CZXNG+J6Wr348vnbLGSiBkwRdqZ6aOHl5BzEiC+Dc8OTbMlmWjD0lbXD5K2Q==","shasum":"8d04d0bacbb48822702a8cd7855753802914cc4a","tarball":"https://registry.npmjs.org/heap-snapshot-toolkit/-/heap-snapshot-toolkit-1.1.3.tgz","fileCount":10,"unpackedSize":710052,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCID838ejGacKWWUKjbzTrIvNNB2+SoGEsPxhuMQncd27MAiEAsCkzMP3DLKArv3QTmvBhj8fWLklUznmEMkBZp5S76SE="}]},"_npmUser":{"name":"nolanlawson","email":"nolan@nolanlawson.com"},"directories":{},"maintainers":[{"name":"nolanlawson","email":"nolan@nolanlawson.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/heap-snapshot-toolkit_1.1.3_1754236033256_0.8896777888295679"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-19T18:32:33.303Z","modified":"2025-08-03T15:47:13.644Z","1.0.0":"2025-04-19T18:32:33.612Z","1.1.0":"2025-04-19T19:42:34.941Z","1.1.1":"2025-04-26T20:50:05.105Z","1.1.2":"2025-07-06T17:36:10.912Z","1.1.3":"2025-08-03T15:47:13.482Z"},"bugs":{"url":"https://github.com/nolanlawson/heap-snapshot-toolkit/issues"},"author":{"name":"Nolan Lawson","email":"nolan@nolanlawson.com"},"license":"Apache-2.0","homepage":"https://github.com/nolanlawson/heap-snapshot-toolkit#readme","keywords":["heap","snapshot","heapsnapshot","parser","memory"],"repository":{"type":"git","url":"git+https://github.com/nolanlawson/heap-snapshot-toolkit.git"},"description":"Tools for parsing Chromium heap snapshot (`*.heapsnapshot`) files and doing useful things with them","maintainers":[{"name":"nolanlawson","email":"nolan@nolanlawson.com"}],"readme":"# heap-snapshot-toolkit\n\nTools for parsing Chromium heap snapshot (`*.heapsnapshot`) files and doing useful things with them.\n\nThis package mostly re-exports code from [the Chromium DevTools frontend](https://github.com/ChromeDevTools/devtools-frontend). You can refer to that project for the original source.\n\nThe goal is to have a way to analyze and diff heap snapshots in any JavaScript environment, including the browser and Node.js.\n\n## Installation\n\n```sh\nnpm install heap-snapshot-toolkit\n```\n\n## Usage\n\n### Parsing\n\nParse a heap snapshot file from disk:\n\n```js\nimport { createReadStream } from 'node:fs'\nimport { parse } from 'heap-snapshot-toolkit'\n\nconst parsedHeapSnapshot = await parse(createReadStream('path/to/my.heapsnapshot', 'utf-8'))\n```\n\nYou can either pass in a Node.js [`ReadStream`](https://nodejs.org/api/fs.html#class-fsreadstream), or a standard [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).\n\nPassing in a file directly is not recommended, since heap snapshot files can be quite large. But if you really must:\n\n```js\nimport { readFileSync } from 'node:fs'\nimport { Readable } from 'node:stream'\nimport { parse } from 'heap-snapshot-toolkit'\n\nconst string = readFileSync('path/to/my.heapsnapshot', 'utf-8')\nconst stream = new Readable()\nstream.push(string)\nstream.push(null)\n\nconst parsedHeapSnapshot = parse(stream)\n```\n\n### Analyzing\n\nWhat can you do with the parsed heap snapshot? You can look at its statistics:\n\n```js\nconsole.log(parsedHeapSnapshot.getStatistics()) \n```\n\nThis might log something like:\n\n```json\n{\n  \"total\": 352312,\n  \"native\": {\n    \"total\": 11568,\n    \"typedArrays\": 0\n  },\n  \"v8heap\": {\n    \"total\": 340744,\n    \"code\": 20840,\n    \"jsArrays\": 512,\n    \"strings\": 5156,\n    \"system\": 140576\n  }\n}\n```\n\nThe exact output is determined by the internals of the Chromium DevTools frontend.\n\n### Diff\n\nYou can also diff two snapshots using the `diff()` method:\n\n```js\nimport { createReadStream } from 'node:fs'\nimport { parse, diff } from 'heap-snapshot-toolkit'\n\nconst startSnapshot = parse(createReadStream('path/to/start.heapsnapshot', 'utf-8'))\nconst endSnapshot = parse(createReadStream('path/to/end.heapsnapshot', 'utf-8'))\n\nconst snapshotDiff = diff(startSnapshot, endSnapshot)\n```\n\nThis will return an object where the keys are unique classes and the values are information about the diff. For example:\n\n```js\nconsole.log(snapshotDiff[',Array'])\n```\n\nThis might log something like:\n\n```json\n{\n  \"name\": \"Foo\",\n  \"addedCount\": 1,\n  \"removedCount\": 0,\n  \"addedSize\": 52,\n  \"removedSize\": 0,\n  \"deletedIndexes\": [],\n  \"addedIndexes\": [\n    86316\n  ],\n  \"countDelta\": 1,\n  \"sizeDelta\": 52\n}\n```\n\nNote that the keys are unique strings determined by the Chromium DevTools frontend. In short, the key is a combination\nof the class name and the code positions, in order to distinguish object classes with the same name. For instance,\n`1,2,3,Foo` would be a different class than `4,5,6,Foo`. For readability, you can find the shorter name in the\n`aggregatesWithFilter` output:\n\n```js\nconsole.log(snapshot.aggregatesWithFilter({}))\n```\n\nThis might log something like:\n\n```js\n{\n  // ...\n  \",Array\": {\n    \"count\": 2,\n    \"distance\": 3,\n    \"self\": 384,\n    \"maxRet\": 4072,\n    \"name\": \"Array\",\n    \"idxs\": [\n      76026,\n      89142\n    ]\n  },\n  // ...\n}\n```\n\nYou can also use the `diffFromStreams()` API to diff from two `ReadStream`/`ReadableStream`s. This is useful if you want to avoid using too\nmuch memory by reading in two entire heap snapshot files at once. `diffFromStreams()` will instead efficiently read in the start\nsnapshot, create a minimal object for diffing, read in the end snapshot, and then create the diff.\n\nIn this mode, `diffFromStreams()` is an [async iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator)\nwhich emits 3 events: one for the start snapshot, one for the end snapshot, and one for the final diff.\n\n```js\nimport { createReadStream } from 'node:fs'\nimport { diffFromStreams } from 'heap-snapshot-toolkit'\n\nconst startStream = createReadStream('path/to/start.heapsnapshot', 'utf-8')\nconst endStream = createReadStream('path/to/end.heapsnapshot', 'utf-8')\n\nconst iterator = diffFromStreams(startStream, endStream)\nfor await (const item of iterator) {\n  if (item.type === 'start') {\n    console.log(item.result) // start snapshot\n  } else if (item.type === 'end') {\n    console.log(item.result) // end snapshot\n  } else if (item.type === 'diff') {\n    console.log(item.result) // snapshot diff\n  }\n}\n```\n\n## `DevToolsAPI`\n\nNote that this package doesn't make much attempt to paper over the Chromium DevTools APIs. You may have to dig\naround in the generated objects if there is something particular you want to do.\n\nAll important DevTools APIs are also exported in case you need them:\n\n```js\nimport { DevToolsAPI } from 'heap-snapshot-toolkit'\nconsole.log(DevToolsAPI)\n```\n\n## Contributing\n\n### Build from `devtools-frontend`\n\nClone `devtools-frontend` from \n[the Chromium DevTools frontend source code](https://github.com/ChromeDevTools/devtools-frontend) into a sibling directory relative to `heap-snapshot-toolkit`. Then run:\n\n```sh\npnpm build\n```\n\n### Lint\n\n```sh\npnpm lint\n```\n\n### Test\n\n```sh\npnpm test\n```\n","readmeFilename":"README.md"}