Skip to content

Commit

Permalink
feat!: Remove default export. You need to "import {XSadd} from 'xsadd'"
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed Oct 17, 2024
1 parent d8241bc commit ac4275b
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 34 deletions.
2 changes: 1 addition & 1 deletion coverage/benchmark/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h1><a href="../index.html">All files</a> benchmark</h1>
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-10-17T15:32:01.879Z
at 2024-10-17T15:36:19.406Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/benchmark/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">benchmark</a> i
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-10-17T15:32:01.879Z
at 2024-10-17T15:36:19.406Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
14 changes: 9 additions & 5 deletions coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1729179121972" clover="3.2.0">
<project timestamp="1729179121983" name="All files">
<metrics statements="95" coveredstatements="65" conditionals="19" coveredconditionals="14" methods="9" coveredmethods="8" elements="123" coveredelements="87" complexity="0" loc="95" ncloc="95" packages="2" files="2" classes="2"/>
<coverage generated="1729179379491" clover="3.2.0">
<project timestamp="1729179379491" name="All files">
<metrics statements="96" coveredstatements="66" conditionals="19" coveredconditionals="14" methods="9" coveredmethods="8" elements="124" coveredelements="88" complexity="0" loc="96" ncloc="96" packages="2" files="3" classes="3"/>
<package name="benchmark">
<metrics statements="22" coveredstatements="0" conditionals="1" coveredconditionals="0" methods="1" coveredmethods="0"/>
<file name="index.js" path="/Users/lpatiny/git/mljs/xsadd/benchmark/index.js">
Expand Down Expand Up @@ -31,8 +31,8 @@
</file>
</package>
<package name="src">
<metrics statements="73" coveredstatements="65" conditionals="18" coveredconditionals="14" methods="8" coveredmethods="8"/>
<file name="xsadd.ts" path="/Users/lpatiny/git/mljs/xsadd/src/xsadd.ts">
<metrics statements="74" coveredstatements="66" conditionals="18" coveredconditionals="14" methods="8" coveredmethods="8"/>
<file name="XSadd.ts" path="/Users/lpatiny/git/mljs/xsadd/src/XSadd.ts">
<metrics statements="73" coveredstatements="65" conditionals="18" coveredconditionals="14" methods="8" coveredmethods="8"/>
<line num="1" count="1" type="stmt"/>
<line num="2" count="1" type="stmt"/>
Expand Down Expand Up @@ -108,6 +108,10 @@
<line num="92" count="118" type="stmt"/>
<line num="93" count="10" type="stmt"/>
</file>
<file name="index.ts" path="/Users/lpatiny/git/mljs/xsadd/src/index.ts">
<metrics statements="1" coveredstatements="1" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0"/>
<line num="1" count="1" type="stmt"/>
</file>
</package>
</project>
</coverage>
3 changes: 2 additions & 1 deletion coverage/coverage-final.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions coverage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ <h1>All files</h1>
<div class='clearfix'>

<div class='fl pad1y space-right2'>
<span class="strong">68.42% </span>
<span class="strong">68.75% </span>
<span class="quiet">Statements</span>
<span class='fraction'>65/95</span>
<span class='fraction'>66/96</span>
</div>


Expand All @@ -44,9 +44,9 @@ <h1>All files</h1>


<div class='fl pad1y space-right2'>
<span class="strong">68.42% </span>
<span class="strong">68.75% </span>
<span class="quiet">Lines</span>
<span class='fraction'>65/95</span>
<span class='fraction'>66/96</span>
</div>


Expand Down Expand Up @@ -95,17 +95,17 @@ <h1>All files</h1>

<tr>
<td class="file high" data-value="src"><a href="src/index.html">src</a></td>
<td data-value="89.04" class="pic high">
<td data-value="89.18" class="pic high">
<div class="chart"><div class="cover-fill" style="width: 89%"></div><div class="cover-empty" style="width: 11%"></div></div>
</td>
<td data-value="89.04" class="pct high">89.04%</td>
<td data-value="73" class="abs high">65/73</td>
<td data-value="89.18" class="pct high">89.18%</td>
<td data-value="74" class="abs high">66/74</td>
<td data-value="77.77" class="pct medium">77.77%</td>
<td data-value="18" class="abs medium">14/18</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="8" class="abs high">8/8</td>
<td data-value="89.04" class="pct high">89.04%</td>
<td data-value="73" class="abs high">65/73</td>
<td data-value="89.18" class="pct high">89.18%</td>
<td data-value="74" class="abs high">66/74</td>
</tr>

</tbody>
Expand All @@ -116,7 +116,7 @@ <h1>All files</h1>
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-10-17T15:32:01.879Z
at 2024-10-17T15:36:19.406Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
27 changes: 21 additions & 6 deletions coverage/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ <h1><a href="../index.html">All files</a> src</h1>
<div class='clearfix'>

<div class='fl pad1y space-right2'>
<span class="strong">89.04% </span>
<span class="strong">89.18% </span>
<span class="quiet">Statements</span>
<span class='fraction'>65/73</span>
<span class='fraction'>66/74</span>
</div>


Expand All @@ -44,9 +44,9 @@ <h1><a href="../index.html">All files</a> src</h1>


