@library/math 0.0.0-stage → 0.0.7

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.
@@ -0,0 +1,33 @@
1
+ [?25l
2
+  RUN  v5.0.3 /Users/yeonjuan/Desktop/projects/library/packages/math
3
+ Coverage enabled with v8
4
+
5
+ [?2026h
6
+  ❯ src/clamp.spec.ts [queued]
7
+
8
+  Test Files 0 passed (1)
9
+  Tests 0 passed (0)
10
+  Start at 22:55:01
11
+  Duration 101ms
12
+ [?2026l[?2026h ✓ src/clamp.spec.ts (5 tests) 3ms
13
+ ✓ clamp (5)
14
+ ✓ clamp(5, 0, 10) = 5 1ms
15
+ ✓ clamp(-5, 0, 10) = 0 0ms
16
+ ✓ clamp(15, 0, 10) = 10 0ms
17
+ ✓ clamp(0, 0, 10) = 0 0ms
18
+ ✓ clamp(10, 0, 10) = 10 0ms
19
+
20
+  Test Files  1 passed (1)
21
+  Tests  5 passed (5)
22
+  Start at  22:55:01
23
+  Duration  230ms (import 39%, worker 35%, transform 24%, tests 3%)
24
+
25
+ [?2026l % Coverage report from v8
26
+ ----------|---------|----------|---------|---------|-------------------
27
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
28
+ ----------|---------|----------|---------|---------|-------------------
29
+ All files |  100 |  100 |  100 |  100 |  
30
+  clamp.ts |  100 |  100 |  100 |  100 |  
31
+ index.ts | 0 | 0 | 0 | 0 |  
32
+ ----------|---------|----------|---------|---------|-------------------
33
+ [?2026h[?2026l[?25h
package/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
1
+ # @library/math
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Installation
4
+
5
+ **npm**
6
+
7
+ ```console
8
+ npm install @library/math
9
+ ```
10
+
11
+ **yarn**
12
+
13
+ ```console
14
+ yarn add @library/math
15
+ ```
16
+
17
+ ## API
18
+
19
+ - [clamp](#clamp)
20
+
21
+ ### clamp
22
+
23
+ Clamp a number between a lower and upper bound.
24
+
25
+ ```ts
26
+ import { clamp } from "@library/math";
27
+
28
+ clamp(5, 0, 10); // 5
29
+ clamp(-5, 0, 10); // 0
30
+ clamp(15, 0, 10); // 10
31
+ ```
@@ -0,0 +1,362 @@
1
+ body,
2
+ html {
3
+ margin: 0;
4
+ padding: 0;
5
+ height: 100%;
6
+ }
7
+ body {
8
+ font-family:
9
+ Helvetica Neue,
10
+ Helvetica,
11
+ Arial;
12
+ font-size: 14px;
13
+ color: #333;
14
+ }
15
+ .small {
16
+ font-size: 12px;
17
+ }
18
+ *,
19
+ *:after,
20
+ *:before {
21
+ -webkit-box-sizing: border-box;
22
+ -moz-box-sizing: border-box;
23
+ box-sizing: border-box;
24
+ }
25
+ h1 {
26
+ font-size: 20px;
27
+ margin: 0;
28
+ }
29
+ h2 {
30
+ font-size: 14px;
31
+ }
32
+ pre {
33
+ font:
34
+ 12px/1.4 Consolas,
35
+ "Liberation Mono",
36
+ Menlo,
37
+ Courier,
38
+ monospace;
39
+ margin: 0;
40
+ padding: 0;
41
+ -moz-tab-size: 2;
42
+ -o-tab-size: 2;
43
+ tab-size: 2;
44
+ }
45
+ a {
46
+ color: #0074d9;
47
+ text-decoration: none;
48
+ }
49
+ a:hover {
50
+ text-decoration: underline;
51
+ }
52
+ .strong {
53
+ font-weight: bold;
54
+ }
55
+ .space-top1 {
56
+ padding: 10px 0 0 0;
57
+ }
58
+ .pad2y {
59
+ padding: 20px 0;
60
+ }
61
+ .pad1y {
62
+ padding: 10px 0;
63
+ }
64
+ .pad2x {
65
+ padding: 0 20px;
66
+ }
67
+ .pad2 {
68
+ padding: 20px;
69
+ }
70
+ .pad1 {
71
+ padding: 10px;
72
+ }
73
+ .space-left2 {
74
+ padding-left: 55px;
75
+ }
76
+ .space-right2 {
77
+ padding-right: 20px;
78
+ }
79
+ .center {
80
+ text-align: center;
81
+ }
82
+ .clearfix {
83
+ display: block;
84
+ }
85
+ .clearfix:after {
86
+ content: "";
87
+ display: block;
88
+ height: 0;
89
+ clear: both;
90
+ visibility: hidden;
91
+ }
92
+ .fl {
93
+ float: left;
94
+ }
95
+ @media only screen and (max-width: 640px) {
96
+ .col3 {
97
+ width: 100%;
98
+ max-width: 100%;
99
+ }
100
+ .hide-mobile {
101
+ display: none !important;
102
+ }
103
+ }
104
+
105
+ .quiet {
106
+ color: #7f7f7f;
107
+ color: rgba(0, 0, 0, 0.5);
108
+ }
109
+ .quiet a {
110
+ opacity: 0.7;
111
+ }
112
+
113
+ .fraction {
114
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
115
+ font-size: 10px;
116
+ color: #555;
117
+ background: #e8e8e8;
118
+ padding: 4px 5px;
119
+ border-radius: 3px;
120
+ vertical-align: middle;
121
+ }
122
+
123
+ div.path a:link,
124
+ div.path a:visited {
125
+ color: #333;
126
+ }
127
+ table.coverage {
128
+ border-collapse: collapse;
129
+ margin: 10px 0 0 0;
130
+ padding: 0;
131
+ }
132
+
133
+ table.coverage td {
134
+ margin: 0;
135
+ padding: 0;
136
+ vertical-align: top;
137
+ }
138
+ table.coverage td.line-count {
139
+ text-align: right;
140
+ padding: 0 5px 0 20px;
141
+ }
142
+ table.coverage td.line-coverage {
143
+ text-align: right;
144
+ padding-right: 10px;
145
+ min-width: 20px;
146
+ }
147
+
148
+ table.coverage td span.cline-any {
149
+ display: inline-block;
150
+ padding: 0 5px;
151
+ width: 100%;
152
+ }
153
+ .missing-if-branch {
154
+ display: inline-block;
155
+ margin-right: 5px;
156
+ border-radius: 3px;
157
+ position: relative;
158
+ padding: 0 4px;
159
+ background: #333;
160
+ color: yellow;
161
+ }
162
+
163
+ .skip-if-branch {
164
+ display: none;
165
+ margin-right: 10px;
166
+ position: relative;
167
+ padding: 0 4px;
168
+ background: #ccc;
169
+ color: white;
170
+ }
171
+ .missing-if-branch .typ,
172
+ .skip-if-branch .typ {
173
+ color: inherit !important;
174
+ }
175
+ .coverage-summary {
176
+ border-collapse: collapse;
177
+ width: 100%;
178
+ }
179
+ .coverage-summary tr {
180
+ border-bottom: 1px solid #bbb;
181
+ }
182
+ .keyline-all {
183
+ border: 1px solid #ddd;
184
+ }
185
+ .coverage-summary td,
186
+ .coverage-summary th {
187
+ padding: 10px;
188
+ }
189
+ .coverage-summary tbody {
190
+ border: 1px solid #bbb;
191
+ }
192
+ .coverage-summary td {
193
+ border-right: 1px solid #bbb;
194
+ }
195
+ .coverage-summary td:last-child {
196
+ border-right: none;
197
+ }
198
+ .coverage-summary th {
199
+ text-align: left;
200
+ font-weight: normal;
201
+ white-space: nowrap;
202
+ }
203
+ .coverage-summary th.file {
204
+ border-right: none !important;
205
+ }
206
+ .coverage-summary th.pct {
207
+ }
208
+ .coverage-summary th.pic,
209
+ .coverage-summary th.abs,
210
+ .coverage-summary td.pct,
211
+ .coverage-summary td.abs {
212
+ text-align: right;
213
+ }
214
+ .coverage-summary td.file {
215
+ white-space: nowrap;
216
+ }
217
+ .coverage-summary td.pic {
218
+ min-width: 120px !important;
219
+ }
220
+ .coverage-summary tfoot td {
221
+ }
222
+
223
+ .coverage-summary .sorter {
224
+ height: 10px;
225
+ width: 7px;
226
+ display: inline-block;
227
+ margin-left: 0.5em;
228
+ background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
229
+ }
230
+ .coverage-summary .sorted .sorter {
231
+ background-position: 0 -20px;
232
+ }
233
+ .coverage-summary .sorted-desc .sorter {
234
+ background-position: 0 -10px;
235
+ }
236
+ .status-line {
237
+ height: 10px;
238
+ }
239
+ /* yellow */
240
+ .cbranch-no {
241
+ background: yellow !important;
242
+ color: #111;
243
+ }
244
+ /* dark red */
245
+ .red.solid,
246
+ .status-line.low,
247
+ .low .cover-fill {
248
+ background: #c21f39;
249
+ }
250
+ .low .chart {
251
+ border: 1px solid #c21f39;
252
+ }
253
+ .highlighted,
254
+ .highlighted .cstat-no,
255
+ .highlighted .fstat-no,
256
+ .highlighted .cbranch-no {
257
+ background: #c21f39 !important;
258
+ }
259
+ /* medium red */
260
+ .cstat-no,
261
+ .fstat-no,
262
+ .cbranch-no,
263
+ .cbranch-no {
264
+ background: #f6c6ce;
265
+ }
266
+ /* light red */
267
+ .low,
268
+ .cline-no {
269
+ background: #fce1e5;
270
+ }
271
+ /* light green */
272
+ .high,
273
+ .cline-yes {
274
+ background: rgb(230, 245, 208);
275
+ }
276
+ /* medium green */
277
+ .cstat-yes {
278
+ background: rgb(161, 215, 106);
279
+ }
280
+ /* dark green */
281
+ .status-line.high,
282
+ .high .cover-fill {
283
+ background: rgb(77, 146, 33);
284
+ }
285
+ .high .chart {
286
+ border: 1px solid rgb(77, 146, 33);
287
+ }
288
+ /* dark yellow (gold) */
289
+ .status-line.medium,
290
+ .medium .cover-fill {
291
+ background: #f9cd0b;
292
+ }
293
+ .medium .chart {
294
+ border: 1px solid #f9cd0b;
295
+ }
296
+ /* light yellow */
297
+ .medium {
298
+ background: #fff4c2;
299
+ }
300
+
301
+ .cstat-skip {
302
+ background: #ddd;
303
+ color: #111;
304
+ }
305
+ .fstat-skip {
306
+ background: #ddd;
307
+ color: #111 !important;
308
+ }
309
+ .cbranch-skip {
310
+ background: #ddd !important;
311
+ color: #111;
312
+ }
313
+
314
+ span.cline-neutral {
315
+ background: #eaeaea;
316
+ }
317
+
318
+ .coverage-summary td.empty {
319
+ opacity: 0.5;
320
+ padding-top: 4px;
321
+ padding-bottom: 4px;
322
+ line-height: 1;
323
+ color: #888;
324
+ }
325
+
326
+ .cover-fill,
327
+ .cover-empty {
328
+ display: inline-block;
329
+ height: 12px;
330
+ }
331
+ .chart {
332
+ line-height: 0;
333
+ }
334
+ .cover-empty {
335
+ background: white;
336
+ }
337
+ .cover-full {
338
+ border-right: none !important;
339
+ }
340
+ pre.prettyprint {
341
+ border: none !important;
342
+ padding: 0 !important;
343
+ margin: 0 !important;
344
+ }
345
+ .com {
346
+ color: #999 !important;
347
+ }
348
+ .ignore-none {
349
+ color: #999;
350
+ font-weight: normal;
351
+ }
352
+
353
+ .wrapper {
354
+ min-height: 100%;
355
+ height: auto !important;
356
+ height: 100%;
357
+ margin: 0 auto -48px;
358
+ }
359
+ .footer,
360
+ .push {
361
+ height: 48px;
362
+ }
@@ -0,0 +1,82 @@
1
+ /* eslint-disable */
2
+ var jumpToCode = (function init() {
3
+ // Classes of code we would like to highlight in the file view
4
+ var missingCoverageClasses = [".cbranch-no", ".cstat-no", ".fstat-no"];
5
+
6
+ // Elements to highlight in the file listing view
7
+ var fileListingElements = ["td.pct.low"];
8
+
9
+ // We don't want to select elements that are direct descendants of another match
10
+ var notSelector = ":not(" + missingCoverageClasses.join("):not(") + ") > "; // becomes `:not(a):not(b) > `
11
+
12
+ // Selector that finds elements on the page to which we can jump
13
+ var selector =
14
+ fileListingElements.join(", ") +
15
+ ", " +
16
+ notSelector +
17
+ missingCoverageClasses.join(", " + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
18
+
19
+ // The NodeList of matching elements
20
+ var missingCoverageElements = document.querySelectorAll(selector);
21
+
22
+ var currentIndex;
23
+
24
+ function toggleClass(index) {
25
+ missingCoverageElements.item(currentIndex).classList.remove("highlighted");
26
+ missingCoverageElements.item(index).classList.add("highlighted");
27
+ }
28
+
29
+ function makeCurrent(index) {
30
+ toggleClass(index);
31
+ currentIndex = index;
32
+ missingCoverageElements.item(index).scrollIntoView({
33
+ behavior: "smooth",
34
+ block: "center",
35
+ inline: "center",
36
+ });
37
+ }
38
+
39
+ function goToPrevious() {
40
+ var nextIndex = 0;
41
+ if (typeof currentIndex !== "number" || currentIndex === 0) {
42
+ nextIndex = missingCoverageElements.length - 1;
43
+ } else if (missingCoverageElements.length > 1) {
44
+ nextIndex = currentIndex - 1;
45
+ }
46
+
47
+ makeCurrent(nextIndex);
48
+ }
49
+
50
+ function goToNext() {
51
+ var nextIndex = 0;
52
+
53
+ if (typeof currentIndex === "number" && currentIndex < missingCoverageElements.length - 1) {
54
+ nextIndex = currentIndex + 1;
55
+ }
56
+
57
+ makeCurrent(nextIndex);
58
+ }
59
+
60
+ return function jump(event) {
61
+ if (
62
+ document.getElementById("fileSearch") === document.activeElement &&
63
+ document.activeElement != null
64
+ ) {
65
+ // if we're currently focused on the search input, we don't want to navigate
66
+ return;
67
+ }
68
+
69
+ switch (event.which) {
70
+ case 78: // n
71
+ case 74: // j
72
+ goToNext();
73
+ break;
74
+ case 66: // b
75
+ case 75: // k
76
+ case 80: // p
77
+ goToPrevious();
78
+ break;
79
+ }
80
+ };
81
+ })();
82
+ window.addEventListener("keydown", jumpToCode);
@@ -0,0 +1,133 @@
1
+
2
+ <!doctype html>
3
+ <html lang="en">
4
+
5
+ <head>
6
+ <title>Code coverage report for clamp.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> clamp.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'>1/1</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'>1/1</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 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>
75
+ <a name='L10'></a><a href='#L10'>10</a>
76
+ <a name='L11'></a><a href='#L11'>11</a>
77
+ <a name='L12'></a><a href='#L12'>12</a>
78
+ <a name='L13'></a><a href='#L13'>13</a>
79
+ <a name='L14'></a><a href='#L14'>14</a>
80
+ <a name='L15'></a><a href='#L15'>15</a>
81
+ <a name='L16'></a><a href='#L16'>16</a>
82
+ <a name='L17'></a><a href='#L17'>17</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
83
+ <span class="cline-any cline-neutral">&nbsp;</span>
84
+ <span class="cline-any cline-neutral">&nbsp;</span>
85
+ <span class="cline-any cline-neutral">&nbsp;</span>
86
+ <span class="cline-any cline-neutral">&nbsp;</span>
87
+ <span class="cline-any cline-neutral">&nbsp;</span>
88
+ <span class="cline-any cline-neutral">&nbsp;</span>
89
+ <span class="cline-any cline-neutral">&nbsp;</span>
90
+ <span class="cline-any cline-neutral">&nbsp;</span>
91
+ <span class="cline-any cline-neutral">&nbsp;</span>
92
+ <span class="cline-any cline-neutral">&nbsp;</span>
93
+ <span class="cline-any cline-neutral">&nbsp;</span>
94
+ <span class="cline-any cline-neutral">&nbsp;</span>
95
+ <span class="cline-any cline-neutral">&nbsp;</span>
96
+ <span class="cline-any cline-yes">5x</span>
97
+ <span class="cline-any cline-neutral">&nbsp;</span>
98
+ <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">/**
99
+ * @param {number} value The number to clamp.
100
+ * @param {number} min The lower bound.
101
+ * @param {number} max The upper bound.
102
+ * @returns {number} The clamped number.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * clamp(5, 0, 10); // 5
107
+ * clamp(-5, 0, 10); // 0
108
+ * clamp(15, 0, 10); // 10
109
+ * ```
110
+ */
111
+ export function clamp(value: number, min: number, max: number): number {
112
+ return Math.min(Math.max(value, min), max);
113
+ }
114
+ &nbsp;</pre></td></tr></table></pre>
115
+
116
+ <div class='push'></div><!-- for sticky footer -->
117
+ </div><!-- /wrapper -->
118
+ <div class='footer quiet pad2 space-top1 center small'>
119
+ Code coverage generated by
120
+ <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
121
+ at 2026-10-08T13:55:02.151Z
122
+ </div>
123
+ <script src="prettify.js"></script>
124
+ <script>
125
+ window.onload = function () {
126
+ prettyPrint();
127
+ };
128
+ </script>
129
+ <script src="sorter.js"></script>
130
+ <script src="block-navigation.js"></script>
131
+ </body>
132
+ </html>
133
+
Binary file