data-structure-typed 1.43.1 → 1.43.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.
Files changed (70) hide show
  1. package/.eslintrc.js +3 -1
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +7 -0
  4. package/benchmark/report.html +30 -30
  5. package/benchmark/report.json +201 -147
  6. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
  7. package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
  8. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +62 -62
  9. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
  10. package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
  12. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +1 -1
  13. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
  14. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
  15. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
  16. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +1 -1
  17. package/dist/cjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
  18. package/dist/cjs/src/data-structures/graph/abstract-graph.js +37 -37
  19. package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -1
  20. package/dist/cjs/src/data-structures/graph/directed-graph.js.map +1 -1
  21. package/dist/cjs/src/data-structures/graph/map-graph.js.map +1 -1
  22. package/dist/cjs/src/data-structures/graph/undirected-graph.js.map +1 -1
  23. package/dist/cjs/src/data-structures/heap/heap.js.map +1 -1
  24. package/dist/cjs/src/interfaces/binary-tree.d.ts +1 -1
  25. package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
  26. package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +62 -62
  27. package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
  28. package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +1 -1
  29. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
  30. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
  31. package/dist/mjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
  32. package/dist/mjs/src/data-structures/graph/abstract-graph.js +37 -37
  33. package/dist/mjs/src/interfaces/binary-tree.d.ts +1 -1
  34. package/dist/umd/data-structure-typed.js +10497 -0
  35. package/dist/umd/data-structure-typed.min.js +1 -1
  36. package/dist/umd/data-structure-typed.min.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/data-structures/binary-tree/avl-tree.ts +2 -3
  39. package/src/data-structures/binary-tree/binary-tree.ts +85 -92
  40. package/src/data-structures/binary-tree/bst.ts +14 -22
  41. package/src/data-structures/binary-tree/rb-tree.ts +11 -20
  42. package/src/data-structures/binary-tree/tree-multimap.ts +56 -58
  43. package/src/data-structures/graph/abstract-graph.ts +6 -22
  44. package/src/data-structures/graph/directed-graph.ts +3 -9
  45. package/src/data-structures/graph/map-graph.ts +6 -6
  46. package/src/data-structures/graph/undirected-graph.ts +1 -2
  47. package/src/data-structures/heap/heap.ts +1 -6
  48. package/src/data-structures/trie/trie.ts +1 -1
  49. package/src/interfaces/binary-tree.ts +1 -1
  50. package/src/types/utils/validate-type.ts +2 -16
  51. package/test/integration/index.html +50 -4
  52. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +18 -19
  53. package/test/performance/data-structures/hash/hash-map.test.ts +10 -13
  54. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +16 -16
  55. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +1 -3
  56. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +10 -12
  57. package/test/performance/data-structures/queue/deque.test.ts +18 -19
  58. package/test/performance/data-structures/queue/queue.test.ts +18 -19
  59. package/test/performance/data-structures/stack/stack.test.ts +10 -11
  60. package/test/performance/reportor.ts +4 -5
  61. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -1
  62. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +83 -61
  63. package/test/unit/data-structures/binary-tree/bst.test.ts +2 -6
  64. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +34 -25
  65. package/test/unit/data-structures/graph/abstract-graph.test.ts +6 -6
  66. package/test/unit/data-structures/graph/directed-graph.test.ts +8 -28
  67. package/test/unit/data-structures/heap/heap.test.ts +1 -8
  68. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +34 -12
  69. package/test/utils/json2html.ts +2 -6
  70. package/tsup.config.js +19 -1
@@ -1,6 +1,8 @@
1
1
  import {PriorityQueue} from '../../../../src';
2
- import {getRandomInt} from '../../../utils';
2
+ import {PriorityQueue as CPriorityQueue} from 'js-sdsl';
3
+ import {isDebugTest} from '../../../config';
3
4
 
5
+ const isDebug = isDebugTest;
4
6
  describe('PriorityQueue Operation Test', () => {
5
7
  it('should PriorityQueue poll, pee, heapify, toArray work well', function () {
6
8
  const minPQ = new PriorityQueue<number>({comparator: (a, b) => a - b});
@@ -11,9 +13,9 @@ describe('PriorityQueue Operation Test', () => {
11
13
  minPQ.poll();
12
14
  expect(minPQ.toArray()).toEqual([4, 5, 6]);
13
15
  expect(minPQ.peek()).toBe(4);
14
- expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual(
15
- [1, 2, 3, 5, 6, 7, 8, 9, 10]
16
- );
16
+ expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual([
17
+ 1, 2, 3, 5, 6, 7, 8, 9, 10
18
+ ]);
17
19
  });
18
20
 
19
21
  it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () {
@@ -25,9 +27,9 @@ describe('PriorityQueue Operation Test', () => {
25
27
  maxPriorityQueue.poll();
26
28
  expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]);
27
29
  expect(maxPriorityQueue.peek()).toBe(3);
28
- expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual(
29
- [1, 2, 3, 5, 6, 7, 8, 9, 10]
30
- );
30
+ expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual([
31
+ 1, 2, 3, 5, 6, 7, 8, 9, 10
32
+ ]);
31
33
  });
32
34
 
33
35
  it('should PriorityQueue clone, sort, getNodes, dfs work well', function () {
@@ -44,10 +46,30 @@ describe('PriorityQueue Operation Test', () => {
44
46
 
45
47
  describe('Priority Queue Performance Test', () => {
46
48
  it('should numeric heap work well', function () {
47
- const values = Array.from(new Array(10000), () => getRandomInt(1, 10000000));
48
- const minPriorityQueue = new PriorityQueue<number>({comparator: (a, b) => a - b});
49
- minPriorityQueue.refill(values);
50
- const sorted = minPriorityQueue.sort();
51
- expect(sorted).toEqual(values.sort((a, b) => a - b));
49
+ const pq = new PriorityQueue({comparator: (a, b) => b - a});
50
+
51
+ const tS = performance.now();
52
+
53
+ for (let i = 0; i < 100000; i++) {
54
+ pq.add(i);
55
+ }
56
+
57
+ // for (let i = 0; i < 10000; i++) {
58
+ // pq.pop();
59
+ // }
60
+ isDebug && console.log(performance.now() - tS);
61
+ isDebug && console.log(pq.size);
62
+ const cS = performance.now();
63
+ const cpq = new CPriorityQueue();
64
+
65
+ for (let i = 0; i < 100000; i++) {
66
+ cpq.push(i);
67
+ }
68
+ //
69
+ // for (let i = 0; i < 10000; i++) {
70
+ // cpq.pop();
71
+ // }
72
+ isDebug && console.log(performance.now() - cS);
73
+ isDebug && console.log(cpq.size());
52
74
  });
53
75
  });
@@ -14,9 +14,7 @@ function makeLabelDiv(options: any, level: number, keyName: string | number, dat
14
14
  return `<div class='index'><span class='json-to-html-label'>${keyName}&nbsp;</span></div>`;
15
15
  } else if (typeof keyName === 'string') {
16
16
  if (datatype === 'array') {
17
- return `<div class='collapsible level${level}' ${toggleJS(
18
- options
19
- )}><span class='json-to-html-label'>${keyName}</span></div>`;
17
+ return `<div class='collapsible level${level}' ${toggleJS(options)}><span class='json-to-html-label'>${keyName}</span></div>`;
20
18
  } else if (datatype === 'object') {
21
19
  return `<div class='attribute collapsible level${level}' ${toggleJS(
22
20
  options
@@ -122,9 +120,7 @@ function _render(name: string, data: any, options: Json2htmlOptions, level: numb
122
120
  } else {
123
121
  subs =
124
122
  "<div class='altRows'>" +
125
- data
126
- .map((val: any, idx: number) => _render(idx.toString(), val, options, level + 1, idx % 2))
127
- .join("</div><div class='altRows'>") +
123
+ data.map((val: any, idx: number) => _render(idx.toString(), val, options, level + 1, idx % 2)).join("</div><div class='altRows'>") +
128
124
  '</div>';
129
125
  }
130
126
  return `<div class="json-to-html-collapse clearfix ${altRow}">
package/tsup.config.js CHANGED
@@ -15,4 +15,22 @@ export default [{
15
15
  js: `.min.js`,
16
16
  }
17
17
  },
18
- }];
18
+ },
19
+ {
20
+ entryPoints: {
21
+ "data-structure-typed": "src/index.ts"
22
+ },
23
+ format: ["iife"],
24
+ clean: true,
25
+ sourcemap: false,
26
+ minify: false,
27
+ outDir: "dist/umd",
28
+ globalName: "dataStructureTyped",
29
+ platform: "browser",
30
+ bundle: true,
31
+ outExtension() {
32
+ return {
33
+ js: `.js`,
34
+ }
35
+ },
36
+ }];