@atlaspack/graph 3.5.8 → 3.5.10-typescript-08dcc1c9b.0

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,11 +1,9 @@
1
- // @flow strict-local
2
-
3
1
  import assert from 'assert';
4
2
  import sinon from 'sinon';
5
3
  import type {TraversalActions} from '@atlaspack/types-internal';
6
4
 
7
5
  import Graph from '../src/Graph';
8
- import {toNodeId, type NodeId} from '../src/types';
6
+ import {toNodeId, NodeId} from '../src/types';
9
7
 
10
8
  describe('Graph', () => {
11
9
  it('constructor should initialize an empty graph', () => {
@@ -16,7 +14,7 @@ describe('Graph', () => {
16
14
 
17
15
  it('addNode should add a node to the graph', () => {
18
16
  let graph = new Graph();
19
- let node = {};
17
+ let node: Record<string, any> = {};
20
18
  let id = graph.addNode(node);
21
19
  assert.equal(graph.getNode(id), node);
22
20
  });
@@ -340,9 +338,9 @@ describe('Graph', () => {
340
338
 
341
339
  graph.setRootNodeId(nodeA);
342
340
 
343
- let visited = [];
341
+ let visited: Array<any> = [];
344
342
  graph.traverse(
345
- (nodeId) => {
343
+ (nodeId: any) => {
346
344
  visited.push(nodeId);
347
345
  },
348
346
  null, // use root as startNode
@@ -413,7 +411,7 @@ describe('Graph', () => {
413
411
  graph.addEdge(1, 3);
414
412
  graph.addEdge(2, 3);
415
413
 
416
- const order = [];
414
+ const order: Array<any> = [];
417
415
  const visit = (node: NodeId) => {
418
416
  order.push(node);
419
417
  };
@@ -440,10 +438,10 @@ describe('Graph', () => {
440
438
  graph.addEdge(1, 2);
441
439
  graph.addEdge(0, 3);
442
440
 
443
- const order = [];
441
+ const order: Array<any> = [];
444
442
  const visit = (
445
443
  node: NodeId,
446
- context: mixed | null,
444
+ context: unknown | null,
447
445
  actions: TraversalActions,
448
446
  ) => {
449
447
  if (node === 1) actions.skipChildren();
@@ -474,10 +472,10 @@ describe('Graph', () => {
474
472
  graph.addEdge(0, 2);
475
473
  graph.addEdge(2, 3);
476
474
 
477
- const order = [];
475
+ const order: Array<any> = [];
478
476
  const visit = (
479
477
  node: NodeId,
480
- context: mixed | null,
478
+ context: unknown | null,
481
479
  actions: TraversalActions,
482
480
  ) => {
483
481
  order.push(node);
@@ -515,8 +513,8 @@ describe('Graph', () => {
515
513
  graph.addEdge(0, 2);
516
514
  graph.addEdge(2, 3);
517
515
 
518
- const contexts = [];
519
- const visit = (node: NodeId, context: mixed | null) => {
516
+ const contexts: Array<any> = [];
517
+ const visit = (node: NodeId, context: unknown | null) => {
520
518
  contexts.push([node, context]);
521
519
  return `node-${node}-created-context`;
522
520
  };
@@ -529,8 +527,8 @@ describe('Graph', () => {
529
527
  });
530
528
 
531
529
  assert.deepEqual(
532
- contexts.map((values) =>
533
- values.map((v) => (v != null ? v : undefined)),
530
+ contexts.map((values: any) =>
531
+ values.map((v: any) => (v != null ? v : undefined)),
534
532
  ),
535
533
  [
536
534
  [0, undefined],
@@ -557,12 +555,12 @@ describe('Graph', () => {
557
555
  graph.addEdge(1, 3);
558
556
  graph.addEdge(0, 2);
559
557
 
560
- const contexts = [];
561
- const visit = (node: NodeId, context: mixed | null) => {
558
+ const contexts: Array<any> = [];
559
+ const visit = (node: NodeId, context: unknown | null) => {
562
560
  contexts.push([node, context]);
563
561
  return `node-${node}-created-context`;
564
562
  };
565
- const visitExit = (node: NodeId, context: mixed | null) => {
563
+ const visitExit = (node: NodeId, context: unknown | null) => {
566
564
  contexts.push(['exit', node, context]);
567
565
  return `node-exit-${node}-created-context`;
568
566
  };
@@ -578,8 +576,8 @@ describe('Graph', () => {
578
576
  });
579
577
 
580
578
  assert.deepEqual(
581
- contexts.map((values) =>
582
- values.map((v) => (v != null ? v : undefined)),
579
+ contexts.map((values: any) =>
580
+ values.map((v: any) => (v != null ? v : undefined)),
583
581
  ),
584
582
  [
585
583
  [0, undefined],
@@ -612,8 +610,8 @@ describe('Graph', () => {
612
610
  graph.addEdge(a, c);
613
611
  graph.addEdge(c, d);
614
612
 
615
- const order = [];
616
- graph.forEachNodeIdConnectedTo(d, (node) => {
613
+ const order: Array<any> = [];
614
+ graph.forEachNodeIdConnectedTo(d, (node: any) => {
617
615
  order.push(node);
618
616
  });
619
617
 
@@ -636,8 +634,8 @@ describe('Graph', () => {
636
634
  graph.addEdge(a, c);
637
635
  graph.addEdge(c, d);
638
636
 
639
- const order = [];
640
- graph.forEachNodeIdConnectedFrom(a, (node) => {
637
+ const order: Array<any> = [];
638
+ graph.forEachNodeIdConnectedFrom(a, (node: any) => {
641
639
  order.push(node);
642
640
  });
643
641
 
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }