Skip to content

Commit eec662a

Browse files
committed
feat: add dashjoin.js
1 parent 77de585 commit eec662a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

public/dashjoin.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var DashJoin = ('object' === typeof module && exports) || {};
2+
(function (window, DashJoin) {
3+
'use strict';
4+
5+
const DENOM_LOWEST = 100001;
6+
const PREDENOM_MIN = DENOM_LOWEST + 193;
7+
8+
DashJoin.DENOM_LOWEST = DENOM_LOWEST;
9+
DashJoin.PREDENOM_MIN = PREDENOM_MIN;
10+
DashJoin.DENOMS = [
11+
100001, // 0.00100001
12+
1000010, // 0.01000010
13+
10000100, // 0.10000100
14+
100001000, // 1.00001000
15+
1000010000, // 10.00010000
16+
];
17+
let reverseDenoms = DashJoin.DENOMS.slice(0);
18+
reverseDenoms.reverse();
19+
20+
// Ask Niles if there's an layman-ish obvious way to do this
21+
DashJoin.getDenom = function (sats) {
22+
for (let denom of reverseDenoms) {
23+
let isDenom = sats === denom;
24+
if (isDenom) {
25+
return isDenom;
26+
}
27+
}
28+
29+
return 0;
30+
};
31+
32+
//@ts-ignore
33+
window.DashJoin = DashJoin;
34+
})(globalThis.window || {}, DashJoin);
35+
if ('object' === typeof module) {
36+
module.exports = DashJoin;
37+
}

0 commit comments

Comments
 (0)