@lightsparkdev/core 1.2.6 → 1.2.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.
- package/CHANGELOG.md +8 -0
- package/dist/{chunk-CKJUUY2Z.js → chunk-NY4EJZNK.js} +121 -35
- package/dist/{index-COxEW2dD.d.cts → index-r0bUxDu_.d.cts} +31 -10
- package/dist/{index-COxEW2dD.d.ts → index-r0bUxDu_.d.ts} +31 -10
- package/dist/index.cjs +123 -35
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/utils/index.cjs +123 -35
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +5 -1
- package/package.json +1 -1
- package/src/utils/currency.ts +195 -42
- package/src/utils/locale.ts +2 -0
- package/src/utils/tests/currency.test.ts +183 -1
package/dist/index.cjs
CHANGED
|
@@ -62,12 +62,14 @@ __export(src_exports, {
|
|
|
62
62
|
ensureArray: () => ensureArray,
|
|
63
63
|
errorToJSON: () => errorToJSON,
|
|
64
64
|
formatCurrencyStr: () => formatCurrencyStr,
|
|
65
|
+
getCurrencyAmount: () => getCurrencyAmount,
|
|
65
66
|
getCurrentLocale: () => getCurrentLocale,
|
|
66
67
|
getErrorMsg: () => getErrorMsg,
|
|
67
68
|
getLocalStorageBoolean: () => getLocalStorageBoolean,
|
|
68
69
|
getLocalStorageConfigItem: () => getLocalStorageConfigItem,
|
|
69
70
|
hexToBytes: () => hexToBytes,
|
|
70
71
|
isBrowser: () => isBrowser,
|
|
72
|
+
isCurrencyAmountInputObj: () => isCurrencyAmountInputObj,
|
|
71
73
|
isCurrencyAmountObj: () => isCurrencyAmountObj,
|
|
72
74
|
isCurrencyAmountPreferenceObj: () => isCurrencyAmountPreferenceObj,
|
|
73
75
|
isCurrencyMap: () => isCurrencyMap,
|
|
@@ -794,6 +796,7 @@ var CurrencyUnit = {
|
|
|
794
796
|
MILLIBITCOIN: "MILLIBITCOIN",
|
|
795
797
|
USD: "USD",
|
|
796
798
|
MXN: "MXN",
|
|
799
|
+
PHP: "PHP",
|
|
797
800
|
Bitcoin: "BITCOIN",
|
|
798
801
|
Microbitcoin: "MICROBITCOIN",
|
|
799
802
|
Millibitcoin: "MILLIBITCOIN",
|
|
@@ -801,7 +804,8 @@ var CurrencyUnit = {
|
|
|
801
804
|
Nanobitcoin: "NANOBITCOIN",
|
|
802
805
|
Satoshi: "SATOSHI",
|
|
803
806
|
Usd: "USD",
|
|
804
|
-
Mxn: "MXN"
|
|
807
|
+
Mxn: "MXN",
|
|
808
|
+
Php: "PHP"
|
|
805
809
|
};
|
|
806
810
|
var standardUnitConversionObj = {
|
|
807
811
|
[CurrencyUnit.BITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc,
|
|
@@ -812,7 +816,8 @@ var standardUnitConversionObj = {
|
|
|
812
816
|
[CurrencyUnit.SATOSHI]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e8,
|
|
813
817
|
/* Converting between two different fiat types is not currently supported */
|
|
814
818
|
[CurrencyUnit.USD]: (v) => v,
|
|
815
|
-
[CurrencyUnit.MXN]: (v) => v
|
|
819
|
+
[CurrencyUnit.MXN]: (v) => v,
|
|
820
|
+
[CurrencyUnit.PHP]: (v) => v
|
|
816
821
|
};
|
|
817
822
|
var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
|
|
818
823
|
var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
|
|
@@ -829,7 +834,8 @@ var CONVERSION_MAP = {
|
|
|
829
834
|
[CurrencyUnit.NANOBITCOIN]: (v) => v * 1e9,
|
|
830
835
|
[CurrencyUnit.SATOSHI]: (v) => v * 1e8,
|
|
831
836
|
[CurrencyUnit.USD]: toBitcoinConversion,
|
|
832
|
-
[CurrencyUnit.MXN]: toBitcoinConversion
|
|
837
|
+
[CurrencyUnit.MXN]: toBitcoinConversion,
|
|
838
|
+
[CurrencyUnit.PHP]: toBitcoinConversion
|
|
833
839
|
},
|
|
834
840
|
[CurrencyUnit.MICROBITCOIN]: {
|
|
835
841
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e6,
|
|
@@ -839,7 +845,8 @@ var CONVERSION_MAP = {
|
|
|
839
845
|
[CurrencyUnit.NANOBITCOIN]: (v) => v * 1e3,
|
|
840
846
|
[CurrencyUnit.SATOSHI]: (v) => v * 100,
|
|
841
847
|
[CurrencyUnit.USD]: toMicrobitcoinConversion,
|
|
842
|
-
[CurrencyUnit.MXN]: toMicrobitcoinConversion
|
|
848
|
+
[CurrencyUnit.MXN]: toMicrobitcoinConversion,
|
|
849
|
+
[CurrencyUnit.PHP]: toMicrobitcoinConversion
|
|
843
850
|
},
|
|
844
851
|
[CurrencyUnit.MILLIBITCOIN]: {
|
|
845
852
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e3,
|
|
@@ -849,7 +856,8 @@ var CONVERSION_MAP = {
|
|
|
849
856
|
[CurrencyUnit.NANOBITCOIN]: (v) => v * 1e6,
|
|
850
857
|
[CurrencyUnit.SATOSHI]: (v) => v * 1e5,
|
|
851
858
|
[CurrencyUnit.USD]: toMillibitcoinConversion,
|
|
852
|
-
[CurrencyUnit.MXN]: toMillibitcoinConversion
|
|
859
|
+
[CurrencyUnit.MXN]: toMillibitcoinConversion,
|
|
860
|
+
[CurrencyUnit.PHP]: toMillibitcoinConversion
|
|
853
861
|
},
|
|
854
862
|
[CurrencyUnit.MILLISATOSHI]: {
|
|
855
863
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e11,
|
|
@@ -859,7 +867,8 @@ var CONVERSION_MAP = {
|
|
|
859
867
|
[CurrencyUnit.NANOBITCOIN]: (v) => v / 100,
|
|
860
868
|
[CurrencyUnit.SATOSHI]: (v) => v / 1e3,
|
|
861
869
|
[CurrencyUnit.USD]: toMillisatoshiConversion,
|
|
862
|
-
[CurrencyUnit.MXN]: toMillisatoshiConversion
|
|
870
|
+
[CurrencyUnit.MXN]: toMillisatoshiConversion,
|
|
871
|
+
[CurrencyUnit.PHP]: toMillisatoshiConversion
|
|
863
872
|
},
|
|
864
873
|
[CurrencyUnit.NANOBITCOIN]: {
|
|
865
874
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e9,
|
|
@@ -869,7 +878,8 @@ var CONVERSION_MAP = {
|
|
|
869
878
|
[CurrencyUnit.NANOBITCOIN]: (v) => v,
|
|
870
879
|
[CurrencyUnit.SATOSHI]: (v) => v / 10,
|
|
871
880
|
[CurrencyUnit.USD]: toNanobitcoinConversion,
|
|
872
|
-
[CurrencyUnit.MXN]: toNanobitcoinConversion
|
|
881
|
+
[CurrencyUnit.MXN]: toNanobitcoinConversion,
|
|
882
|
+
[CurrencyUnit.PHP]: toNanobitcoinConversion
|
|
873
883
|
},
|
|
874
884
|
[CurrencyUnit.SATOSHI]: {
|
|
875
885
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e8,
|
|
@@ -879,10 +889,12 @@ var CONVERSION_MAP = {
|
|
|
879
889
|
[CurrencyUnit.NANOBITCOIN]: (v) => v * 10,
|
|
880
890
|
[CurrencyUnit.SATOSHI]: (v) => v,
|
|
881
891
|
[CurrencyUnit.USD]: toSatoshiConversion,
|
|
882
|
-
[CurrencyUnit.MXN]: toSatoshiConversion
|
|
892
|
+
[CurrencyUnit.MXN]: toSatoshiConversion,
|
|
893
|
+
[CurrencyUnit.PHP]: toSatoshiConversion
|
|
883
894
|
},
|
|
884
895
|
[CurrencyUnit.USD]: standardUnitConversionObj,
|
|
885
|
-
[CurrencyUnit.MXN]: standardUnitConversionObj
|
|
896
|
+
[CurrencyUnit.MXN]: standardUnitConversionObj,
|
|
897
|
+
[CurrencyUnit.PHP]: standardUnitConversionObj
|
|
886
898
|
};
|
|
887
899
|
function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
|
|
888
900
|
if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
|
|
@@ -913,6 +925,9 @@ var convertCurrencyAmount = (from, toUnit) => {
|
|
|
913
925
|
preferredCurrencyValueRounded: value
|
|
914
926
|
};
|
|
915
927
|
};
|
|
928
|
+
function isCurrencyAmountInputObj(arg) {
|
|
929
|
+
return typeof arg === "object" && arg !== null && "value" in arg && (typeof arg.value === "number" || typeof arg.value === "string" || arg.value === null) && "unit" in arg && typeof arg.unit === "string";
|
|
930
|
+
}
|
|
916
931
|
function isDeprecatedCurrencyAmountObj(arg) {
|
|
917
932
|
return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
|
|
918
933
|
}
|
|
@@ -920,7 +935,7 @@ function isCurrencyAmountObj(arg) {
|
|
|
920
935
|
return typeof arg === "object" && arg !== null && "original_value" in arg && "original_unit" in arg;
|
|
921
936
|
}
|
|
922
937
|
function isCurrencyAmountPreferenceObj(arg) {
|
|
923
|
-
return typeof arg === "object" && arg !== null && "preferred_currency_unit" in arg && "
|
|
938
|
+
return typeof arg === "object" && arg !== null && "original_unit" in arg && typeof arg.original_unit === "string" && "original_value" in arg && typeof arg.original_value === "number" && "preferred_currency_unit" in arg && typeof arg.preferred_currency_unit === "string" && "preferred_currency_value_approx" in arg && typeof arg.preferred_currency_value_approx === "number";
|
|
924
939
|
}
|
|
925
940
|
function isSDKCurrencyAmount(arg) {
|
|
926
941
|
return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
|
|
@@ -938,13 +953,10 @@ function getCurrencyAmount(currencyAmountArg) {
|
|
|
938
953
|
if (isSDKCurrencyAmount(currencyAmountArg)) {
|
|
939
954
|
value = currencyAmountArg.originalValue;
|
|
940
955
|
unit = currencyAmountArg.originalUnit;
|
|
941
|
-
} else if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
|
|
942
|
-
value = asNumber(currencyAmountArg.preferred_currency_value_rounded);
|
|
943
|
-
unit = currencyAmountArg.preferred_currency_unit;
|
|
944
956
|
} else if (isCurrencyAmountObj(currencyAmountArg)) {
|
|
945
957
|
value = asNumber(currencyAmountArg.original_value);
|
|
946
958
|
unit = currencyAmountArg.original_unit;
|
|
947
|
-
} else if (isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
|
|
959
|
+
} else if (isCurrencyAmountInputObj(currencyAmountArg) || isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
|
|
948
960
|
value = asNumber(currencyAmountArg.value);
|
|
949
961
|
unit = currencyAmountArg.unit;
|
|
950
962
|
}
|
|
@@ -953,23 +965,61 @@ function getCurrencyAmount(currencyAmountArg) {
|
|
|
953
965
|
unit: unit || CurrencyUnit.SATOSHI
|
|
954
966
|
};
|
|
955
967
|
}
|
|
968
|
+
function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversionOverride) {
|
|
969
|
+
const convert = convertCurrencyAmountValue;
|
|
970
|
+
const namesToUnits = {
|
|
971
|
+
sats: CurrencyUnit.SATOSHI,
|
|
972
|
+
btc: CurrencyUnit.BITCOIN,
|
|
973
|
+
msats: CurrencyUnit.MILLISATOSHI,
|
|
974
|
+
usd: CurrencyUnit.USD,
|
|
975
|
+
mxn: CurrencyUnit.MXN,
|
|
976
|
+
php: CurrencyUnit.PHP,
|
|
977
|
+
mibtc: CurrencyUnit.MICROBITCOIN,
|
|
978
|
+
mlbtc: CurrencyUnit.MILLIBITCOIN,
|
|
979
|
+
nbtc: CurrencyUnit.NANOBITCOIN
|
|
980
|
+
};
|
|
981
|
+
return Object.entries(namesToUnits).reduce(
|
|
982
|
+
(acc, [name, unit]) => {
|
|
983
|
+
if (conversionOverride && unit === conversionOverride.unit) {
|
|
984
|
+
acc[name] = conversionOverride.convertedValue;
|
|
985
|
+
} else {
|
|
986
|
+
acc[name] = convert(
|
|
987
|
+
fromUnit,
|
|
988
|
+
unit,
|
|
989
|
+
amount,
|
|
990
|
+
unitsPerBtc
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
return acc;
|
|
994
|
+
},
|
|
995
|
+
{}
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
function getPreferredConversionOverride(currencyAmountArg) {
|
|
999
|
+
if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
|
|
1000
|
+
return {
|
|
1001
|
+
unit: currencyAmountArg.preferred_currency_unit,
|
|
1002
|
+
convertedValue: currencyAmountArg.preferred_currency_value_approx
|
|
1003
|
+
};
|
|
1004
|
+
} else if (isSDKCurrencyAmount(currencyAmountArg)) {
|
|
1005
|
+
return {
|
|
1006
|
+
unit: currencyAmountArg.preferredCurrencyUnit,
|
|
1007
|
+
convertedValue: currencyAmountArg.preferredCurrencyValueApprox
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
return void 0;
|
|
1011
|
+
}
|
|
956
1012
|
function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
957
1013
|
const { value, unit } = getCurrencyAmount(currencyAmountArg);
|
|
958
|
-
const
|
|
959
|
-
const sats =
|
|
960
|
-
const btc = convert(unit, CurrencyUnit.BITCOIN, value, unitsPerBtc);
|
|
961
|
-
const msats = convert(unit, CurrencyUnit.MILLISATOSHI, value, unitsPerBtc);
|
|
962
|
-
const usd = convert(unit, CurrencyUnit.USD, value, unitsPerBtc);
|
|
963
|
-
const mxn = convert(unit, CurrencyUnit.MXN, value, unitsPerBtc);
|
|
964
|
-
const mibtc = convert(unit, CurrencyUnit.MICROBITCOIN, value, unitsPerBtc);
|
|
965
|
-
const mlbtc = convert(unit, CurrencyUnit.MILLIBITCOIN, value, unitsPerBtc);
|
|
966
|
-
const nbtc = convert(unit, CurrencyUnit.NANOBITCOIN, value, unitsPerBtc);
|
|
1014
|
+
const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
|
|
1015
|
+
const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
|
|
967
1016
|
const mapWithCurrencyUnits = {
|
|
968
1017
|
[CurrencyUnit.BITCOIN]: btc,
|
|
969
1018
|
[CurrencyUnit.SATOSHI]: sats,
|
|
970
1019
|
[CurrencyUnit.MILLISATOSHI]: msats,
|
|
971
1020
|
[CurrencyUnit.USD]: usd,
|
|
972
1021
|
[CurrencyUnit.MXN]: mxn,
|
|
1022
|
+
[CurrencyUnit.PHP]: php,
|
|
973
1023
|
[CurrencyUnit.MICROBITCOIN]: mibtc,
|
|
974
1024
|
[CurrencyUnit.MILLIBITCOIN]: mlbtc,
|
|
975
1025
|
[CurrencyUnit.NANOBITCOIN]: nbtc,
|
|
@@ -1007,6 +1057,10 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
|
1007
1057
|
value: mxn,
|
|
1008
1058
|
unit: CurrencyUnit.MXN
|
|
1009
1059
|
}),
|
|
1060
|
+
[CurrencyUnit.PHP]: formatCurrencyStr({
|
|
1061
|
+
value: php,
|
|
1062
|
+
unit: CurrencyUnit.PHP
|
|
1063
|
+
}),
|
|
1010
1064
|
[CurrencyUnit.FUTURE_VALUE]: "-"
|
|
1011
1065
|
}
|
|
1012
1066
|
};
|
|
@@ -1061,8 +1115,16 @@ var abbrCurrencyUnit = (unit) => {
|
|
|
1061
1115
|
return "SAT";
|
|
1062
1116
|
case CurrencyUnit.MILLISATOSHI:
|
|
1063
1117
|
return "MSAT";
|
|
1118
|
+
case CurrencyUnit.MILLIBITCOIN:
|
|
1119
|
+
return "mBTC";
|
|
1120
|
+
case CurrencyUnit.MICROBITCOIN:
|
|
1121
|
+
return "\u03BCBTC";
|
|
1064
1122
|
case CurrencyUnit.USD:
|
|
1065
1123
|
return "USD";
|
|
1124
|
+
case CurrencyUnit.MXN:
|
|
1125
|
+
return "MXN";
|
|
1126
|
+
case CurrencyUnit.PHP:
|
|
1127
|
+
return "PHP";
|
|
1066
1128
|
}
|
|
1067
1129
|
return "Unsupported CurrencyUnit";
|
|
1068
1130
|
};
|
|
@@ -1070,7 +1132,8 @@ var defaultOptions = {
|
|
|
1070
1132
|
/* undefined indicates to use default precision for unit defined below */
|
|
1071
1133
|
precision: void 0,
|
|
1072
1134
|
compact: false,
|
|
1073
|
-
showBtcSymbol: false
|
|
1135
|
+
showBtcSymbol: false,
|
|
1136
|
+
append: void 0
|
|
1074
1137
|
};
|
|
1075
1138
|
function formatCurrencyStr(amount, options) {
|
|
1076
1139
|
const { precision, compact, showBtcSymbol } = {
|
|
@@ -1080,7 +1143,12 @@ function formatCurrencyStr(amount, options) {
|
|
|
1080
1143
|
const currencyAmount = getCurrencyAmount(amount);
|
|
1081
1144
|
let { value: num } = currencyAmount;
|
|
1082
1145
|
const { unit } = currencyAmount;
|
|
1083
|
-
|
|
1146
|
+
const centCurrencies = [
|
|
1147
|
+
CurrencyUnit.USD,
|
|
1148
|
+
CurrencyUnit.MXN,
|
|
1149
|
+
CurrencyUnit.PHP
|
|
1150
|
+
];
|
|
1151
|
+
if (centCurrencies.includes(unit)) {
|
|
1084
1152
|
num = num / 100;
|
|
1085
1153
|
}
|
|
1086
1154
|
function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
|
|
@@ -1096,34 +1164,52 @@ function formatCurrencyStr(amount, options) {
|
|
|
1096
1164
|
}
|
|
1097
1165
|
const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
|
|
1098
1166
|
const currentLocale = getCurrentLocale();
|
|
1167
|
+
let formattedStr = "";
|
|
1099
1168
|
switch (unit) {
|
|
1169
|
+
case CurrencyUnit.MXN:
|
|
1170
|
+
case CurrencyUnit.USD:
|
|
1171
|
+
case CurrencyUnit.PHP:
|
|
1172
|
+
formattedStr = num.toLocaleString(currentLocale, {
|
|
1173
|
+
style: "currency",
|
|
1174
|
+
currency: unit,
|
|
1175
|
+
currencyDisplay: "narrowSymbol",
|
|
1176
|
+
notation: compact ? "compact" : void 0,
|
|
1177
|
+
maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
|
|
1178
|
+
});
|
|
1179
|
+
break;
|
|
1100
1180
|
case CurrencyUnit.BITCOIN:
|
|
1101
|
-
|
|
1181
|
+
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
1102
1182
|
notation: compact ? "compact" : void 0,
|
|
1103
1183
|
maximumFractionDigits: getDefaultMaxFractionDigits(4, 8)
|
|
1104
1184
|
})}`;
|
|
1185
|
+
break;
|
|
1105
1186
|
case CurrencyUnit.SATOSHI:
|
|
1106
|
-
|
|
1187
|
+
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
1107
1188
|
notation: compact ? "compact" : void 0,
|
|
1108
1189
|
maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
|
|
1109
1190
|
})}`;
|
|
1191
|
+
break;
|
|
1110
1192
|
case CurrencyUnit.MILLISATOSHI:
|
|
1111
1193
|
case CurrencyUnit.MICROBITCOIN:
|
|
1112
1194
|
case CurrencyUnit.MILLIBITCOIN:
|
|
1113
1195
|
case CurrencyUnit.NANOBITCOIN:
|
|
1114
1196
|
default:
|
|
1115
|
-
|
|
1197
|
+
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
1116
1198
|
notation: compact ? "compact" : void 0,
|
|
1117
1199
|
maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
|
|
1118
1200
|
})}`;
|
|
1119
|
-
case CurrencyUnit.USD:
|
|
1120
|
-
return num.toLocaleString(currentLocale, {
|
|
1121
|
-
style: "currency",
|
|
1122
|
-
currency: defaultCurrencyCode,
|
|
1123
|
-
notation: compact ? "compact" : void 0,
|
|
1124
|
-
maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
|
|
1125
|
-
});
|
|
1126
1201
|
}
|
|
1202
|
+
if (options?.appendUnits) {
|
|
1203
|
+
const localeCurrencyCode = localeToCurrencyCode(currentLocale);
|
|
1204
|
+
if (unit === localeCurrencyCode && !options.appendUnits.showForCurrentLocaleUnit) {
|
|
1205
|
+
return formattedStr;
|
|
1206
|
+
}
|
|
1207
|
+
const unitStr = abbrCurrencyUnit(unit);
|
|
1208
|
+
const unitSuffix = options.appendUnits.plural && num > 1 ? "s" : "";
|
|
1209
|
+
const unitStrWithSuffix = `${unitStr}${unitSuffix}`;
|
|
1210
|
+
formattedStr += ` ${options.appendUnits.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
|
|
1211
|
+
}
|
|
1212
|
+
return formattedStr;
|
|
1127
1213
|
}
|
|
1128
1214
|
function separateCurrencyStrParts(currencyStr) {
|
|
1129
1215
|
const symbol = currencyStr.replace(/[0-9\s\u00a0.,]/g, "");
|
|
@@ -1753,12 +1839,14 @@ var ServerEnvironment_default = ServerEnvironment;
|
|
|
1753
1839
|
ensureArray,
|
|
1754
1840
|
errorToJSON,
|
|
1755
1841
|
formatCurrencyStr,
|
|
1842
|
+
getCurrencyAmount,
|
|
1756
1843
|
getCurrentLocale,
|
|
1757
1844
|
getErrorMsg,
|
|
1758
1845
|
getLocalStorageBoolean,
|
|
1759
1846
|
getLocalStorageConfigItem,
|
|
1760
1847
|
hexToBytes,
|
|
1761
1848
|
isBrowser,
|
|
1849
|
+
isCurrencyAmountInputObj,
|
|
1762
1850
|
isCurrencyAmountObj,
|
|
1763
1851
|
isCurrencyAmountPreferenceObj,
|
|
1764
1852
|
isCurrencyMap,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { A as AppendUnitsOptions, a7 as ById, ah as Complete, C as ConfigKeys, n as CurrencyAmountArg, k as CurrencyAmountInputObj, l as CurrencyAmountObj, m as CurrencyAmountPreferenceObj, R as CurrencyCodes, Q as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, aa as DeepPartial, D as DeprecatedCurrencyAmountObj, a6 as ExpandRecursively, ab as JSONLiteral, ad as JSONObject, ac as JSONType, a5 as Maybe, ae as NN, a8 as OmitTypename, ag as PartialBy, ai as RequiredKeys, S as SDKCurrencyAmountType, x as abbrCurrencyUnit, b as b64decode, a as b64encode, M as bytesToHex, Y as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, P as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, X as deleteLocalStorageItem, e as ensureArray, L as errorToJSON, y as formatCurrencyStr, t as getCurrencyAmount, O as getCurrentLocale, J as getErrorMsg, V as getLocalStorageBoolean, U as getLocalStorageConfigItem, N as hexToBytes, E as isBrowser, o as isCurrencyAmountInputObj, q as isCurrencyAmountObj, r as isCurrencyAmountPreferenceObj, w as isCurrencyMap, p as isDeprecatedCurrencyAmountObj, H as isError, K as isErrorMsg, I as isErrorWithMessage, F as isNode, $ as isNumber, a4 as isObject, s as isSDKCurrencyAmount, G as isTest, a9 as isType, a3 as isUint8Array, Z as linearInterpolate, T as localeToCurrencyCode, B as localeToCurrencySymbol, a2 as lsidToUUID, v as mapCurrencyAmount, af as notNullUndefined, a0 as pollUntil, _ as round, z as separateCurrencyStrParts, W as setLocalStorageBoolean, a1 as sleep, u as urlsafe_b64decode } from './index-r0bUxDu_.cjs';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
4
|
type Headers = Record<string, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { A as AppendUnitsOptions, a7 as ById, ah as Complete, C as ConfigKeys, n as CurrencyAmountArg, k as CurrencyAmountInputObj, l as CurrencyAmountObj, m as CurrencyAmountPreferenceObj, R as CurrencyCodes, Q as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, aa as DeepPartial, D as DeprecatedCurrencyAmountObj, a6 as ExpandRecursively, ab as JSONLiteral, ad as JSONObject, ac as JSONType, a5 as Maybe, ae as NN, a8 as OmitTypename, ag as PartialBy, ai as RequiredKeys, S as SDKCurrencyAmountType, x as abbrCurrencyUnit, b as b64decode, a as b64encode, M as bytesToHex, Y as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, P as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, X as deleteLocalStorageItem, e as ensureArray, L as errorToJSON, y as formatCurrencyStr, t as getCurrencyAmount, O as getCurrentLocale, J as getErrorMsg, V as getLocalStorageBoolean, U as getLocalStorageConfigItem, N as hexToBytes, E as isBrowser, o as isCurrencyAmountInputObj, q as isCurrencyAmountObj, r as isCurrencyAmountPreferenceObj, w as isCurrencyMap, p as isDeprecatedCurrencyAmountObj, H as isError, K as isErrorMsg, I as isErrorWithMessage, F as isNode, $ as isNumber, a4 as isObject, s as isSDKCurrencyAmount, G as isTest, a9 as isType, a3 as isUint8Array, Z as linearInterpolate, T as localeToCurrencyCode, B as localeToCurrencySymbol, a2 as lsidToUUID, v as mapCurrencyAmount, af as notNullUndefined, a0 as pollUntil, _ as round, z as separateCurrencyStrParts, W as setLocalStorageBoolean, a1 as sleep, u as urlsafe_b64decode } from './index-r0bUxDu_.js';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
4
|
type Headers = Record<string, string>;
|
package/dist/index.js
CHANGED
|
@@ -15,12 +15,14 @@ import {
|
|
|
15
15
|
ensureArray,
|
|
16
16
|
errorToJSON,
|
|
17
17
|
formatCurrencyStr,
|
|
18
|
+
getCurrencyAmount,
|
|
18
19
|
getCurrentLocale,
|
|
19
20
|
getErrorMsg,
|
|
20
21
|
getLocalStorageBoolean,
|
|
21
22
|
getLocalStorageConfigItem,
|
|
22
23
|
hexToBytes,
|
|
23
24
|
isBrowser,
|
|
25
|
+
isCurrencyAmountInputObj,
|
|
24
26
|
isCurrencyAmountObj,
|
|
25
27
|
isCurrencyAmountPreferenceObj,
|
|
26
28
|
isCurrencyMap,
|
|
@@ -47,7 +49,7 @@ import {
|
|
|
47
49
|
setLocalStorageBoolean,
|
|
48
50
|
sleep,
|
|
49
51
|
urlsafe_b64decode
|
|
50
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-NY4EJZNK.js";
|
|
51
53
|
|
|
52
54
|
// src/auth/LightsparkAuthException.ts
|
|
53
55
|
var LightsparkAuthException = class extends LightsparkException_default {
|
|
@@ -739,12 +741,14 @@ export {
|
|
|
739
741
|
ensureArray,
|
|
740
742
|
errorToJSON,
|
|
741
743
|
formatCurrencyStr,
|
|
744
|
+
getCurrencyAmount,
|
|
742
745
|
getCurrentLocale,
|
|
743
746
|
getErrorMsg,
|
|
744
747
|
getLocalStorageBoolean,
|
|
745
748
|
getLocalStorageConfigItem,
|
|
746
749
|
hexToBytes,
|
|
747
750
|
isBrowser,
|
|
751
|
+
isCurrencyAmountInputObj,
|
|
748
752
|
isCurrencyAmountObj,
|
|
749
753
|
isCurrencyAmountPreferenceObj,
|
|
750
754
|
isCurrencyMap,
|