@argent/x-shared 1.57.0 → 1.58.0

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,7 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("../../../../../_virtual/numeral2.cjs");/*! @preserve
2
+ * numeral.js
3
+ * version : 2.0.6
4
+ * author : Adam Draper
5
+ * license : MIT
6
+ * http://adamwdraper.github.com/Numeral-js/
7
+ */var O=B.__module.exports,P;function L(){return P||(P=1,function(S){(function(n,m){S.exports?S.exports=m():n.numeral=m()})(O,function(){var n,m,E="2.0.6",_={},N={},y={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},c={currentLocale:y.currentLocale,zeroFormat:y.zeroFormat,nullFormat:y.nullFormat,defaultFormat:y.defaultFormat,scalePercentBy100:y.scalePercentBy100};function M(e,r){this._input=e,this._value=r}return n=function(e){var r,l,i,t;if(n.isNumeral(e))r=e.value();else if(e===0||typeof e>"u")r=0;else if(e===null||m.isNaN(e))r=null;else if(typeof e=="string")if(c.zeroFormat&&e===c.zeroFormat)r=0;else if(c.nullFormat&&e===c.nullFormat||!e.replace(/[^0-9]+/g,"").length)r=null;else{for(l in _)if(t=typeof _[l].regexps.unformat=="function"?_[l].regexps.unformat():_[l].regexps.unformat,t&&e.match(t)){i=_[l].unformat;break}i=i||n._.stringToNumber,r=i(e)}else r=Number(e)||null;return new M(e,r)},n.version=E,n.isNumeral=function(e){return e instanceof M},n._=m={numberToFormat:function(e,r,l){var i=N[n.options.currentLocale],t=!1,o=!1,a=0,u="",f=1e12,s=1e9,d=1e6,w=1e3,h="",v=!1,p,x,b,g,T,$,F;if(e=e||0,x=Math.abs(e),n._.includes(r,"(")?(t=!0,r=r.replace(/[\(|\)]/g,"")):(n._.includes(r,"+")||n._.includes(r,"-"))&&(T=n._.includes(r,"+")?r.indexOf("+"):e<0?r.indexOf("-"):-1,r=r.replace(/[\+|\-]/g,"")),n._.includes(r,"a")&&(p=r.match(/a(k|m|b|t)?/),p=p?p[1]:!1,n._.includes(r," a")&&(u=" "),r=r.replace(new RegExp(u+"a[kmbt]?"),""),x>=f&&!p||p==="t"?(u+=i.abbreviations.trillion,e=e/f):x<f&&x>=s&&!p||p==="b"?(u+=i.abbreviations.billion,e=e/s):x<s&&x>=d&&!p||p==="m"?(u+=i.abbreviations.million,e=e/d):(x<d&&x>=w&&!p||p==="k")&&(u+=i.abbreviations.thousand,e=e/w)),n._.includes(r,"[.]")&&(o=!0,r=r.replace("[.]",".")),b=e.toString().split(".")[0],g=r.split(".")[1],$=r.indexOf(","),a=(r.split(".")[0].split(",")[0].match(/0/g)||[]).length,g?(n._.includes(g,"[")?(g=g.replace("]",""),g=g.split("["),h=n._.toFixed(e,g[0].length+g[1].length,l,g[1].length)):h=n._.toFixed(e,g.length,l),b=h.split(".")[0],n._.includes(h,".")?h=i.delimiters.decimal+h.split(".")[1]:h="",o&&Number(h.slice(1))===0&&(h="")):b=n._.toFixed(e,0,l),u&&!p&&Number(b)>=1e3&&u!==i.abbreviations.trillion)switch(b=String(Number(b)/1e3),u){case i.abbreviations.thousand:u=i.abbreviations.million;break;case i.abbreviations.million:u=i.abbreviations.billion;break;case i.abbreviations.billion:u=i.abbreviations.trillion;break}if(n._.includes(b,"-")&&(b=b.slice(1),v=!0),b.length<a)for(var k=a-b.length;k>0;k--)b="0"+b;return $>-1&&(b=b.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+i.delimiters.thousands)),r.indexOf(".")===0&&(b=""),F=b+h+(u||""),t?F=(t&&v?"(":"")+F+(t&&v?")":""):T>=0?F=T===0?(v?"-":"+")+F:F+(v?"-":"+"):v&&(F="-"+F),F},stringToNumber:function(e){var r=N[c.currentLocale],l=e,i={thousand:3,million:6,billion:9,trillion:12},t,o,a;if(c.zeroFormat&&e===c.zeroFormat)o=0;else if(c.nullFormat&&e===c.nullFormat||!e.replace(/[^0-9]+/g,"").length)o=null;else{o=1,r.delimiters.decimal!=="."&&(e=e.replace(/\./g,"").replace(r.delimiters.decimal,"."));for(t in i)if(a=new RegExp("[^a-zA-Z]"+r.abbreviations[t]+"(?:\\)|(\\"+r.currency.symbol+")?(?:\\))?)?$"),l.match(a)){o*=Math.pow(10,i[t]);break}o*=(e.split("-").length+Math.min(e.split("(").length-1,e.split(")").length-1))%2?1:-1,e=e.replace(/[^0-9\.]+/g,""),o*=Number(e)}return o},isNaN:function(e){return typeof e=="number"&&isNaN(e)},includes:function(e,r){return e.indexOf(r)!==-1},insert:function(e,r,l){return e.slice(0,l)+r+e.slice(l)},reduce:function(e,r){if(this===null)throw new TypeError("Array.prototype.reduce called on null or undefined");if(typeof r!="function")throw new TypeError(r+" is not a function");var l=Object(e),i=l.length>>>0,t=0,o;if(arguments.length===3)o=arguments[2];else{for(;t<i&&!(t in l);)t++;if(t>=i)throw new TypeError("Reduce of empty array with no initial value");o=l[t++]}for(;t<i;t++)t in l&&(o=r(o,l[t],t,l));return o},multiplier:function(e){var r=e.toString().split(".");return r.length<2?1:Math.pow(10,r[1].length)},correctionFactor:function(){var e=Array.prototype.slice.call(arguments);return e.reduce(function(r,l){var i=m.multiplier(l);return r>i?r:i},1)},toFixed:function(e,r,l,i){var t=e.toString().split("."),o=r-(i||0),a,u,f,s;return t.length===2?a=Math.min(Math.max(t[1].length,o),r):a=o,f=Math.pow(10,a),s=(l(e+"e+"+a)/f).toFixed(a),i>r-a&&(u=new RegExp("\\.?0{1,"+(i-(r-a))+"}$"),s=s.replace(u,"")),s}},n.options=c,n.formats=_,n.locales=N,n.locale=function(e){return e&&(c.currentLocale=e.toLowerCase()),c.currentLocale},n.localeData=function(e){if(!e)return N[c.currentLocale];if(e=e.toLowerCase(),!N[e])throw new Error("Unknown locale : "+e);return N[e]},n.reset=function(){for(var e in y)c[e]=y[e]},n.zeroFormat=function(e){c.zeroFormat=typeof e=="string"?e:null},n.nullFormat=function(e){c.nullFormat=typeof e=="string"?e:null},n.defaultFormat=function(e){c.defaultFormat=typeof e=="string"?e:"0.0"},n.register=function(e,r,l){if(r=r.toLowerCase(),this[e+"s"][r])throw new TypeError(r+" "+e+" already registered.");return this[e+"s"][r]=l,l},n.validate=function(e,r){var l,i,t,o,a,u,f,s;if(typeof e!="string"&&(e+=""),e=e.trim(),e.match(/^\d+$/))return!0;if(e==="")return!1;try{f=n.localeData(r)}catch{f=n.localeData(n.locale())}return t=f.currency.symbol,a=f.abbreviations,l=f.delimiters.decimal,f.delimiters.thousands==="."?i="\\.":i=f.delimiters.thousands,s=e.match(/^[^\d]+/),s!==null&&(e=e.substr(1),s[0]!==t)||(s=e.match(/[^\d]+$/),s!==null&&(e=e.slice(0,-1),s[0]!==a.thousand&&s[0]!==a.million&&s[0]!==a.billion&&s[0]!==a.trillion))?!1:(u=new RegExp(i+"{2}"),e.match(/[^\d.,]/g)?!1:(o=e.split(l),o.length>2?!1:o.length<2?!!o[0].match(/^\d+.*\d$/)&&!o[0].match(u):o[0].length===1?!!o[0].match(/^\d+$/)&&!o[0].match(u)&&!!o[1].match(/^\d+$/):!!o[0].match(/^\d+.*\d$/)&&!o[0].match(u)&&!!o[1].match(/^\d+$/)))},n.fn=M.prototype={clone:function(){return n(this)},format:function(e,r){var l=this._value,i=e||c.defaultFormat,t,o,a;if(r=r||Math.round,l===0&&c.zeroFormat!==null)o=c.zeroFormat;else if(l===null&&c.nullFormat!==null)o=c.nullFormat;else{for(t in _)if(i.match(_[t].regexps.format)){a=_[t].format;break}a=a||n._.numberToFormat,o=a(l,i,r)}return o},value:function(){return this._value},input:function(){return this._input},set:function(e){return this._value=Number(e),this},add:function(e){var r=m.correctionFactor.call(null,this._value,e);function l(i,t,o,a){return i+Math.round(r*t)}return this._value=m.reduce([this._value,e],l,0)/r,this},subtract:function(e){var r=m.correctionFactor.call(null,this._value,e);function l(i,t,o,a){return i-Math.round(r*t)}return this._value=m.reduce([e],l,Math.round(this._value*r))/r,this},multiply:function(e){function r(l,i,t,o){var a=m.correctionFactor(l,i);return Math.round(l*a)*Math.round(i*a)/Math.round(a*a)}return this._value=m.reduce([this._value,e],r,1),this},divide:function(e){function r(l,i,t,o){var a=m.correctionFactor(l,i);return Math.round(l*a)/Math.round(i*a)}return this._value=m.reduce([this._value,e],r),this},difference:function(e){return Math.abs(n(this._value).subtract(e).value())}},n.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(e){var r=e%10;return~~(e%100/10)===1?"th":r===1?"st":r===2?"nd":r===3?"rd":"th"},currency:{symbol:"$"}}),function(){n.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(e,r,l){var i=n._.includes(r," BPS")?" ":"",t;return e=e*1e4,r=r.replace(/\s?BPS/,""),t=n._.numberToFormat(e,r,l),n._.includes(t,")")?(t=t.split(""),t.splice(-1,0,i+"BPS"),t=t.join("")):t=t+i+"BPS",t},unformat:function(e){return+(n._.stringToNumber(e)*1e-4).toFixed(15)}})}(),function(){var e={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},r={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},l=e.suffixes.concat(r.suffixes.filter(function(t){return e.suffixes.indexOf(t)<0})),i=l.join("|");i="("+i.replace("B","B(?!PS)")+")",n.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(i)},format:function(t,o,a){var u,f=n._.includes(o,"ib")?r:e,s=n._.includes(o," b")||n._.includes(o," ib")?" ":"",d,w,h;for(o=o.replace(/\s?i?b/,""),d=0;d<=f.suffixes.length;d++)if(w=Math.pow(f.base,d),h=Math.pow(f.base,d+1),t===null||t===0||t>=w&&t<h){s+=f.suffixes[d],w>0&&(t=t/w);break}return u=n._.numberToFormat(t,o,a),u+s},unformat:function(t){var o=n._.stringToNumber(t),a,u;if(o){for(a=e.suffixes.length-1;a>=0;a--){if(n._.includes(t,e.suffixes[a])){u=Math.pow(e.base,a);break}if(n._.includes(t,r.suffixes[a])){u=Math.pow(r.base,a);break}}o*=u||1}return o}})}(),function(){n.register("format","currency",{regexps:{format:/(\$)/},format:function(e,r,l){var i=n.locales[n.options.currentLocale],t={before:r.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:r.match(/([\+|\-|\)|\s|\$]*)$/)[0]},o,a,u;for(r=r.replace(/\s?\$\s?/,""),o=n._.numberToFormat(e,r,l),e>=0?(t.before=t.before.replace(/[\-\(]/,""),t.after=t.after.replace(/[\-\)]/,"")):e<0&&!n._.includes(t.before,"-")&&!n._.includes(t.before,"(")&&(t.before="-"+t.before),u=0;u<t.before.length;u++)switch(a=t.before[u],a){case"$":o=n._.insert(o,i.currency.symbol,u);break;case" ":o=n._.insert(o," ",u+i.currency.symbol.length-1);break}for(u=t.after.length-1;u>=0;u--)switch(a=t.after[u],a){case"$":o=u===t.after.length-1?o+i.currency.symbol:n._.insert(o,i.currency.symbol,-(t.after.length-(1+u)));break;case" ":o=u===t.after.length-1?o+" ":n._.insert(o," ",-(t.after.length-(1+u)+i.currency.symbol.length-1));break}return o}})}(),function(){n.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(e,r,l){var i,t=typeof e=="number"&&!n._.isNaN(e)?e.toExponential():"0e+0",o=t.split("e");return r=r.replace(/e[\+|\-]{1}0/,""),i=n._.numberToFormat(Number(o[0]),r,l),i+"e"+o[1]},unformat:function(e){var r=n._.includes(e,"e+")?e.split("e+"):e.split("e-"),l=Number(r[0]),i=Number(r[1]);i=n._.includes(e,"e-")?i*=-1:i;function t(o,a,u,f){var s=n._.correctionFactor(o,a),d=o*s*(a*s)/(s*s);return d}return n._.reduce([l,Math.pow(10,i)],t,1)}})}(),function(){n.register("format","ordinal",{regexps:{format:/(o)/},format:function(e,r,l){var i=n.locales[n.options.currentLocale],t,o=n._.includes(r," o")?" ":"";return r=r.replace(/\s?o/,""),o+=i.ordinal(e),t=n._.numberToFormat(e,r,l),t+o}})}(),function(){n.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(e,r,l){var i=n._.includes(r," %")?" ":"",t;return n.options.scalePercentBy100&&(e=e*100),r=r.replace(/\s?\%/,""),t=n._.numberToFormat(e,r,l),n._.includes(t,")")?(t=t.split(""),t.splice(-1,0,i+"%"),t=t.join("")):t=t+i+"%",t},unformat:function(e){var r=n._.stringToNumber(e);return n.options.scalePercentBy100?r*.01:r}})}(),function(){n.register("format","time",{regexps:{format:/(:)/,unformat:/(:)/},format:function(e,r,l){var i=Math.floor(e/60/60),t=Math.floor((e-i*60*60)/60),o=Math.round(e-i*60*60-t*60);return i+":"+(t<10?"0"+t:t)+":"+(o<10?"0"+o:o)},unformat:function(e){var r=e.split(":"),l=0;return r.length===3?(l=l+Number(r[0])*60*60,l=l+Number(r[1])*60,l=l+Number(r[2])):r.length===2&&(l=l+Number(r[0])*60,l=l+Number(r[1])),Number(l)}})}(),n})}(B.__module)),B.__module.exports}exports.__require=L;
@@ -0,0 +1,424 @@
1
+ import { __module as v } from "../../../../../_virtual/numeral2.js";
2
+ /*! @preserve
3
+ * numeral.js
4
+ * version : 2.0.6
5
+ * author : Adam Draper
6
+ * license : MIT
7
+ * http://adamwdraper.github.com/Numeral-js/
8
+ */
9
+ var O = v.exports, E;
10
+ function z() {
11
+ return E ? v.exports : (E = 1, function($) {
12
+ (function(n, m) {
13
+ $.exports ? $.exports = m() : n.numeral = m();
14
+ })(O, function() {
15
+ var n, m, P = "2.0.6", _ = {}, N = {}, y = {
16
+ currentLocale: "en",
17
+ zeroFormat: null,
18
+ nullFormat: null,
19
+ defaultFormat: "0,0",
20
+ scalePercentBy100: !0
21
+ }, c = {
22
+ currentLocale: y.currentLocale,
23
+ zeroFormat: y.zeroFormat,
24
+ nullFormat: y.nullFormat,
25
+ defaultFormat: y.defaultFormat,
26
+ scalePercentBy100: y.scalePercentBy100
27
+ };
28
+ function M(e, r) {
29
+ this._input = e, this._value = r;
30
+ }
31
+ return n = function(e) {
32
+ var r, l, i, t;
33
+ if (n.isNumeral(e))
34
+ r = e.value();
35
+ else if (e === 0 || typeof e > "u")
36
+ r = 0;
37
+ else if (e === null || m.isNaN(e))
38
+ r = null;
39
+ else if (typeof e == "string")
40
+ if (c.zeroFormat && e === c.zeroFormat)
41
+ r = 0;
42
+ else if (c.nullFormat && e === c.nullFormat || !e.replace(/[^0-9]+/g, "").length)
43
+ r = null;
44
+ else {
45
+ for (l in _)
46
+ if (t = typeof _[l].regexps.unformat == "function" ? _[l].regexps.unformat() : _[l].regexps.unformat, t && e.match(t)) {
47
+ i = _[l].unformat;
48
+ break;
49
+ }
50
+ i = i || n._.stringToNumber, r = i(e);
51
+ }
52
+ else
53
+ r = Number(e) || null;
54
+ return new M(e, r);
55
+ }, n.version = P, n.isNumeral = function(e) {
56
+ return e instanceof M;
57
+ }, n._ = m = {
58
+ // formats numbers separators, decimals places, signs, abbreviations
59
+ numberToFormat: function(e, r, l) {
60
+ var i = N[n.options.currentLocale], t = !1, o = !1, a = 0, u = "", f = 1e12, s = 1e9, d = 1e6, w = 1e3, h = "", B = !1, p, F, b, g, T, k, x;
61
+ if (e = e || 0, F = Math.abs(e), n._.includes(r, "(") ? (t = !0, r = r.replace(/[\(|\)]/g, "")) : (n._.includes(r, "+") || n._.includes(r, "-")) && (T = n._.includes(r, "+") ? r.indexOf("+") : e < 0 ? r.indexOf("-") : -1, r = r.replace(/[\+|\-]/g, "")), n._.includes(r, "a") && (p = r.match(/a(k|m|b|t)?/), p = p ? p[1] : !1, n._.includes(r, " a") && (u = " "), r = r.replace(new RegExp(u + "a[kmbt]?"), ""), F >= f && !p || p === "t" ? (u += i.abbreviations.trillion, e = e / f) : F < f && F >= s && !p || p === "b" ? (u += i.abbreviations.billion, e = e / s) : F < s && F >= d && !p || p === "m" ? (u += i.abbreviations.million, e = e / d) : (F < d && F >= w && !p || p === "k") && (u += i.abbreviations.thousand, e = e / w)), n._.includes(r, "[.]") && (o = !0, r = r.replace("[.]", ".")), b = e.toString().split(".")[0], g = r.split(".")[1], k = r.indexOf(","), a = (r.split(".")[0].split(",")[0].match(/0/g) || []).length, g ? (n._.includes(g, "[") ? (g = g.replace("]", ""), g = g.split("["), h = n._.toFixed(e, g[0].length + g[1].length, l, g[1].length)) : h = n._.toFixed(e, g.length, l), b = h.split(".")[0], n._.includes(h, ".") ? h = i.delimiters.decimal + h.split(".")[1] : h = "", o && Number(h.slice(1)) === 0 && (h = "")) : b = n._.toFixed(e, 0, l), u && !p && Number(b) >= 1e3 && u !== i.abbreviations.trillion)
62
+ switch (b = String(Number(b) / 1e3), u) {
63
+ case i.abbreviations.thousand:
64
+ u = i.abbreviations.million;
65
+ break;
66
+ case i.abbreviations.million:
67
+ u = i.abbreviations.billion;
68
+ break;
69
+ case i.abbreviations.billion:
70
+ u = i.abbreviations.trillion;
71
+ break;
72
+ }
73
+ if (n._.includes(b, "-") && (b = b.slice(1), B = !0), b.length < a)
74
+ for (var S = a - b.length; S > 0; S--)
75
+ b = "0" + b;
76
+ return k > -1 && (b = b.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1" + i.delimiters.thousands)), r.indexOf(".") === 0 && (b = ""), x = b + h + (u || ""), t ? x = (t && B ? "(" : "") + x + (t && B ? ")" : "") : T >= 0 ? x = T === 0 ? (B ? "-" : "+") + x : x + (B ? "-" : "+") : B && (x = "-" + x), x;
77
+ },
78
+ // unformats numbers separators, decimals places, signs, abbreviations
79
+ stringToNumber: function(e) {
80
+ var r = N[c.currentLocale], l = e, i = {
81
+ thousand: 3,
82
+ million: 6,
83
+ billion: 9,
84
+ trillion: 12
85
+ }, t, o, a;
86
+ if (c.zeroFormat && e === c.zeroFormat)
87
+ o = 0;
88
+ else if (c.nullFormat && e === c.nullFormat || !e.replace(/[^0-9]+/g, "").length)
89
+ o = null;
90
+ else {
91
+ o = 1, r.delimiters.decimal !== "." && (e = e.replace(/\./g, "").replace(r.delimiters.decimal, "."));
92
+ for (t in i)
93
+ if (a = new RegExp("[^a-zA-Z]" + r.abbreviations[t] + "(?:\\)|(\\" + r.currency.symbol + ")?(?:\\))?)?$"), l.match(a)) {
94
+ o *= Math.pow(10, i[t]);
95
+ break;
96
+ }
97
+ o *= (e.split("-").length + Math.min(e.split("(").length - 1, e.split(")").length - 1)) % 2 ? 1 : -1, e = e.replace(/[^0-9\.]+/g, ""), o *= Number(e);
98
+ }
99
+ return o;
100
+ },
101
+ isNaN: function(e) {
102
+ return typeof e == "number" && isNaN(e);
103
+ },
104
+ includes: function(e, r) {
105
+ return e.indexOf(r) !== -1;
106
+ },
107
+ insert: function(e, r, l) {
108
+ return e.slice(0, l) + r + e.slice(l);
109
+ },
110
+ reduce: function(e, r) {
111
+ if (this === null)
112
+ throw new TypeError("Array.prototype.reduce called on null or undefined");
113
+ if (typeof r != "function")
114
+ throw new TypeError(r + " is not a function");
115
+ var l = Object(e), i = l.length >>> 0, t = 0, o;
116
+ if (arguments.length === 3)
117
+ o = arguments[2];
118
+ else {
119
+ for (; t < i && !(t in l); )
120
+ t++;
121
+ if (t >= i)
122
+ throw new TypeError("Reduce of empty array with no initial value");
123
+ o = l[t++];
124
+ }
125
+ for (; t < i; t++)
126
+ t in l && (o = r(o, l[t], t, l));
127
+ return o;
128
+ },
129
+ /**
130
+ * Computes the multiplier necessary to make x >= 1,
131
+ * effectively eliminating miscalculations caused by
132
+ * finite precision.
133
+ */
134
+ multiplier: function(e) {
135
+ var r = e.toString().split(".");
136
+ return r.length < 2 ? 1 : Math.pow(10, r[1].length);
137
+ },
138
+ /**
139
+ * Given a variable number of arguments, returns the maximum
140
+ * multiplier that must be used to normalize an operation involving
141
+ * all of them.
142
+ */
143
+ correctionFactor: function() {
144
+ var e = Array.prototype.slice.call(arguments);
145
+ return e.reduce(function(r, l) {
146
+ var i = m.multiplier(l);
147
+ return r > i ? r : i;
148
+ }, 1);
149
+ },
150
+ /**
151
+ * Implementation of toFixed() that treats floats more like decimals
152
+ *
153
+ * Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present
154
+ * problems for accounting- and finance-related software.
155
+ */
156
+ toFixed: function(e, r, l, i) {
157
+ var t = e.toString().split("."), o = r - (i || 0), a, u, f, s;
158
+ return t.length === 2 ? a = Math.min(Math.max(t[1].length, o), r) : a = o, f = Math.pow(10, a), s = (l(e + "e+" + a) / f).toFixed(a), i > r - a && (u = new RegExp("\\.?0{1," + (i - (r - a)) + "}$"), s = s.replace(u, "")), s;
159
+ }
160
+ }, n.options = c, n.formats = _, n.locales = N, n.locale = function(e) {
161
+ return e && (c.currentLocale = e.toLowerCase()), c.currentLocale;
162
+ }, n.localeData = function(e) {
163
+ if (!e)
164
+ return N[c.currentLocale];
165
+ if (e = e.toLowerCase(), !N[e])
166
+ throw new Error("Unknown locale : " + e);
167
+ return N[e];
168
+ }, n.reset = function() {
169
+ for (var e in y)
170
+ c[e] = y[e];
171
+ }, n.zeroFormat = function(e) {
172
+ c.zeroFormat = typeof e == "string" ? e : null;
173
+ }, n.nullFormat = function(e) {
174
+ c.nullFormat = typeof e == "string" ? e : null;
175
+ }, n.defaultFormat = function(e) {
176
+ c.defaultFormat = typeof e == "string" ? e : "0.0";
177
+ }, n.register = function(e, r, l) {
178
+ if (r = r.toLowerCase(), this[e + "s"][r])
179
+ throw new TypeError(r + " " + e + " already registered.");
180
+ return this[e + "s"][r] = l, l;
181
+ }, n.validate = function(e, r) {
182
+ var l, i, t, o, a, u, f, s;
183
+ if (typeof e != "string" && (e += ""), e = e.trim(), e.match(/^\d+$/))
184
+ return !0;
185
+ if (e === "")
186
+ return !1;
187
+ try {
188
+ f = n.localeData(r);
189
+ } catch {
190
+ f = n.localeData(n.locale());
191
+ }
192
+ return t = f.currency.symbol, a = f.abbreviations, l = f.delimiters.decimal, f.delimiters.thousands === "." ? i = "\\." : i = f.delimiters.thousands, s = e.match(/^[^\d]+/), s !== null && (e = e.substr(1), s[0] !== t) || (s = e.match(/[^\d]+$/), s !== null && (e = e.slice(0, -1), s[0] !== a.thousand && s[0] !== a.million && s[0] !== a.billion && s[0] !== a.trillion)) ? !1 : (u = new RegExp(i + "{2}"), e.match(/[^\d.,]/g) ? !1 : (o = e.split(l), o.length > 2 ? !1 : o.length < 2 ? !!o[0].match(/^\d+.*\d$/) && !o[0].match(u) : o[0].length === 1 ? !!o[0].match(/^\d+$/) && !o[0].match(u) && !!o[1].match(/^\d+$/) : !!o[0].match(/^\d+.*\d$/) && !o[0].match(u) && !!o[1].match(/^\d+$/)));
193
+ }, n.fn = M.prototype = {
194
+ clone: function() {
195
+ return n(this);
196
+ },
197
+ format: function(e, r) {
198
+ var l = this._value, i = e || c.defaultFormat, t, o, a;
199
+ if (r = r || Math.round, l === 0 && c.zeroFormat !== null)
200
+ o = c.zeroFormat;
201
+ else if (l === null && c.nullFormat !== null)
202
+ o = c.nullFormat;
203
+ else {
204
+ for (t in _)
205
+ if (i.match(_[t].regexps.format)) {
206
+ a = _[t].format;
207
+ break;
208
+ }
209
+ a = a || n._.numberToFormat, o = a(l, i, r);
210
+ }
211
+ return o;
212
+ },
213
+ value: function() {
214
+ return this._value;
215
+ },
216
+ input: function() {
217
+ return this._input;
218
+ },
219
+ set: function(e) {
220
+ return this._value = Number(e), this;
221
+ },
222
+ add: function(e) {
223
+ var r = m.correctionFactor.call(null, this._value, e);
224
+ function l(i, t, o, a) {
225
+ return i + Math.round(r * t);
226
+ }
227
+ return this._value = m.reduce([this._value, e], l, 0) / r, this;
228
+ },
229
+ subtract: function(e) {
230
+ var r = m.correctionFactor.call(null, this._value, e);
231
+ function l(i, t, o, a) {
232
+ return i - Math.round(r * t);
233
+ }
234
+ return this._value = m.reduce([e], l, Math.round(this._value * r)) / r, this;
235
+ },
236
+ multiply: function(e) {
237
+ function r(l, i, t, o) {
238
+ var a = m.correctionFactor(l, i);
239
+ return Math.round(l * a) * Math.round(i * a) / Math.round(a * a);
240
+ }
241
+ return this._value = m.reduce([this._value, e], r, 1), this;
242
+ },
243
+ divide: function(e) {
244
+ function r(l, i, t, o) {
245
+ var a = m.correctionFactor(l, i);
246
+ return Math.round(l * a) / Math.round(i * a);
247
+ }
248
+ return this._value = m.reduce([this._value, e], r), this;
249
+ },
250
+ difference: function(e) {
251
+ return Math.abs(n(this._value).subtract(e).value());
252
+ }
253
+ }, n.register("locale", "en", {
254
+ delimiters: {
255
+ thousands: ",",
256
+ decimal: "."
257
+ },
258
+ abbreviations: {
259
+ thousand: "k",
260
+ million: "m",
261
+ billion: "b",
262
+ trillion: "t"
263
+ },
264
+ ordinal: function(e) {
265
+ var r = e % 10;
266
+ return ~~(e % 100 / 10) === 1 ? "th" : r === 1 ? "st" : r === 2 ? "nd" : r === 3 ? "rd" : "th";
267
+ },
268
+ currency: {
269
+ symbol: "$"
270
+ }
271
+ }), function() {
272
+ n.register("format", "bps", {
273
+ regexps: {
274
+ format: /(BPS)/,
275
+ unformat: /(BPS)/
276
+ },
277
+ format: function(e, r, l) {
278
+ var i = n._.includes(r, " BPS") ? " " : "", t;
279
+ return e = e * 1e4, r = r.replace(/\s?BPS/, ""), t = n._.numberToFormat(e, r, l), n._.includes(t, ")") ? (t = t.split(""), t.splice(-1, 0, i + "BPS"), t = t.join("")) : t = t + i + "BPS", t;
280
+ },
281
+ unformat: function(e) {
282
+ return +(n._.stringToNumber(e) * 1e-4).toFixed(15);
283
+ }
284
+ });
285
+ }(), function() {
286
+ var e = {
287
+ base: 1e3,
288
+ suffixes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
289
+ }, r = {
290
+ base: 1024,
291
+ suffixes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
292
+ }, l = e.suffixes.concat(r.suffixes.filter(function(t) {
293
+ return e.suffixes.indexOf(t) < 0;
294
+ })), i = l.join("|");
295
+ i = "(" + i.replace("B", "B(?!PS)") + ")", n.register("format", "bytes", {
296
+ regexps: {
297
+ format: /([0\s]i?b)/,
298
+ unformat: new RegExp(i)
299
+ },
300
+ format: function(t, o, a) {
301
+ var u, f = n._.includes(o, "ib") ? r : e, s = n._.includes(o, " b") || n._.includes(o, " ib") ? " " : "", d, w, h;
302
+ for (o = o.replace(/\s?i?b/, ""), d = 0; d <= f.suffixes.length; d++)
303
+ if (w = Math.pow(f.base, d), h = Math.pow(f.base, d + 1), t === null || t === 0 || t >= w && t < h) {
304
+ s += f.suffixes[d], w > 0 && (t = t / w);
305
+ break;
306
+ }
307
+ return u = n._.numberToFormat(t, o, a), u + s;
308
+ },
309
+ unformat: function(t) {
310
+ var o = n._.stringToNumber(t), a, u;
311
+ if (o) {
312
+ for (a = e.suffixes.length - 1; a >= 0; a--) {
313
+ if (n._.includes(t, e.suffixes[a])) {
314
+ u = Math.pow(e.base, a);
315
+ break;
316
+ }
317
+ if (n._.includes(t, r.suffixes[a])) {
318
+ u = Math.pow(r.base, a);
319
+ break;
320
+ }
321
+ }
322
+ o *= u || 1;
323
+ }
324
+ return o;
325
+ }
326
+ });
327
+ }(), function() {
328
+ n.register("format", "currency", {
329
+ regexps: {
330
+ format: /(\$)/
331
+ },
332
+ format: function(e, r, l) {
333
+ var i = n.locales[n.options.currentLocale], t = {
334
+ before: r.match(/^([\+|\-|\(|\s|\$]*)/)[0],
335
+ after: r.match(/([\+|\-|\)|\s|\$]*)$/)[0]
336
+ }, o, a, u;
337
+ for (r = r.replace(/\s?\$\s?/, ""), o = n._.numberToFormat(e, r, l), e >= 0 ? (t.before = t.before.replace(/[\-\(]/, ""), t.after = t.after.replace(/[\-\)]/, "")) : e < 0 && !n._.includes(t.before, "-") && !n._.includes(t.before, "(") && (t.before = "-" + t.before), u = 0; u < t.before.length; u++)
338
+ switch (a = t.before[u], a) {
339
+ case "$":
340
+ o = n._.insert(o, i.currency.symbol, u);
341
+ break;
342
+ case " ":
343
+ o = n._.insert(o, " ", u + i.currency.symbol.length - 1);
344
+ break;
345
+ }
346
+ for (u = t.after.length - 1; u >= 0; u--)
347
+ switch (a = t.after[u], a) {
348
+ case "$":
349
+ o = u === t.after.length - 1 ? o + i.currency.symbol : n._.insert(o, i.currency.symbol, -(t.after.length - (1 + u)));
350
+ break;
351
+ case " ":
352
+ o = u === t.after.length - 1 ? o + " " : n._.insert(o, " ", -(t.after.length - (1 + u) + i.currency.symbol.length - 1));
353
+ break;
354
+ }
355
+ return o;
356
+ }
357
+ });
358
+ }(), function() {
359
+ n.register("format", "exponential", {
360
+ regexps: {
361
+ format: /(e\+|e-)/,
362
+ unformat: /(e\+|e-)/
363
+ },
364
+ format: function(e, r, l) {
365
+ var i, t = typeof e == "number" && !n._.isNaN(e) ? e.toExponential() : "0e+0", o = t.split("e");
366
+ return r = r.replace(/e[\+|\-]{1}0/, ""), i = n._.numberToFormat(Number(o[0]), r, l), i + "e" + o[1];
367
+ },
368
+ unformat: function(e) {
369
+ var r = n._.includes(e, "e+") ? e.split("e+") : e.split("e-"), l = Number(r[0]), i = Number(r[1]);
370
+ i = n._.includes(e, "e-") ? i *= -1 : i;
371
+ function t(o, a, u, f) {
372
+ var s = n._.correctionFactor(o, a), d = o * s * (a * s) / (s * s);
373
+ return d;
374
+ }
375
+ return n._.reduce([l, Math.pow(10, i)], t, 1);
376
+ }
377
+ });
378
+ }(), function() {
379
+ n.register("format", "ordinal", {
380
+ regexps: {
381
+ format: /(o)/
382
+ },
383
+ format: function(e, r, l) {
384
+ var i = n.locales[n.options.currentLocale], t, o = n._.includes(r, " o") ? " " : "";
385
+ return r = r.replace(/\s?o/, ""), o += i.ordinal(e), t = n._.numberToFormat(e, r, l), t + o;
386
+ }
387
+ });
388
+ }(), function() {
389
+ n.register("format", "percentage", {
390
+ regexps: {
391
+ format: /(%)/,
392
+ unformat: /(%)/
393
+ },
394
+ format: function(e, r, l) {
395
+ var i = n._.includes(r, " %") ? " " : "", t;
396
+ return n.options.scalePercentBy100 && (e = e * 100), r = r.replace(/\s?\%/, ""), t = n._.numberToFormat(e, r, l), n._.includes(t, ")") ? (t = t.split(""), t.splice(-1, 0, i + "%"), t = t.join("")) : t = t + i + "%", t;
397
+ },
398
+ unformat: function(e) {
399
+ var r = n._.stringToNumber(e);
400
+ return n.options.scalePercentBy100 ? r * 0.01 : r;
401
+ }
402
+ });
403
+ }(), function() {
404
+ n.register("format", "time", {
405
+ regexps: {
406
+ format: /(:)/,
407
+ unformat: /(:)/
408
+ },
409
+ format: function(e, r, l) {
410
+ var i = Math.floor(e / 60 / 60), t = Math.floor((e - i * 60 * 60) / 60), o = Math.round(e - i * 60 * 60 - t * 60);
411
+ return i + ":" + (t < 10 ? "0" + t : t) + ":" + (o < 10 ? "0" + o : o);
412
+ },
413
+ unformat: function(e) {
414
+ var r = e.split(":"), l = 0;
415
+ return r.length === 3 ? (l = l + Number(r[0]) * 60 * 60, l = l + Number(r[1]) * 60, l = l + Number(r[2])) : r.length === 2 && (l = l + Number(r[0]) * 60, l = l + Number(r[1])), Number(l);
416
+ }
417
+ });
418
+ }(), n;
419
+ });
420
+ }(v), v.exports);
421
+ }
422
+ export {
423
+ z as __require
424
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/number/isNumeric.cjs"),o=require("../bigdecimal/utils.cjs"),s=({currencyValue:r,decimals:t,unitCurrencyValue:n})=>{if(!e.isNumeric(r)||!e.isNumeric(t)||!e.isNumeric(n))return;const u=Number(t),i=o.parseCurrency(r.toString()).value,c=o.parseCurrency(n.toString()).value;return i*BigInt(10**u)/c};exports.convertCurrencyValueToTokenAmount=s;
@@ -0,0 +1,14 @@
1
+ import { BigNumberish } from 'starknet';
2
+ export interface IConvertCurrencyValueToTokenAmount {
3
+ /** the currency value to convert */
4
+ currencyValue: number | string;
5
+ /** number of decimals used in token amount */
6
+ decimals: BigNumberish;
7
+ /** the currency value of 1 unit of token */
8
+ unitCurrencyValue: number | string;
9
+ }
10
+ /**
11
+ * Converts a currency value back to token amount using the unit currency value
12
+ * @returns token amount as a BigInt
13
+ */
14
+ export declare const convertCurrencyValueToTokenAmount: ({ currencyValue, decimals, unitCurrencyValue, }: IConvertCurrencyValueToTokenAmount) => bigint | undefined;
@@ -0,0 +1,11 @@
1
+ import { isNumeric as t } from "../utils/number/isNumeric.js";
2
+ import { parseCurrency as e } from "../bigdecimal/utils.js";
3
+ const a = ({ currencyValue: n, decimals: o, unitCurrencyValue: r }) => {
4
+ if (!t(n) || !t(o) || !t(r))
5
+ return;
6
+ const u = Number(o), i = e(n.toString()).value, m = e(r.toString()).value;
7
+ return i * BigInt(10 ** u) / m;
8
+ };
9
+ export {
10
+ a as convertCurrencyValueToTokenAmount
11
+ };
@@ -1,5 +1,6 @@
1
1
  export * from './balances';
2
2
  export * from './constants';
3
+ export * from './convertCurrencyValueToTokenAmount';
3
4
  export * from './convertTokenAmountToCurrencyValue';
4
5
  export * from './convertTokenUnitAmountWithDecimals';
5
6
  export * from './ensureDecimals';