queue-typed 1.34.4 → 1.34.6
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/coverage/clover.xml +7 -3
- package/coverage/coverage-final.json +2 -1
- package/coverage/coverage-summary.json +2 -1
- package/coverage/lcov-report/index.html +25 -10
- package/coverage/lcov-report/index.ts.html +109 -0
- package/coverage/lcov.info +14 -0
- package/package.json +2 -2
- package/test/index.test.ts +179 -3
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
4
|
-
<metrics statements="
|
|
2
|
+
<coverage generated="1696760624305" clover="3.2.0">
|
|
3
|
+
<project timestamp="1696760624306" name="All files">
|
|
4
|
+
<metrics statements="1" coveredstatements="1" conditionals="0" coveredconditionals="0" methods="2" coveredmethods="2" elements="3" coveredelements="3" complexity="0" loc="1" ncloc="1" packages="1" files="1" classes="1"/>
|
|
5
|
+
<file name="index.ts" path="/Users/revone/projects/data-structure-typed-individuals/queue-typed/src/index.ts">
|
|
6
|
+
<metrics statements="1" coveredstatements="1" conditionals="0" coveredconditionals="0" methods="2" coveredmethods="2"/>
|
|
7
|
+
<line num="8" count="16" type="stmt"/>
|
|
8
|
+
</file>
|
|
5
9
|
</project>
|
|
6
10
|
</coverage>
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
{}
|
|
1
|
+
{"/Users/revone/projects/data-structure-typed-individuals/queue-typed/src/index.ts": {"path":"/Users/revone/projects/data-structure-typed-individuals/queue-typed/src/index.ts","statementMap":{"0":{"start":{"line":8,"column":0},"end":{"line":8,"column":9}},"1":{"start":{"line":8,"column":9},"end":{"line":8,"column":16}},"2":{"start":{"line":8,"column":16},"end":{"line":8,"column":62}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":8,"column":9},"end":{"line":8,"column":14}},"loc":{"start":{"line":8,"column":9},"end":{"line":8,"column":16}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":8,"column":16},"end":{"line":8,"column":31}},"loc":{"start":{"line":8,"column":16},"end":{"line":8,"column":62}}}},"branchMap":{},"s":{"0":1,"1":16,"2":4},"f":{"0":15,"1":3},"b":{}}
|
|
2
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
{"total": {"lines":{"total":
|
|
1
|
+
{"total": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
|
|
2
|
+
,"/Users/revone/projects/data-structure-typed-individuals/queue-typed/src/index.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
|
|
2
3
|
}
|
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">100% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>3/3</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">100% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
35
|
<span class='fraction'>0/0</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">100% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>2/2</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">100% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>1/1</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
</div>
|
|
62
62
|
</template>
|
|
63
63
|
</div>
|
|
64
|
-
<div class='status-line
|
|
64
|
+
<div class='status-line high'></div>
|
|
65
65
|
<div class="pad1">
|
|
66
66
|
<table class="coverage-summary">
|
|
67
67
|
<thead>
|
|
@@ -78,7 +78,22 @@
|
|
|
78
78
|
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
79
79
|
</tr>
|
|
80
80
|
</thead>
|
|
81
|
-
<tbody
|
|
81
|
+
<tbody><tr>
|
|
82
|
+
<td class="file high" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
|
|
83
|
+
<td data-value="100" class="pic high">
|
|
84
|
+
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
|
|
85
|
+
</td>
|
|
86
|
+
<td data-value="100" class="pct high">100%</td>
|
|
87
|
+
<td data-value="3" class="abs high">3/3</td>
|
|
88
|
+
<td data-value="100" class="pct high">100%</td>
|
|
89
|
+
<td data-value="0" class="abs high">0/0</td>
|
|
90
|
+
<td data-value="100" class="pct high">100%</td>
|
|
91
|
+
<td data-value="2" class="abs high">2/2</td>
|
|
92
|
+
<td data-value="100" class="pct high">100%</td>
|
|
93
|
+
<td data-value="1" class="abs high">1/1</td>
|
|
94
|
+
</tr>
|
|
95
|
+
|
|
96
|
+
</tbody>
|
|
82
97
|
</table>
|
|
83
98
|
</div>
|
|
84
99
|
<div class='push'></div><!-- for sticky footer -->
|
|
@@ -86,7 +101,7 @@
|
|
|
86
101
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
87
102
|
Code coverage generated by
|
|
88
103
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
89
|
-
at 2023-10-
|
|
104
|
+
at 2023-10-08T10:23:44.321Z
|
|
90
105
|
</div>
|
|
91
106
|
<script src="prettify.js"></script>
|
|
92
107
|
<script>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
<title>Code coverage report for index.ts</title>
|
|
7
|
+
<meta charset="utf-8" />
|
|
8
|
+
<link rel="stylesheet" href="prettify.css" />
|
|
9
|
+
<link rel="stylesheet" href="base.css" />
|
|
10
|
+
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
+
<style type='text/css'>
|
|
13
|
+
.coverage-summary .sorter {
|
|
14
|
+
background-image: url(sort-arrow-sprite.png);
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<div class='wrapper'>
|
|
21
|
+
<div class='pad1'>
|
|
22
|
+
<h1><a href="index.html">All files</a> index.ts</h1>
|
|
23
|
+
<div class='clearfix'>
|
|
24
|
+
|
|
25
|
+
<div class='fl pad1y space-right2'>
|
|
26
|
+
<span class="strong">100% </span>
|
|
27
|
+
<span class="quiet">Statements</span>
|
|
28
|
+
<span class='fraction'>3/3</span>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<div class='fl pad1y space-right2'>
|
|
33
|
+
<span class="strong">100% </span>
|
|
34
|
+
<span class="quiet">Branches</span>
|
|
35
|
+
<span class='fraction'>0/0</span>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<div class='fl pad1y space-right2'>
|
|
40
|
+
<span class="strong">100% </span>
|
|
41
|
+
<span class="quiet">Functions</span>
|
|
42
|
+
<span class='fraction'>2/2</span>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<div class='fl pad1y space-right2'>
|
|
47
|
+
<span class="strong">100% </span>
|
|
48
|
+
<span class="quiet">Lines</span>
|
|
49
|
+
<span class='fraction'>1/1</span>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
<p class="quiet">
|
|
55
|
+
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
+
</p>
|
|
57
|
+
<template id="filterTemplate">
|
|
58
|
+
<div class="quiet">
|
|
59
|
+
Filter:
|
|
60
|
+
<input oninput="onInput()" type="search" id="fileSearch">
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
</div>
|
|
64
|
+
<div class='status-line high'></div>
|
|
65
|
+
<pre><table class="coverage">
|
|
66
|
+
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
+
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
+
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
+
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
+
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
+
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
+
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
+
<a name='L8'></a><a href='#L8'>8</a>
|
|
74
|
+
<a name='L9'></a><a href='#L9'>9</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
75
|
+
<span class="cline-any cline-neutral"> </span>
|
|
76
|
+
<span class="cline-any cline-neutral"> </span>
|
|
77
|
+
<span class="cline-any cline-neutral"> </span>
|
|
78
|
+
<span class="cline-any cline-neutral"> </span>
|
|
79
|
+
<span class="cline-any cline-neutral"> </span>
|
|
80
|
+
<span class="cline-any cline-neutral"> </span>
|
|
81
|
+
<span class="cline-any cline-yes">16x</span>
|
|
82
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/**
|
|
83
|
+
* data-structure-typed
|
|
84
|
+
*
|
|
85
|
+
* @author Tyler Zeng
|
|
86
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
87
|
+
* @license MIT License
|
|
88
|
+
*/
|
|
89
|
+
export { Queue, LinkedListQueue } from 'data-structure-typed';
|
|
90
|
+
</pre></td></tr></table></pre>
|
|
91
|
+
|
|
92
|
+
<div class='push'></div><!-- for sticky footer -->
|
|
93
|
+
</div><!-- /wrapper -->
|
|
94
|
+
<div class='footer quiet pad2 space-top1 center small'>
|
|
95
|
+
Code coverage generated by
|
|
96
|
+
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
97
|
+
at 2023-10-08T10:23:44.321Z
|
|
98
|
+
</div>
|
|
99
|
+
<script src="prettify.js"></script>
|
|
100
|
+
<script>
|
|
101
|
+
window.onload = function () {
|
|
102
|
+
prettyPrint();
|
|
103
|
+
};
|
|
104
|
+
</script>
|
|
105
|
+
<script src="sorter.js"></script>
|
|
106
|
+
<script src="block-navigation.js"></script>
|
|
107
|
+
</body>
|
|
108
|
+
</html>
|
|
109
|
+
|
package/coverage/lcov.info
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "queue-typed",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.6",
|
|
4
4
|
"description": "Queue, ArrayQueue. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -114,6 +114,6 @@
|
|
|
114
114
|
"typescript": "^4.9.5"
|
|
115
115
|
},
|
|
116
116
|
"dependencies": {
|
|
117
|
-
"data-structure-typed": "^1.34.
|
|
117
|
+
"data-structure-typed": "^1.34.6"
|
|
118
118
|
}
|
|
119
119
|
}
|
package/test/index.test.ts
CHANGED
|
@@ -1,5 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {Queue, LinkedListQueue} from '../src';
|
|
2
|
+
|
|
3
|
+
describe('Queue Operation Test', () => {
|
|
4
|
+
it('should validate a queue', () => {
|
|
5
|
+
const queue = new Queue<number>();
|
|
6
|
+
for (let i = 0; i < 1000; i++) {
|
|
7
|
+
queue.enqueue(i);
|
|
8
|
+
}
|
|
9
|
+
let last: number | undefined = 0;
|
|
10
|
+
for (let i = 0; i < 1000; i++) {
|
|
11
|
+
last = queue.dequeue();
|
|
12
|
+
}
|
|
13
|
+
expect(last).toBe(999);
|
|
4
14
|
});
|
|
5
15
|
});
|
|
16
|
+
|
|
17
|
+
describe('Queue', () => {
|
|
18
|
+
let queue: Queue<number>;
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
queue = new Queue<number>();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should initialize an empty queue', () => {
|
|
25
|
+
expect(queue.size).toBe(0);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should push elements to the end of the queue', () => {
|
|
29
|
+
queue.push(1);
|
|
30
|
+
queue.push(2);
|
|
31
|
+
expect(queue.peek()).toBe(1);
|
|
32
|
+
expect(queue.size).toBe(2);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// it('should shift elements from the front of the queue', () => {
|
|
36
|
+
// queue.push(1);
|
|
37
|
+
// queue.push(2);
|
|
38
|
+
// const shifted = queue.shift();
|
|
39
|
+
// expect(shifted).toBe(1);
|
|
40
|
+
// expect(queue.peek()).toBe(2);
|
|
41
|
+
// expect(queue.size).toBe(1);
|
|
42
|
+
// });
|
|
43
|
+
//
|
|
44
|
+
// it('should peek at the front of the queue', () => {
|
|
45
|
+
// queue.push(1);
|
|
46
|
+
// queue.push(2);
|
|
47
|
+
// expect(queue.peek()).toBe(1);
|
|
48
|
+
// });
|
|
49
|
+
|
|
50
|
+
// Add more test cases for other methods of Queue.
|
|
51
|
+
});
|
|
52
|
+
describe('Queue', () => {
|
|
53
|
+
let queue: Queue<number>;
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
queue = new Queue<number>();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should initialize an empty queue', () => {
|
|
60
|
+
expect(queue.size).toBe(0);
|
|
61
|
+
expect(queue.isEmpty()).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should push elements to the end of the queue', () => {
|
|
65
|
+
queue.push(1);
|
|
66
|
+
queue.push(2);
|
|
67
|
+
expect(queue.size).toBe(2);
|
|
68
|
+
expect(queue.peek()).toBe(1);
|
|
69
|
+
expect(queue.peekLast()).toBe(2);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should shift elements from the front of the queue', () => {
|
|
73
|
+
queue.push(1);
|
|
74
|
+
queue.push(2);
|
|
75
|
+
const shifted = queue.shift();
|
|
76
|
+
expect(shifted).toBe(1);
|
|
77
|
+
expect(queue.size).toBe(1);
|
|
78
|
+
expect(queue.peek()).toBe(2);
|
|
79
|
+
expect(queue.peekLast()).toBe(2);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should handle shifting when queue reaches half size', () => {
|
|
83
|
+
for (let i = 1; i <= 5; i++) {
|
|
84
|
+
queue.push(i);
|
|
85
|
+
}
|
|
86
|
+
for (let i = 1; i <= 3; i++) {
|
|
87
|
+
queue.shift();
|
|
88
|
+
}
|
|
89
|
+
// Queue size should be 2, but internal array size is still 5.
|
|
90
|
+
// Test that shifting optimizes the internal array.
|
|
91
|
+
expect(queue.size).toBe(2);
|
|
92
|
+
expect(queue.nodes.length).toBe(2);
|
|
93
|
+
expect(queue.peek()).toBe(4);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should peek at the front and end of the queue', () => {
|
|
97
|
+
queue.push(1);
|
|
98
|
+
queue.push(2);
|
|
99
|
+
expect(queue.peek()).toBe(1);
|
|
100
|
+
expect(queue.peekLast()).toBe(2);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should handle shifting when the queue is empty', () => {
|
|
104
|
+
const shifted = queue.shift();
|
|
105
|
+
expect(shifted).toBeUndefined();
|
|
106
|
+
expect(queue.size).toBe(0);
|
|
107
|
+
expect(queue.peek()).toBeUndefined();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should handle peeking when the queue is empty', () => {
|
|
111
|
+
expect(queue.peek()).toBeUndefined();
|
|
112
|
+
expect(queue.peekLast()).toBeUndefined();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should handle clearing the queue', () => {
|
|
116
|
+
for (let i = 1; i <= 3; i++) {
|
|
117
|
+
queue.push(i);
|
|
118
|
+
}
|
|
119
|
+
queue.clear();
|
|
120
|
+
expect(queue.size).toBe(0);
|
|
121
|
+
expect(queue.peek()).toBeUndefined();
|
|
122
|
+
expect(queue.peekLast()).toBeUndefined();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('should clone the queue', () => {
|
|
126
|
+
for (let i = 1; i <= 3; i++) {
|
|
127
|
+
queue.push(i);
|
|
128
|
+
}
|
|
129
|
+
const clonedQueue = queue.clone();
|
|
130
|
+
expect(clonedQueue.size).toBe(3);
|
|
131
|
+
expect(clonedQueue.peek()).toBe(1);
|
|
132
|
+
expect(clonedQueue.peekLast()).toBe(3);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should handle creating a queue from an array', () => {
|
|
136
|
+
const elements = [1, 2, 3, 4, 5];
|
|
137
|
+
const newQueue = Queue.fromArray(elements);
|
|
138
|
+
expect(newQueue.size).toBe(5);
|
|
139
|
+
expect(newQueue.peek()).toBe(1);
|
|
140
|
+
expect(newQueue.peekLast()).toBe(5);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should iterate through the queue', () => {
|
|
144
|
+
for (let i = 1; i <= 3; i++) {
|
|
145
|
+
queue.push(i);
|
|
146
|
+
}
|
|
147
|
+
const values = Array.from(queue);
|
|
148
|
+
expect(values).toEqual([1, 2, 3]);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
describe('LinkedListQueue', () => {
|
|
152
|
+
let queue: LinkedListQueue<string>;
|
|
153
|
+
|
|
154
|
+
beforeEach(() => {
|
|
155
|
+
queue = new LinkedListQueue<string>();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should enqueue elements to the end of the queue', () => {
|
|
159
|
+
queue.enqueue('A');
|
|
160
|
+
queue.enqueue('B');
|
|
161
|
+
expect(queue.peek()).toBe('A');
|
|
162
|
+
expect(queue.length).toBe(2);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should dequeue elements from the front of the queue', () => {
|
|
166
|
+
queue.enqueue('A');
|
|
167
|
+
queue.enqueue('B');
|
|
168
|
+
const dequeued = queue.dequeue();
|
|
169
|
+
expect(dequeued).toBe('A');
|
|
170
|
+
expect(queue.peek()).toBe('B');
|
|
171
|
+
expect(queue.length).toBe(1);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should peek at the front of the queue', () => {
|
|
175
|
+
queue.enqueue('A');
|
|
176
|
+
queue.enqueue('B');
|
|
177
|
+
expect(queue.peek()).toBe('A');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Add more test cases for other methods of LinkedListQueue.
|
|
181
|
+
});
|