heapsnapshot
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -21,4 +21,4 @@ 'use strict'; | ||
toString() { | ||
return `<edge:${this.name_or_index} from: ${from.toStringContent()} to ${to.toStringContent()}>`; | ||
return `<edge: ${this.name_or_index} from(${this.from.toStringContent()}) to(${this.to.toStringContent()})>`; | ||
} | ||
} |
@@ -72,2 +72,6 @@ 'use strict'; | ||
buildSync() { | ||
for (let _ of this.build()) { } | ||
} | ||
* build() { | ||
@@ -74,0 +78,0 @@ let index = 0; |
@@ -31,4 +31,5 @@ 'use strict'; | ||
toStringContent() { | ||
return `${this.name || '(unknown node)'}:${this.index}` | ||
return `${this.name || '(unknown node)'}: ${this.index}` | ||
} | ||
toString() { | ||
@@ -35,0 +36,0 @@ return `<${this.toStringContent()}>` |
'use strict'; | ||
module.exports = function pathToRoot(node, visited = new WeakSet(), fromEdge) { | ||
module.exports = function pathToRoot(node) { | ||
let visited = arguments[1] || new WeakSet(); | ||
let fromEdge = arguments[2]; | ||
if (visited.has(node)) { return; } | ||
@@ -18,2 +20,4 @@ visited.add(node); | ||
} | ||
return []; | ||
}; |
{ | ||
"name": "heapsnapshot", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"repository": "https://github.com/stefanpenner/heapsnapshot.git", | ||
"scripts": { | ||
"test": "mocha tests" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
] | ||
], | ||
"devDependencies": { | ||
"chai": "^4.0.2", | ||
"mocha": "^3.4.2" | ||
} | ||
} |
# heapsnapshot | ||
[![Build Status](https://travis-ci.org/stefanpenner/heapsnapshot.svg?branch=master)](https://travis-ci.org/stefanpenner/heapsnapshot) | ||
A Programmatic API for a heapsnapshot. | ||
Currently supports dumps from: | ||
* chrome/v8 | ||
usage: | ||
* `yarn add heapsnapshot` | ||
* `npm install heapsnapshot` | ||
```js | ||
@@ -15,3 +19,3 @@ | ||
// TODO: iterate for building (so we can do it eventually incrementally) | ||
for (let _ of snapshot.build()) { } | ||
snapshot.buildSync(); // alternatively build() is a generator, which allows for incremental building. | ||
@@ -26,1 +30,20 @@ // get all nodes | ||
``` | ||
### Stuff | ||
#### Node | ||
```js | ||
node.in // => array in in-bound edges | ||
node.out // => array in in-bound edges | ||
node.toString() // => "<Container: 622248>" | ||
``` | ||
#### Edge | ||
```js | ||
edge.to // => node the edge points to | ||
edge.from // => node the edge comes from | ||
edge.toString() // => "<name: from(Container: 622248) to ((map descriptors): 625980)" | ||
``` |
9450
233
48
2