@atlaspack/graph 3.5.10-typescript-5b4d3ad41.0 → 3.5.10

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.
@@ -1,5 +1,7 @@
1
+ // @flow strict-local
2
+
1
3
  import {fromNodeId} from './types';
2
- import AdjacencyList, {SerializedAdjacencyList} from './AdjacencyList';
4
+ import AdjacencyList, {type SerializedAdjacencyList} from './AdjacencyList';
3
5
  import type {Edge, NodeId} from './types';
4
6
  import type {
5
7
  TraversalActions,
@@ -12,32 +14,32 @@ import nullthrows from 'nullthrows';
12
14
 
13
15
  export type NullEdgeType = 1;
14
16
  export const NULL_EDGE_TYPE: NullEdgeType = 1;
15
- export type GraphOpts<TNode, TEdgeType extends number = NullEdgeType> = {
16
- nodes?: Array<TNode | null>;
17
- adjacencyList?: SerializedAdjacencyList<TEdgeType>;
18
- rootNodeId?: NodeId | null | undefined;
19
- initialCapacity?: number;
20
- };
21
-
22
- export type SerializedGraph<TNode, TEdgeType extends number = NullEdgeType> = {
23
- nodes: Array<TNode | null>;
24
- adjacencyList: SerializedAdjacencyList<TEdgeType>;
25
- rootNodeId: NodeId | null | undefined;
26
- };
17
+ export type GraphOpts<TNode, TEdgeType: number = NullEdgeType> = {|
18
+ nodes?: Array<TNode | null>,
19
+ adjacencyList?: SerializedAdjacencyList<TEdgeType>,
20
+ rootNodeId?: ?NodeId,
21
+ initialCapacity?: number,
22
+ |};
23
+
24
+ export type SerializedGraph<TNode, TEdgeType: number = NullEdgeType> = {|
25
+ nodes: Array<TNode | null>,
26
+ adjacencyList: SerializedAdjacencyList<TEdgeType>,
27
+ rootNodeId: ?NodeId,
28
+ |};
27
29
 
28
30
  export type AllEdgeTypes = -1;
29
31
  export const ALL_EDGE_TYPES: AllEdgeTypes = -1;
30
32
 
31
- type DFSCommandVisit<TContext> = {
32
- nodeId: NodeId;
33
- context: TContext | null;
34
- };
33
+ type DFSCommandVisit<TContext> = {|
34
+ nodeId: NodeId,
35
+ context: TContext | null,
36
+ |};
35
37
 
36
- type DFSCommandExit<TContext> = {
37
- nodeId: NodeId;
38
- exit: GraphTraversalCallback<NodeId, TContext>;
39
- context: TContext | null;
40
- };
38
+ type DFSCommandExit<TContext> = {|
39
+ nodeId: NodeId,
40
+ exit: GraphTraversalCallback<NodeId, TContext>,
41
+ context: TContext | null,
42
+ |};
41
43
 
42
44
  /**
43
45
  * Internal type used for queue iterative DFS implementation.
@@ -49,8 +51,8 @@ type DFSCommand<TContext> =
49
51
  /**
50
52
  * Options for DFS traversal.
51
53
  */
52
- export type DFSParams<TContext> = {
53
- visit: GraphVisitor<NodeId, TContext>;
54
+ export type DFSParams<TContext> = {|
55
+ visit: GraphVisitor<NodeId, TContext>,
54
56
  /**
55
57
  * Custom function to get next entries to visit.
56
58
  *
@@ -69,17 +71,17 @@ export type DFSParams<TContext> = {
69
71
  *
70
72
  * Only due to the latter we aren't replacing this.
71
73
  */
72
- getChildren: (nodeId: NodeId) => Array<NodeId>;
73
- startNodeId?: NodeId | null | undefined;
74
- };
74
+ getChildren: (nodeId: NodeId) => Array<NodeId>,
75
+ startNodeId?: ?NodeId,
76
+ |};
75
77
 
76
- export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
78
+ export default class Graph<TNode, TEdgeType: number = NullEdgeType> {
77
79
  nodes: Array<TNode | null>;
78
80
  adjacencyList: AdjacencyList<TEdgeType>;
79
- rootNodeId: NodeId | null | undefined;
80
- _visited: BitSet | null | undefined;
81
+ rootNodeId: ?NodeId;
82
+ _visited: ?BitSet;
81
83
 
82
- constructor(opts?: GraphOpts<TNode, TEdgeType> | null) {
84
+ constructor(opts: ?GraphOpts<TNode, TEdgeType>) {
83
85
  this.nodes = opts?.nodes || [];
84
86
  this.setRootNodeId(opts?.rootNodeId);
85
87
 
@@ -92,11 +94,11 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
92
94
  );
93
95
  }
94
96
 
95
- setRootNodeId(id?: NodeId | null) {
97
+ setRootNodeId(id: ?NodeId) {
96
98
  this.rootNodeId = id;
97
99
  }
98
100
 
99
- static deserialize<TNode, TEdgeType extends number = NullEdgeType>(
101
+ static deserialize(
100
102
  opts: GraphOpts<TNode, TEdgeType>,
101
103
  ): Graph<TNode, TEdgeType> {
102
104
  return new this({
@@ -130,7 +132,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
130
132
  return this.nodes[id] != null;
131
133
  }
132
134
 
133
- getNode(id: NodeId): TNode | null | undefined {
135
+ getNode(id: NodeId): ?TNode {
134
136
  return this.nodes[id];
135
137
  }
136
138
 
@@ -157,7 +159,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
157
159
  hasEdge(
158
160
  from: NodeId,
159
161
  to: NodeId,
160
- type:
162
+ type?:
161
163
  | TEdgeType
162
164
  | NullEdgeType
163
165
  | Array<TEdgeType | NullEdgeType> = NULL_EDGE_TYPE,
@@ -167,7 +169,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
167
169
 
168
170
  forEachNodeIdConnectedTo(
169
171
  to: NodeId,
170
- fn: (nodeId: NodeId) => boolean | undefined,
172
+ fn: (nodeId: NodeId) => boolean | void,
171
173
  type: AllEdgeTypes | TEdgeType | NullEdgeType = NULL_EDGE_TYPE,
172
174
  ) {
173
175
  this._assertHasNodeId(to);
@@ -325,9 +327,9 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
325
327
  // Update a node's downstream nodes making sure to prune any orphaned branches
326
328
  replaceNodeIdsConnectedTo(
327
329
  fromNodeId: NodeId,
328
- toNodeIds: ReadonlyArray<NodeId>,
329
- replaceFilter?: null | ((arg1: NodeId) => boolean),
330
- type: TEdgeType | NullEdgeType = NULL_EDGE_TYPE,
330
+ toNodeIds: $ReadOnlyArray<NodeId>,
331
+ replaceFilter?: null | ((NodeId) => boolean),
332
+ type?: TEdgeType | NullEdgeType = NULL_EDGE_TYPE,
331
333
  removeOrphans: boolean = true,
332
334
  ): void {
333
335
  this._assertHasNodeId(fromNodeId);
@@ -353,13 +355,13 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
353
355
 
354
356
  traverse<TContext>(
355
357
  visit: GraphVisitor<NodeId, TContext>,
356
- startNodeId?: NodeId | null,
358
+ startNodeId: ?NodeId,
357
359
  type:
358
360
  | TEdgeType
359
361
  | NullEdgeType
360
362
  | Array<TEdgeType | NullEdgeType>
361
363
  | AllEdgeTypes = NULL_EDGE_TYPE,
362
- ): TContext | null | undefined {
364
+ ): ?TContext {
363
365
  let enter = typeof visit === 'function' ? visit : visit.enter;
364
366
  if (
365
367
  type === ALL_EDGE_TYPES &&
@@ -377,23 +379,23 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
377
379
  }
378
380
 
379
381
  filteredTraverse<TValue, TContext>(
380
- filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined,
382
+ filter: (NodeId, TraversalActions) => ?TValue,
381
383
  visit: GraphVisitor<TValue, TContext>,
382
- startNodeId?: NodeId | null,
384
+ startNodeId: ?NodeId,
383
385
  type?: TEdgeType | Array<TEdgeType | NullEdgeType> | AllEdgeTypes,
384
- ): TContext | null | undefined {
386
+ ): ?TContext {
385
387
  return this.traverse(mapVisitor(filter, visit), startNodeId, type);
386
388
  }
387
389
 
388
390
  traverseAncestors<TContext>(
389
- startNodeId: NodeId | null | undefined,
391
+ startNodeId: ?NodeId,
390
392
  visit: GraphVisitor<NodeId, TContext>,
391
393
  type:
392
394
  | TEdgeType
393
395
  | NullEdgeType
394
396
  | Array<TEdgeType | NullEdgeType>
395
397
  | AllEdgeTypes = NULL_EDGE_TYPE,
396
- ): TContext | null | undefined {
398
+ ): ?TContext {
397
399
  return this.dfs({
398
400
  visit,
399
401
  startNodeId,
@@ -403,8 +405,8 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
403
405
 
404
406
  dfsFast<TContext>(
405
407
  visit: GraphTraversalCallback<NodeId, TContext>,
406
- startNodeId?: NodeId | null,
407
- ): TContext | null | undefined {
408
+ startNodeId: ?NodeId,
409
+ ): ?TContext {
408
410
  let traversalStartNode = nullthrows(
409
411
  startNodeId ?? this.rootNodeId,
410
412
  'A start node is required to traverse',
@@ -435,7 +437,6 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
435
437
 
436
438
  let queue = [{nodeId: traversalStartNode, context: null}];
437
439
  while (queue.length !== 0) {
438
- // @ts-expect-error TS2339
439
440
  let {nodeId, context} = queue.pop();
440
441
  if (!this.hasNode(nodeId) || visited.has(nodeId)) continue;
441
442
  visited.add(nodeId);
@@ -443,6 +444,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
443
444
  skipped = false;
444
445
  let newContext = visit(nodeId, context, actions);
445
446
  if (typeof newContext !== 'undefined') {
447
+ // $FlowFixMe[reassign-const]
446
448
  context = newContext;
447
449
  }
448
450
 
@@ -470,7 +472,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
470
472
  // A post-order implementation of dfsFast
471
473
  postOrderDfsFast(
472
474
  visit: GraphTraversalCallback<NodeId, TraversalActions>,
473
- startNodeId?: NodeId | null,
475
+ startNodeId: ?NodeId,
474
476
  ): void {
475
477
  let traversalStartNode = nullthrows(
476
478
  startNodeId ?? this.rootNodeId,
@@ -540,7 +542,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
540
542
  visit,
541
543
  startNodeId,
542
544
  getChildren,
543
- }: DFSParams<TContext>): TContext | null | undefined {
545
+ }: DFSParams<TContext>): ?TContext {
544
546
  let traversalStartNode = nullthrows(
545
547
  startNodeId ?? this.rootNodeId,
546
548
  'A start node is required to traverse',
@@ -576,13 +578,11 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
576
578
  while (queue.length !== 0) {
577
579
  const command = queue.pop();
578
580
 
579
- // @ts-expect-error TS18048
580
581
  if (command.exit != null) {
581
- // @ts-expect-error TS2339
582
582
  let {nodeId, context, exit} = command;
583
- // @ts-expect-error TS18048
584
583
  let newContext = exit(nodeId, command.context, actions);
585
584
  if (typeof newContext !== 'undefined') {
585
+ // $FlowFixMe[reassign-const]
586
586
  context = newContext;
587
587
  }
588
588
 
@@ -595,7 +595,6 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
595
595
  return context;
596
596
  }
597
597
  } else {
598
- // @ts-expect-error TS2339
599
598
  let {nodeId, context} = command;
600
599
  if (!this.hasNode(nodeId) || visited.has(nodeId)) continue;
601
600
  visited.add(nodeId);
@@ -604,6 +603,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
604
603
  if (enter) {
605
604
  let newContext = enter(nodeId, context, actions);
606
605
  if (typeof newContext !== 'undefined') {
606
+ // $FlowFixMe[reassign-const]
607
607
  context = newContext;
608
608
  }
609
609
  }
@@ -641,9 +641,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
641
641
  this._visited = visited;
642
642
  }
643
643
 
644
- bfs(
645
- visit: (nodeId: NodeId) => boolean | null | undefined,
646
- ): NodeId | null | undefined {
644
+ bfs(visit: (nodeId: NodeId) => ?boolean): ?NodeId {
647
645
  let rootNodeId = nullthrows(
648
646
  this.rootNodeId,
649
647
  'A root node is required to traverse',
@@ -659,7 +657,6 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
659
657
  return node;
660
658
  }
661
659
 
662
- // @ts-expect-error TS2345
663
660
  for (let child of this.getNodeIdsConnectedFrom(node)) {
664
661
  if (!visited.has(child)) {
665
662
  visited.add(child);
@@ -685,10 +682,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
685
682
  return sorted.reverse();
686
683
  }
687
684
 
688
- findAncestor(
689
- nodeId: NodeId,
690
- fn: (nodeId: NodeId) => boolean,
691
- ): NodeId | null | undefined {
685
+ findAncestor(nodeId: NodeId, fn: (nodeId: NodeId) => boolean): ?NodeId {
692
686
  let res = null;
693
687
  this.traverseAncestors(nodeId, (nodeId, ctx, traversal) => {
694
688
  if (fn(nodeId)) {
@@ -703,7 +697,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
703
697
  nodeId: NodeId,
704
698
  fn: (nodeId: NodeId) => boolean,
705
699
  ): Array<NodeId> {
706
- let res: Array<NodeId> = [];
700
+ let res = [];
707
701
  this.traverseAncestors(nodeId, (nodeId, ctx, traversal) => {
708
702
  if (fn(nodeId)) {
709
703
  res.push(nodeId);
@@ -713,10 +707,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
713
707
  return res;
714
708
  }
715
709
 
716
- findDescendant(
717
- nodeId: NodeId,
718
- fn: (nodeId: NodeId) => boolean,
719
- ): NodeId | null | undefined {
710
+ findDescendant(nodeId: NodeId, fn: (nodeId: NodeId) => boolean): ?NodeId {
720
711
  let res = null;
721
712
  this.traverse((nodeId, ctx, traversal) => {
722
713
  if (fn(nodeId)) {
@@ -731,7 +722,7 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
731
722
  nodeId: NodeId,
732
723
  fn: (nodeId: NodeId) => boolean,
733
724
  ): Array<NodeId> {
734
- let res: Array<NodeId> = [];
725
+ let res = [];
735
726
  this.traverse((nodeId, ctx, traversal) => {
736
727
  if (fn(nodeId)) {
737
728
  res.push(nodeId);
@@ -749,21 +740,11 @@ export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
749
740
  }
750
741
 
751
742
  export function mapVisitor<NodeId, TValue, TContext>(
752
- filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined,
743
+ filter: (NodeId, TraversalActions) => ?TValue,
753
744
  visit: GraphVisitor<TValue, TContext>,
754
745
  ): GraphVisitor<NodeId, TContext> {
755
- function makeEnter(
756
- visit: (
757
- node: TValue,
758
- context: TContext | null | undefined,
759
- actions: TraversalActions,
760
- ) => TContext | null | undefined,
761
- ) {
762
- return function mappedEnter(
763
- nodeId: NodeId,
764
- context: TContext | null | undefined,
765
- actions: TraversalActions,
766
- ) {
746
+ function makeEnter(visit) {
747
+ return function mappedEnter(nodeId, context, actions) {
767
748
  let value = filter(nodeId, actions);
768
749
  if (value != null) {
769
750
  return visit(value, context, actions);
@@ -775,17 +756,13 @@ export function mapVisitor<NodeId, TValue, TContext>(
775
756
  return makeEnter(visit);
776
757
  }
777
758
 
778
- let mapped: Record<string, any> = {};
759
+ let mapped = {};
779
760
  if (visit.enter != null) {
780
761
  mapped.enter = makeEnter(visit.enter);
781
762
  }
782
763
 
783
764
  if (visit.exit != null) {
784
- mapped.exit = function mappedExit(
785
- nodeId: NodeId,
786
- context: TContext | null | undefined,
787
- actions: TraversalActions,
788
- ) {
765
+ mapped.exit = function mappedExit(nodeId, context, actions) {
789
766
  let exit = visit.exit;
790
767
  if (!exit) {
791
768
  return;
@@ -1,3 +1,5 @@
1
+ // @flow strict-local
2
+
1
3
  export type {NodeId, ContentKey, Edge} from './types';
2
4
  export type {GraphOpts} from './Graph';
3
5
  export type {ContentGraphOpts, SerializedContentGraph} from './ContentGraph';
@@ -1,11 +1,8 @@
1
- // flow-to-ts helpers
2
- export type Class<T> = new (...args: any[]) => T;
3
- // /flow-to-ts helpers
4
-
1
+ // @flow
5
2
  // Copy from @atlaspack/utils to fix: https://github.com/stackblitz/core/issues/1855
6
3
  export let SharedBuffer: Class<ArrayBuffer> | Class<SharedArrayBuffer>;
7
4
 
8
- // @ts-expect-error TS2339
5
+ // $FlowFixMe[prop-missing]
9
6
  if (process.browser) {
10
7
  SharedBuffer = ArrayBuffer;
11
8
  // Safari has removed the constructor
@@ -15,7 +12,7 @@ if (process.browser) {
15
12
  // Firefox might throw when sending the Buffer over a MessagePort
16
13
  channel.port1.postMessage(new SharedArrayBuffer(0));
17
14
  SharedBuffer = SharedArrayBuffer;
18
- } catch (_: any) {
15
+ } catch (_) {
19
16
  // NOOP
20
17
  }
21
18
  channel.port1.close();
@@ -1,3 +1,5 @@
1
+ // @flow strict-local
2
+
1
3
  // forcing NodeId to be opaque as it should only be created once
2
4
  export type NodeId = number;
3
5
  export function toNodeId(x: number): NodeId {
@@ -9,8 +11,8 @@ export function fromNodeId(x: NodeId): number {
9
11
 
10
12
  export type ContentKey = string;
11
13
 
12
- export type Edge<TEdgeType extends number> = {
13
- from: NodeId;
14
- to: NodeId;
15
- type: TEdgeType;
16
- };
14
+ export type Edge<TEdgeType: number> = {|
15
+ from: NodeId,
16
+ to: NodeId,
17
+ type: TEdgeType,
18
+ |};
@@ -1,3 +1,5 @@
1
+ // @flow strict-local
2
+
1
3
  import assert from 'assert';
2
4
  import sinon from 'sinon';
3
5
  import path from 'path';
@@ -212,7 +214,9 @@ describe('AdjacencyList', () => {
212
214
 
213
215
  it('addEdge should not replace a deleted edge if the edge was already added', () => {
214
216
  // Mock hash fn to generate collisions
217
+ // $FlowFixMe[prop-missing]
215
218
  let originalHash = AdjacencyList.prototype.hash;
219
+ // $FlowFixMe[prop-missing]
216
220
  AdjacencyList.prototype.hash = () => 1;
217
221
 
218
222
  let graph = new AdjacencyList();
@@ -225,12 +229,15 @@ describe('AdjacencyList', () => {
225
229
  assert(graph.addEdge(n0, n1, 1) === false);
226
230
  assert(graph.stats.edges === 1);
227
231
 
232
+ // $FlowFixMe[prop-missing]
228
233
  AdjacencyList.prototype.hash = originalHash;
229
234
  });
230
235
 
231
236
  it('addEdge should replace a deleted edge', () => {
232
237
  // Mock hash fn to generate collisions
238
+ // $FlowFixMe[prop-missing]
233
239
  let originalHash = AdjacencyList.prototype.hash;
240
+ // $FlowFixMe[prop-missing]
234
241
  AdjacencyList.prototype.hash = () => 1;
235
242
 
236
243
  try {
@@ -247,6 +254,7 @@ describe('AdjacencyList', () => {
247
254
  assert(graph.stats.edges === 1);
248
255
  assert(graph.stats.deleted === 0);
249
256
  } finally {
257
+ // $FlowFixMe[prop-missing]
250
258
  AdjacencyList.prototype.hash = originalHash;
251
259
  }
252
260
  });
@@ -291,8 +299,8 @@ describe('AdjacencyList', () => {
291
299
  graph.addEdge(a, b);
292
300
  graph.addEdge(c, b);
293
301
 
294
- const nodeIds: Array<any> = [];
295
- graph.forEachNodeIdConnectedTo(b, (id: any) => {
302
+ const nodeIds = [];
303
+ graph.forEachNodeIdConnectedTo(b, (id) => {
296
304
  nodeIds.push(id);
297
305
  });
298
306
 
@@ -310,8 +318,8 @@ describe('AdjacencyList', () => {
310
318
  graph.addEdge(b, d);
311
319
  graph.addEdge(c, d);
312
320
 
313
- const nodeIds: Array<any> = [];
314
- graph.forEachNodeIdConnectedTo(d, (nodeId: any) => {
321
+ const nodeIds = [];
322
+ graph.forEachNodeIdConnectedTo(d, (nodeId) => {
315
323
  nodeIds.push(nodeId);
316
324
  return true;
317
325
  });
@@ -329,8 +337,8 @@ describe('AdjacencyList', () => {
329
337
  graph.addEdge(c, b);
330
338
  graph.addEdge(b, b);
331
339
 
332
- const nodeIds: Array<any> = [];
333
- graph.forEachNodeIdConnectedTo(b, (id: any) => {
340
+ const nodeIds = [];
341
+ graph.forEachNodeIdConnectedTo(b, (id) => {
334
342
  nodeIds.push(id);
335
343
  });
336
344
 
@@ -346,8 +354,8 @@ describe('AdjacencyList', () => {
346
354
  graph.addEdge(a, b);
347
355
  graph.addEdge(c, b, 2);
348
356
 
349
- const nodeIds: Array<any> = [];
350
- graph.forEachNodeIdConnectedTo(b, (id: any) => {
357
+ const nodeIds = [];
358
+ graph.forEachNodeIdConnectedTo(b, (id) => {
351
359
  nodeIds.push(id);
352
360
  });
353
361
 
@@ -363,10 +371,10 @@ describe('AdjacencyList', () => {
363
371
  graph.addEdge(a, b);
364
372
  graph.addEdge(c, b, 2);
365
373
 
366
- const nodeIds: Array<any> = [];
374
+ const nodeIds = [];
367
375
  graph.forEachNodeIdConnectedTo(
368
376
  b,
369
- (id: any) => {
377
+ (id) => {
370
378
  nodeIds.push(id);
371
379
  },
372
380
  ALL_EDGE_TYPES,
@@ -405,8 +413,8 @@ describe('AdjacencyList', () => {
405
413
  graph.addEdge(b, d, 3);
406
414
  graph.addEdge(c, e, 4);
407
415
 
408
- const nodeIds: Array<any> = [];
409
- graph.forEachNodeIdConnectedFromReverse(a, (nodeId: any) => {
416
+ const nodeIds = [];
417
+ graph.forEachNodeIdConnectedFromReverse(a, (nodeId) => {
410
418
  nodeIds.push(nodeId);
411
419
  return false;
412
420
  });
@@ -424,8 +432,8 @@ describe('AdjacencyList', () => {
424
432
  graph.addEdge(a, c);
425
433
  graph.addEdge(a, a);
426
434
 
427
- const nodeIds: Array<any> = [];
428
- graph.forEachNodeIdConnectedFromReverse(a, (nodeId: any) => {
435
+ const nodeIds = [];
436
+ graph.forEachNodeIdConnectedFromReverse(a, (nodeId) => {
429
437
  nodeIds.push(nodeId);
430
438
  return false;
431
439
  });
@@ -444,8 +452,8 @@ describe('AdjacencyList', () => {
444
452
  graph.addEdge(a, c);
445
453
  graph.addEdge(a, d);
446
454
 
447
- const nodeIds: Array<any> = [];
448
- graph.forEachNodeIdConnectedFromReverse(a, (nodeId: any) => {
455
+ const nodeIds = [];
456
+ graph.forEachNodeIdConnectedFromReverse(a, (nodeId) => {
449
457
  nodeIds.push(nodeId);
450
458
  return true;
451
459
  });
@@ -464,10 +472,10 @@ describe('AdjacencyList', () => {
464
472
  graph.addEdge(a, c, 2);
465
473
  graph.addEdge(a, d);
466
474
 
467
- const nodeIds: Array<any> = [];
475
+ const nodeIds = [];
468
476
  graph.forEachNodeIdConnectedFromReverse(
469
477
  a,
470
- (nodeId: any) => {
478
+ (nodeId) => {
471
479
  nodeIds.push(nodeId);
472
480
  return false;
473
481
  },
@@ -495,7 +503,7 @@ describe('AdjacencyList', () => {
495
503
  let originalSerialized = graph.serialize();
496
504
  let originalNodes = [...originalSerialized.nodes];
497
505
  let originalEdges = [...originalSerialized.edges];
498
- let work = new Promise((resolve: any) => worker.on('message', resolve));
506
+ let work = new Promise((resolve) => worker.on('message', resolve));
499
507
  worker.postMessage(originalSerialized);
500
508
  let received = AdjacencyList.deserialize(await work);
501
509
  // eslint-disable-next-line no-unused-vars
@@ -504,7 +512,7 @@ describe('AdjacencyList', () => {
504
512
  assert.deepEqual(received.serialize().nodes, graph.serialize().nodes);
505
513
  assert.deepEqual(received.serialize().edges, graph.serialize().edges);
506
514
 
507
- originalNodes.forEach((v: any, i: any) => {
515
+ originalNodes.forEach((v, i) => {
508
516
  if (i < NodeTypeMap.HEADER_SIZE) {
509
517
  assert.equal(v, received.serialize().nodes[i]);
510
518
  assert.equal(v, graph.serialize().nodes[i]);
@@ -514,7 +522,7 @@ describe('AdjacencyList', () => {
514
522
  }
515
523
  });
516
524
 
517
- originalEdges.forEach((v: any, i: any) => {
525
+ originalEdges.forEach((v, i) => {
518
526
  if (i < EdgeTypeMap.HEADER_SIZE) {
519
527
  assert.equal(v, received.serialize().edges[i]);
520
528
  assert.equal(v, graph.serialize().edges[i]);
@@ -1,16 +1,18 @@
1
+ // @flow strict-local
2
+
1
3
  import assert from 'assert';
2
4
  import {BitSet} from '../src/BitSet';
3
5
 
4
6
  function assertValues(set: BitSet, values: Array<number>) {
5
- let setValues: Array<any> = [];
6
- set.forEach((bit: any) => {
7
+ let setValues = [];
8
+ set.forEach((bit) => {
7
9
  setValues.push(bit);
8
10
  });
9
11
 
10
12
  for (let value of values) {
11
13
  assert(set.has(value), 'Set.has returned false');
12
14
  assert(
13
- setValues.some((v: any) => v === value),
15
+ setValues.some((v) => v === value),
14
16
  'Set values is missing value',
15
17
  );
16
18
  }
@@ -1,3 +1,5 @@
1
+ // @flow strict-local
2
+
1
3
  import assert from 'assert';
2
4
  import ContentGraph from '../src/ContentGraph';
3
5
 
@@ -5,7 +7,7 @@ describe('ContentGraph', () => {
5
7
  it('should addNodeByContentKey if no node exists with the content key', () => {
6
8
  let graph = new ContentGraph();
7
9
 
8
- const node: Record<string, any> = {};
10
+ const node = {};
9
11
 
10
12
  const nodeId1 = graph.addNodeByContentKey('contentKey', node);
11
13
 
@@ -27,7 +29,7 @@ describe('ContentGraph', () => {
27
29
  it('should remove the content key from graph when node is removed', () => {
28
30
  let graph = new ContentGraph();
29
31
 
30
- const node1: Record<string, any> = {};
32
+ const node1 = {};
31
33
  const nodeId1 = graph.addNodeByContentKey('contentKey', node1);
32
34
 
33
35
  assert.equal(graph.getNode(nodeId1), node1);