<div class='fl pad1y space-right2'>
<span class="strong">89.04% </span>
<span class="strong">89.18% </span>
<span class="quiet">Lines</span>
<span class='fraction'>65/73</span>
<span class='fraction'>66/74</span>
</div>


Expand Down Expand Up @@ -79,7 +79,7 @@ <h1><a href="../index.html">All files</a> src</h1>
</tr>
</thead>
<tbody><tr>
<td class="file high" data-value="xsadd.ts"><a href="xsadd.ts.html">xsadd.ts</a></td>
<td class="file high" data-value="XSadd.ts"><a href="XSadd.ts.html">XSadd.ts</a></td>
<td data-value="89.04" class="pic high">
<div class="chart"><div class="cover-fill" style="width: 89%"></div><div class="cover-empty" style="width: 11%"></div></div>
</td>
Expand All @@ -93,6 +93,21 @@ <h1><a href="../index.html">All files</a> src</h1>
<td data-value="73" class="abs high">65/73</td>
</tr>

<tr>
<td class="file high" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
<td data-value="100" class="pic high">
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="1" class="abs high">1/1</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="0" class="abs high">0/0</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="0" class="abs high">0/0</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="1" class="abs high">1/1</td>
</tr>

</tbody>
</table>
</div>
Expand All @@ -101,7 +116,7 @@ <h1><a href="../index.html">All files</a> src</h1>
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-10-17T15:32:01.879Z
at 2024-10-17T15:36:19.406Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
88 changes: 88 additions & 0 deletions coverage/src/index.ts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

<!doctype html>
<html lang="en">

<head>
<title>Code coverage report for src/index.ts</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="../prettify.css" />
<link rel="stylesheet" href="../base.css" />
<link rel="shortcut icon" type="image/x-icon" href="../favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(../sort-arrow-sprite.png);
}
</style>
</head>

<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="../index.html">All files</a> / <a href="index.html">src</a> index.ts</h1>
<div class='clearfix'>

<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>1/1</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>0/0</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>1/1</span>
</div>


</div>
<p class="quiet">
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.
</p>
<template id="filterTemplate">
<div class="quiet">
Filter:
<input type="search" id="fileSearch">
</div>
</template>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">export * from "./XSadd";
&nbsp;</pre></td></tr></table></pre>

<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-10-17T15:36:19.406Z
</div>
<script src="../prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="../sorter.js"></script>
<script src="../block-navigation.js"></script>
</body>
</html>

8 changes: 4 additions & 4 deletions coverage/src/xsadd.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html lang="en">

<head>
<title>Code coverage report for src/xsadd.ts</title>
<title>Code coverage report for src/XSadd.ts</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="../prettify.css" />
<link rel="stylesheet" href="../base.css" />
Expand All @@ -19,7 +19,7 @@
<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="../index.html">All files</a> / <a href="index.html">src</a> xsadd.ts</h1>
<h1><a href="../index.html">All files</a> / <a href="index.html">src</a> XSadd.ts</h1>
<div class='clearfix'>

<div class='fl pad1y space-right2'>
Expand Down Expand Up @@ -264,7 +264,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> xsadd.t
return (((nhi * m) &gt;&gt;&gt; 0) + nlo * m) &gt;&gt;&gt; 0;
}
&nbsp;
export default class XSadd {
export class XSadd {
public random: () =&gt; number;
&nbsp;
private state: Uint32Array;
Expand Down Expand Up @@ -349,7 +349,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> xsadd.t
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-10-17T15:32:01.879Z
at 2024-10-17T15:36:19.406Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"version": "2.0.0",
"description": "JavaScript implementation of the XORSHIFT-ADD (XSadd) pseudo random number generator",
"main": "./lib/xsadd.js",
"module": "./lib-esm/xsadd.js",
"types": "./lib/xsadd.d.ts",
"module": "./lib-esm/index.js",
"types": "./lib/index.d.ts",
"files": [
"src",
"lib",
"lib-esm"
],
"scripts": {
"check-types": "tsc --noEmit",
"clean": "rimraf lib lib-es6",
"clean": "rimraf lib lib-esm",
"eslint": "eslint src",
"eslint-fix": "npm run eslint -- --fix",
"prepack": "npm run tsc",
Expand Down
4 changes: 2 additions & 2 deletions src/xsadd.ts → src/XSadd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function multiplyUint32(n: number, m: number) {
return (((nhi * m) >>> 0) + nlo * m) >>> 0;
}

export default class XSadd {
export class XSadd {
public random: () => number;

private state: Uint32Array;
Expand Down Expand Up @@ -56,7 +56,7 @@ export default class XSadd {
(i +
multiplyUint32(
1812433253,
this.state[(i - 1) & 3] ^ ((this.state[(i - 1) & 3] >>> 30) >>> 0)
this.state[(i - 1) & 3] ^ ((this.state[(i - 1) & 3] >>> 30) >>> 0),
)) >>>
0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";

import XSadd from "../xsadd";
import { XSadd } from "..";

const resultUint32 = [
1823491521, 1658333335, 1467485721, 45623648, 3336175492, 2561136018,
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./XSadd";

0 comments on commit ac4275b

Please sign in to comment.