Skip to content

Commit

Permalink
feat: add dashjoin.js
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Aug 14, 2024
1 parent 77de585 commit eec662a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions public/dashjoin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var DashJoin = ('object' === typeof module && exports) || {};
(function (window, DashJoin) {
'use strict';

const DENOM_LOWEST = 100001;
const PREDENOM_MIN = DENOM_LOWEST + 193;

DashJoin.DENOM_LOWEST = DENOM_LOWEST;
DashJoin.PREDENOM_MIN = PREDENOM_MIN;
DashJoin.DENOMS = [
100001, // 0.00100001
1000010, // 0.01000010
10000100, // 0.10000100
100001000, // 1.00001000
1000010000, // 10.00010000
];
let reverseDenoms = DashJoin.DENOMS.slice(0);
reverseDenoms.reverse();

// Ask Niles if there's an layman-ish obvious way to do this
DashJoin.getDenom = function (sats) {
for (let denom of reverseDenoms) {
let isDenom = sats === denom;
if (isDenom) {
return isDenom;
}
}

return 0;
};

//@ts-ignore
window.DashJoin = DashJoin;
})(globalThis.window || {}, DashJoin);
if ('object' === typeof module) {
module.exports = DashJoin;
}

0 comments on commit eec662a

Please sign in to comment.