@memlab/core 1.1.0 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/Utils.js CHANGED
@@ -542,6 +542,7 @@ function getSnapshotFromFile(filename, options) {
542
542
  catch (e) {
543
543
  handleSnapshotError(getError(e));
544
544
  }
545
+ Console_1.default.flush();
545
546
  return ret;
546
547
  });
547
548
  }
@@ -580,14 +581,14 @@ function getEdgeByNameAndType(node, edgeName, type) {
580
581
  if (!node) {
581
582
  return null;
582
583
  }
583
- return node.findReference((edge) => edge.name_or_index === edgeName &&
584
+ return node.findAnyReference((edge) => edge.name_or_index === edgeName &&
584
585
  (type === undefined || edge.type === type));
585
586
  }
586
587
  function getEdgeStartsWithName(node, prefix) {
587
588
  if (!node) {
588
589
  return null;
589
590
  }
590
- return node.findReference(edge => typeof edge.name_or_index === 'string' &&
591
+ return node.findAnyReference(edge => typeof edge.name_or_index === 'string' &&
591
592
  edge.name_or_index.startsWith(prefix));
592
593
  }
593
594
  function isStringNode(node) {
@@ -31,7 +31,7 @@ export default class HeapNode implements IHeapNode {
31
31
  get trace_node_id(): number;
32
32
  get references(): HeapEdge[];
33
33
  forEachReference(callback: EdgeIterationCallback): void;
34
- findReference(predicate: Predicator<IHeapEdge>): Nullable<IHeapEdge>;
34
+ findAnyReference(predicate: Predicator<IHeapEdge>): Nullable<IHeapEdge>;
35
35
  findAnyReferrer(predicate: Predicator<IHeapEdge>): Nullable<IHeapEdge>;
36
36
  findReferrers(predicate: Predicator<IHeapEdge>): IHeapEdge[];
37
37
  get referrers(): HeapEdge[];
@@ -131,7 +131,7 @@ class HeapNode {
131
131
  }
132
132
  }
133
133
  }
134
- findReference(predicate) {
134
+ findAnyReference(predicate) {
135
135
  let found = null;
136
136
  this.forEachReference((edge) => {
137
137
  if (predicate(edge)) {
@@ -82,6 +82,9 @@ class HeapSnapshot {
82
82
  this.nodes = {
83
83
  length: self._nodeCount,
84
84
  get(idx) {
85
+ if (idx < 0 || idx >= self._nodeCount) {
86
+ return null;
87
+ }
85
88
  return new HeapNode_1.default(self, idx);
86
89
  },
87
90
  forEach(cb) {
@@ -109,6 +112,9 @@ class HeapSnapshot {
109
112
  this.edges = {
110
113
  length: self._edgeCount,
111
114
  get(idx) {
115
+ if (idx < 0 || idx >= self._edgeCount) {
116
+ return null;
117
+ }
112
118
  return new HeapEdge_1.default(self, idx);
113
119
  },
114
120
  forEach(cb) {
@@ -180,7 +186,7 @@ class HeapSnapshot {
180
186
  return false;
181
187
  }
182
188
  // check if the table has any weak reference to any object
183
- const ref = table.findReference((edge) => edge.type === 'weak' && edge.toNode.name !== 'system / Oddball');
189
+ const ref = table.findAnyReference((edge) => edge.type === 'weak' && edge.toNode.name !== 'system / Oddball');
184
190
  return ref != null;
185
191
  }
186
192
  getNodeById(id) {
@@ -159,7 +159,8 @@ class TraceFinder {
159
159
  if (!Utils_1.default.isEssentialEdge(nodeIndex, edgeType, rootNodeIndex)) {
160
160
  continue;
161
161
  }
162
- const childNodeIndex = forwardEdges.get(edgeIndex).toNode.nodeIndex;
162
+ const childNodeIndex = forwardEdges.get(edgeIndex)
163
+ .toNode.nodeIndex;
163
164
  if (visited[childNodeIndex]) {
164
165
  continue;
165
166
  }
@@ -278,7 +279,8 @@ class TraceFinder {
278
279
  if (!Utils_1.default.isEssentialEdge(ROOT_NODE_INDEX, edgeType, ROOT_NODE_INDEX)) {
279
280
  continue;
280
281
  }
281
- const childNodeIndex = forwardEdges.get(edgeIndex).toNode.nodeIndex;
282
+ const childNodeIndex = forwardEdges.get(edgeIndex).toNode
283
+ .nodeIndex;
282
284
  nodesWithOutdatedDominatorInfo[nodeIndex2PostOrderIndex[childNodeIndex]] = 1;
283
285
  }
284
286
  // now iterate through all nodes in the heap
@@ -34,7 +34,7 @@ export declare class NodeRecord implements IHeapNode {
34
34
  get referrers(): IHeapEdge[];
35
35
  toStringNode(): IHeapStringNode;
36
36
  forEachReferrer(_callback: EdgeIterationCallback): void;
37
- findReference(): Nullable<IHeapEdge>;
37
+ findAnyReference(): Nullable<IHeapEdge>;
38
38
  findAnyReferrer(): Nullable<IHeapEdge>;
39
39
  findReferrers(): IHeapEdge[];
40
40
  set pathEdge(r: IHeapEdge);
@@ -70,8 +70,8 @@ class NodeRecord {
70
70
  _callback) {
71
71
  throw new Error('NodeRecord.forEachReferrer is not implemented');
72
72
  }
73
- findReference() {
74
- throw new Error('NodeRecord.findReference is not implemented');
73
+ findAnyReference() {
74
+ throw new Error('NodeRecord.findAnyReference is not implemented');
75
75
  }
76
76
  findAnyReferrer() {
77
77
  throw new Error('NodeRecord.findAnyReferrer is not implemented');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/core",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "license": "MIT",
5
5
  "description": "memlab core libraries",
6
6
  "author": "Liang Gong <lgong@fb.com>",
@@ -58,6 +58,7 @@
58
58
  "scripts": {
59
59
  "build-pkg": "tsc",
60
60
  "test-pkg": "jest .",
61
+ "publish-patch": "npm version patch --force && npm publish",
61
62
  "clean-pkg": "rm -rf ./dist && rm -rf ./node_modules && rm -f ./tsconfig.tsbuildinfo"
62
63
  },
63
64
  "bugs": {