@w3ux/utils 1.0.0-alpha.2 → 1.0.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.
- package/base.cjs +6 -22
- package/base.d.cts +23 -10
- package/base.d.ts +23 -10
- package/base.js +4 -21
- package/index.cjs +2 -46
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +2 -44
- package/package.json +1 -1
- package/unit.cjs +0 -28
- package/unit.d.cts +1 -34
- package/unit.d.ts +1 -34
- package/unit.js +0 -25
package/base.cjs
CHANGED
|
@@ -25,8 +25,9 @@ __export(base_exports, {
|
|
|
25
25
|
ellipsisFn: () => ellipsisFn,
|
|
26
26
|
eqSet: () => eqSet,
|
|
27
27
|
formatAccountSs58: () => formatAccountSs58,
|
|
28
|
-
formatNumber: () => formatNumber,
|
|
29
28
|
isSuperset: () => isSuperset,
|
|
29
|
+
maxBigInt: () => maxBigInt,
|
|
30
|
+
minBigInt: () => minBigInt,
|
|
30
31
|
minDecimalPlaces: () => minDecimalPlaces,
|
|
31
32
|
pageFromUri: () => pageFromUri,
|
|
32
33
|
removeHexPrefix: () => removeHexPrefix,
|
|
@@ -49,26 +50,6 @@ var minDecimalPlaces = (val, minDecimals) => {
|
|
|
49
50
|
return "0";
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
|
-
var formatNumber = (val, decimals, commas = "auto") => {
|
|
53
|
-
if (val === "") {
|
|
54
|
-
val = "0";
|
|
55
|
-
}
|
|
56
|
-
let strVal = typeof val === "string" ? val : val.toString();
|
|
57
|
-
const originalHasCommas = typeof val === "string" && /,/.test(val);
|
|
58
|
-
strVal = strVal.replace(/,/g, "");
|
|
59
|
-
const [integerPart, fractionalPart = ""] = strVal.split(".");
|
|
60
|
-
let formattedFractional = fractionalPart;
|
|
61
|
-
if (decimals !== "auto") {
|
|
62
|
-
formattedFractional = fractionalPart.padEnd(decimals, "0").slice(0, decimals);
|
|
63
|
-
}
|
|
64
|
-
const formattedNumber = formattedFractional ? `${integerPart}.${formattedFractional}` : integerPart;
|
|
65
|
-
const shouldAddCommas = commas === "auto" ? originalHasCommas : commas;
|
|
66
|
-
if (shouldAddCommas) {
|
|
67
|
-
const formattedIntegerWithCommas = BigInt(integerPart).toLocaleString("en-US");
|
|
68
|
-
return formattedFractional ? `${formattedIntegerWithCommas}.${formattedFractional}` : formattedIntegerWithCommas;
|
|
69
|
-
}
|
|
70
|
-
return formattedNumber;
|
|
71
|
-
};
|
|
72
53
|
var camelize = (str) => {
|
|
73
54
|
const convertToString = (string) => {
|
|
74
55
|
if (string) {
|
|
@@ -173,6 +154,8 @@ var isSuperset = (set, subset) => {
|
|
|
173
154
|
}
|
|
174
155
|
return true;
|
|
175
156
|
};
|
|
157
|
+
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
158
|
+
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
176
159
|
// Annotate the CommonJS export names for ESM import in node:
|
|
177
160
|
0 && (module.exports = {
|
|
178
161
|
appendOr,
|
|
@@ -181,8 +164,9 @@ var isSuperset = (set, subset) => {
|
|
|
181
164
|
ellipsisFn,
|
|
182
165
|
eqSet,
|
|
183
166
|
formatAccountSs58,
|
|
184
|
-
formatNumber,
|
|
185
167
|
isSuperset,
|
|
168
|
+
maxBigInt,
|
|
169
|
+
minBigInt,
|
|
186
170
|
minDecimalPlaces,
|
|
187
171
|
pageFromUri,
|
|
188
172
|
removeHexPrefix,
|
package/base.d.cts
CHANGED
|
@@ -19,15 +19,6 @@ import { AnyFunction } from '@w3ux/types';
|
|
|
19
19
|
* minDecimalPlaces(BigInt(1234), 2); // returns "1234.00"
|
|
20
20
|
*/
|
|
21
21
|
declare const minDecimalPlaces: (val: string | number | bigint, minDecimals: number) => string;
|
|
22
|
-
/**
|
|
23
|
-
* Formats a number with a specified number of decimal places and optional comma inclusion.
|
|
24
|
-
*
|
|
25
|
-
* @param {string | number | BigInt} val - The input value to format. Can be a string with or without commas, a number, or a BigInt.
|
|
26
|
-
* @param {number | "auto"} decimals - The number of decimal places to include. If "auto", adheres to the original decimal count in `val`.
|
|
27
|
-
* @param {boolean | "auto"} [commas="auto"] - Whether to include commas. If "auto", includes commas only if `val` has them originally.
|
|
28
|
-
* @returns {string} The formatted number as a string.
|
|
29
|
-
*/
|
|
30
|
-
declare const formatNumber: (val: string | number | bigint, decimals: number | "auto", commas?: boolean | "auto") => string;
|
|
31
22
|
/**
|
|
32
23
|
* @name camelize
|
|
33
24
|
* @summary Converts a string of text to camelCase.
|
|
@@ -87,5 +78,27 @@ declare const formatAccountSs58: (address: string, ss58Prefix: number) => string
|
|
|
87
78
|
declare const removeHexPrefix: (str: string) => string;
|
|
88
79
|
declare const eqSet: (xs: Set<any>, ys: Set<any>) => boolean;
|
|
89
80
|
declare const isSuperset: (set: Set<any>, subset: Set<any>) => boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Finds the maximum value among a list of BigInt values.
|
|
83
|
+
*
|
|
84
|
+
* @function maxBigInt
|
|
85
|
+
* @param {...bigint} values - A list of BigInt values to compare.
|
|
86
|
+
* @returns {bigint} The largest BigInt value in the provided list.
|
|
87
|
+
* @example
|
|
88
|
+
* // Returns the maximum BigInt value
|
|
89
|
+
* maxBigInt(10n, 50n, 30n, 100n, 20n); // 100n
|
|
90
|
+
*/
|
|
91
|
+
declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
92
|
+
/**
|
|
93
|
+
* Finds the minimum value among a list of BigInt values.
|
|
94
|
+
*
|
|
95
|
+
* @function minBigInt
|
|
96
|
+
* @param {...bigint} values - A list of BigInt values to compare.
|
|
97
|
+
* @returns {bigint} The smallest BigInt value in the provided list.
|
|
98
|
+
* @example
|
|
99
|
+
* // Returns the minimum BigInt value
|
|
100
|
+
* minBigInt(10n, 50n, 30n, 100n, 20n); // 10n
|
|
101
|
+
*/
|
|
102
|
+
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
90
103
|
|
|
91
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58,
|
|
104
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
|
package/base.d.ts
CHANGED
|
@@ -19,15 +19,6 @@ import { AnyFunction } from '@w3ux/types';
|
|
|
19
19
|
* minDecimalPlaces(BigInt(1234), 2); // returns "1234.00"
|
|
20
20
|
*/
|
|
21
21
|
declare const minDecimalPlaces: (val: string | number | bigint, minDecimals: number) => string;
|
|
22
|
-
/**
|
|
23
|
-
* Formats a number with a specified number of decimal places and optional comma inclusion.
|
|
24
|
-
*
|
|
25
|
-
* @param {string | number | BigInt} val - The input value to format. Can be a string with or without commas, a number, or a BigInt.
|
|
26
|
-
* @param {number | "auto"} decimals - The number of decimal places to include. If "auto", adheres to the original decimal count in `val`.
|
|
27
|
-
* @param {boolean | "auto"} [commas="auto"] - Whether to include commas. If "auto", includes commas only if `val` has them originally.
|
|
28
|
-
* @returns {string} The formatted number as a string.
|
|
29
|
-
*/
|
|
30
|
-
declare const formatNumber: (val: string | number | bigint, decimals: number | "auto", commas?: boolean | "auto") => string;
|
|
31
22
|
/**
|
|
32
23
|
* @name camelize
|
|
33
24
|
* @summary Converts a string of text to camelCase.
|
|
@@ -87,5 +78,27 @@ declare const formatAccountSs58: (address: string, ss58Prefix: number) => string
|
|
|
87
78
|
declare const removeHexPrefix: (str: string) => string;
|
|
88
79
|
declare const eqSet: (xs: Set<any>, ys: Set<any>) => boolean;
|
|
89
80
|
declare const isSuperset: (set: Set<any>, subset: Set<any>) => boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Finds the maximum value among a list of BigInt values.
|
|
83
|
+
*
|
|
84
|
+
* @function maxBigInt
|
|
85
|
+
* @param {...bigint} values - A list of BigInt values to compare.
|
|
86
|
+
* @returns {bigint} The largest BigInt value in the provided list.
|
|
87
|
+
* @example
|
|
88
|
+
* // Returns the maximum BigInt value
|
|
89
|
+
* maxBigInt(10n, 50n, 30n, 100n, 20n); // 100n
|
|
90
|
+
*/
|
|
91
|
+
declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
92
|
+
/**
|
|
93
|
+
* Finds the minimum value among a list of BigInt values.
|
|
94
|
+
*
|
|
95
|
+
* @function minBigInt
|
|
96
|
+
* @param {...bigint} values - A list of BigInt values to compare.
|
|
97
|
+
* @returns {bigint} The smallest BigInt value in the provided list.
|
|
98
|
+
* @example
|
|
99
|
+
* // Returns the minimum BigInt value
|
|
100
|
+
* minBigInt(10n, 50n, 30n, 100n, 20n); // 10n
|
|
101
|
+
*/
|
|
102
|
+
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
90
103
|
|
|
91
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58,
|
|
104
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
|
package/base.js
CHANGED
|
@@ -13,26 +13,6 @@ var minDecimalPlaces = (val, minDecimals) => {
|
|
|
13
13
|
return "0";
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
var formatNumber = (val, decimals, commas = "auto") => {
|
|
17
|
-
if (val === "") {
|
|
18
|
-
val = "0";
|
|
19
|
-
}
|
|
20
|
-
let strVal = typeof val === "string" ? val : val.toString();
|
|
21
|
-
const originalHasCommas = typeof val === "string" && /,/.test(val);
|
|
22
|
-
strVal = strVal.replace(/,/g, "");
|
|
23
|
-
const [integerPart, fractionalPart = ""] = strVal.split(".");
|
|
24
|
-
let formattedFractional = fractionalPart;
|
|
25
|
-
if (decimals !== "auto") {
|
|
26
|
-
formattedFractional = fractionalPart.padEnd(decimals, "0").slice(0, decimals);
|
|
27
|
-
}
|
|
28
|
-
const formattedNumber = formattedFractional ? `${integerPart}.${formattedFractional}` : integerPart;
|
|
29
|
-
const shouldAddCommas = commas === "auto" ? originalHasCommas : commas;
|
|
30
|
-
if (shouldAddCommas) {
|
|
31
|
-
const formattedIntegerWithCommas = BigInt(integerPart).toLocaleString("en-US");
|
|
32
|
-
return formattedFractional ? `${formattedIntegerWithCommas}.${formattedFractional}` : formattedIntegerWithCommas;
|
|
33
|
-
}
|
|
34
|
-
return formattedNumber;
|
|
35
|
-
};
|
|
36
16
|
var camelize = (str) => {
|
|
37
17
|
const convertToString = (string) => {
|
|
38
18
|
if (string) {
|
|
@@ -137,6 +117,8 @@ var isSuperset = (set, subset) => {
|
|
|
137
117
|
}
|
|
138
118
|
return true;
|
|
139
119
|
};
|
|
120
|
+
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
121
|
+
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
140
122
|
export {
|
|
141
123
|
appendOr,
|
|
142
124
|
appendOrEmpty,
|
|
@@ -144,8 +126,9 @@ export {
|
|
|
144
126
|
ellipsisFn,
|
|
145
127
|
eqSet,
|
|
146
128
|
formatAccountSs58,
|
|
147
|
-
formatNumber,
|
|
148
129
|
isSuperset,
|
|
130
|
+
maxBigInt,
|
|
131
|
+
minBigInt,
|
|
149
132
|
minDecimalPlaces,
|
|
150
133
|
pageFromUri,
|
|
151
134
|
removeHexPrefix,
|
package/index.cjs
CHANGED
|
@@ -40,7 +40,6 @@ __export(src_exports, {
|
|
|
40
40
|
eqSet: () => eqSet,
|
|
41
41
|
extractUrlValue: () => extractUrlValue,
|
|
42
42
|
formatAccountSs58: () => formatAccountSs58,
|
|
43
|
-
formatNumber: () => formatNumber,
|
|
44
43
|
inChrome: () => inChrome,
|
|
45
44
|
isSuperset: () => isSuperset,
|
|
46
45
|
isValidAddress: () => isValidAddress,
|
|
@@ -63,7 +62,6 @@ __export(src_exports, {
|
|
|
63
62
|
shuffle: () => shuffle,
|
|
64
63
|
snakeToCamel: () => snakeToCamel,
|
|
65
64
|
sortWithNull: () => sortWithNull,
|
|
66
|
-
transformToBaseUnit: () => transformToBaseUnit,
|
|
67
65
|
unescape: () => unescape,
|
|
68
66
|
unimplemented: () => unimplemented,
|
|
69
67
|
unitToPlanck: () => unitToPlanck,
|
|
@@ -87,26 +85,6 @@ var minDecimalPlaces = (val, minDecimals) => {
|
|
|
87
85
|
return "0";
|
|
88
86
|
}
|
|
89
87
|
};
|
|
90
|
-
var formatNumber = (val, decimals, commas = "auto") => {
|
|
91
|
-
if (val === "") {
|
|
92
|
-
val = "0";
|
|
93
|
-
}
|
|
94
|
-
let strVal = typeof val === "string" ? val : val.toString();
|
|
95
|
-
const originalHasCommas = typeof val === "string" && /,/.test(val);
|
|
96
|
-
strVal = strVal.replace(/,/g, "");
|
|
97
|
-
const [integerPart, fractionalPart = ""] = strVal.split(".");
|
|
98
|
-
let formattedFractional = fractionalPart;
|
|
99
|
-
if (decimals !== "auto") {
|
|
100
|
-
formattedFractional = fractionalPart.padEnd(decimals, "0").slice(0, decimals);
|
|
101
|
-
}
|
|
102
|
-
const formattedNumber = formattedFractional ? `${integerPart}.${formattedFractional}` : integerPart;
|
|
103
|
-
const shouldAddCommas = commas === "auto" ? originalHasCommas : commas;
|
|
104
|
-
if (shouldAddCommas) {
|
|
105
|
-
const formattedIntegerWithCommas = BigInt(integerPart).toLocaleString("en-US");
|
|
106
|
-
return formattedFractional ? `${formattedIntegerWithCommas}.${formattedFractional}` : formattedIntegerWithCommas;
|
|
107
|
-
}
|
|
108
|
-
return formattedNumber;
|
|
109
|
-
};
|
|
110
88
|
var camelize = (str) => {
|
|
111
89
|
const convertToString = (string) => {
|
|
112
90
|
if (string) {
|
|
@@ -211,6 +189,8 @@ var isSuperset = (set, subset) => {
|
|
|
211
189
|
}
|
|
212
190
|
return true;
|
|
213
191
|
};
|
|
192
|
+
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
193
|
+
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
214
194
|
|
|
215
195
|
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
216
196
|
var import_node_util = __toESM(require("util"), 1);
|
|
@@ -539,26 +519,6 @@ var makeCancelable = (promise) => {
|
|
|
539
519
|
}
|
|
540
520
|
};
|
|
541
521
|
};
|
|
542
|
-
var transformToBaseUnit = (estFee, chainDecimals) => {
|
|
543
|
-
const t = estFee.length - chainDecimals;
|
|
544
|
-
let s = "";
|
|
545
|
-
if (t < 0) {
|
|
546
|
-
for (let i = 0; i < Math.abs(t) - 1; i++) {
|
|
547
|
-
s += "0";
|
|
548
|
-
}
|
|
549
|
-
s = s + estFee;
|
|
550
|
-
for (let i = 0; i < s.length; i++) {
|
|
551
|
-
if (s.slice(s.length - 1) !== "0") {
|
|
552
|
-
break;
|
|
553
|
-
}
|
|
554
|
-
s = s.substring(0, s.length - 1);
|
|
555
|
-
}
|
|
556
|
-
s = "0." + s;
|
|
557
|
-
} else {
|
|
558
|
-
s = (parseInt(estFee) / 10 ** chainDecimals).toString();
|
|
559
|
-
}
|
|
560
|
-
return parseFloat(s) !== 0 ? s : "0";
|
|
561
|
-
};
|
|
562
522
|
var unimplemented = ({ ...props }) => {
|
|
563
523
|
};
|
|
564
524
|
var mergeDeep = (target, ...sources) => {
|
|
@@ -581,8 +541,6 @@ var mergeDeep = (target, ...sources) => {
|
|
|
581
541
|
}
|
|
582
542
|
return mergeDeep(target, ...sources);
|
|
583
543
|
};
|
|
584
|
-
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
585
|
-
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
586
544
|
// Annotate the CommonJS export names for ESM import in node:
|
|
587
545
|
0 && (module.exports = {
|
|
588
546
|
addedTo,
|
|
@@ -596,7 +554,6 @@ var minBigInt = (...values) => values.reduce((min, current) => current < min ? c
|
|
|
596
554
|
eqSet,
|
|
597
555
|
extractUrlValue,
|
|
598
556
|
formatAccountSs58,
|
|
599
|
-
formatNumber,
|
|
600
557
|
inChrome,
|
|
601
558
|
isSuperset,
|
|
602
559
|
isValidAddress,
|
|
@@ -619,7 +576,6 @@ var minBigInt = (...values) => values.reduce((min, current) => current < min ? c
|
|
|
619
576
|
shuffle,
|
|
620
577
|
snakeToCamel,
|
|
621
578
|
sortWithNull,
|
|
622
|
-
transformToBaseUnit,
|
|
623
579
|
unescape,
|
|
624
580
|
unimplemented,
|
|
625
581
|
unitToPlanck,
|
package/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58,
|
|
2
|
-
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties,
|
|
1
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.cjs';
|
|
2
|
+
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.cjs';
|
|
3
3
|
import '@w3ux/types';
|
|
4
4
|
import 'react';
|
|
5
5
|
import './types.cjs';
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58,
|
|
2
|
-
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties,
|
|
1
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.js';
|
|
2
|
+
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.js';
|
|
3
3
|
import '@w3ux/types';
|
|
4
4
|
import 'react';
|
|
5
5
|
import './types.js';
|
package/index.js
CHANGED
|
@@ -13,26 +13,6 @@ var minDecimalPlaces = (val, minDecimals) => {
|
|
|
13
13
|
return "0";
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
var formatNumber = (val, decimals, commas = "auto") => {
|
|
17
|
-
if (val === "") {
|
|
18
|
-
val = "0";
|
|
19
|
-
}
|
|
20
|
-
let strVal = typeof val === "string" ? val : val.toString();
|
|
21
|
-
const originalHasCommas = typeof val === "string" && /,/.test(val);
|
|
22
|
-
strVal = strVal.replace(/,/g, "");
|
|
23
|
-
const [integerPart, fractionalPart = ""] = strVal.split(".");
|
|
24
|
-
let formattedFractional = fractionalPart;
|
|
25
|
-
if (decimals !== "auto") {
|
|
26
|
-
formattedFractional = fractionalPart.padEnd(decimals, "0").slice(0, decimals);
|
|
27
|
-
}
|
|
28
|
-
const formattedNumber = formattedFractional ? `${integerPart}.${formattedFractional}` : integerPart;
|
|
29
|
-
const shouldAddCommas = commas === "auto" ? originalHasCommas : commas;
|
|
30
|
-
if (shouldAddCommas) {
|
|
31
|
-
const formattedIntegerWithCommas = BigInt(integerPart).toLocaleString("en-US");
|
|
32
|
-
return formattedFractional ? `${formattedIntegerWithCommas}.${formattedFractional}` : formattedIntegerWithCommas;
|
|
33
|
-
}
|
|
34
|
-
return formattedNumber;
|
|
35
|
-
};
|
|
36
16
|
var camelize = (str) => {
|
|
37
17
|
const convertToString = (string) => {
|
|
38
18
|
if (string) {
|
|
@@ -137,6 +117,8 @@ var isSuperset = (set, subset) => {
|
|
|
137
117
|
}
|
|
138
118
|
return true;
|
|
139
119
|
};
|
|
120
|
+
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
121
|
+
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
140
122
|
|
|
141
123
|
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
142
124
|
import util from "node:util";
|
|
@@ -465,26 +447,6 @@ var makeCancelable = (promise) => {
|
|
|
465
447
|
}
|
|
466
448
|
};
|
|
467
449
|
};
|
|
468
|
-
var transformToBaseUnit = (estFee, chainDecimals) => {
|
|
469
|
-
const t = estFee.length - chainDecimals;
|
|
470
|
-
let s = "";
|
|
471
|
-
if (t < 0) {
|
|
472
|
-
for (let i = 0; i < Math.abs(t) - 1; i++) {
|
|
473
|
-
s += "0";
|
|
474
|
-
}
|
|
475
|
-
s = s + estFee;
|
|
476
|
-
for (let i = 0; i < s.length; i++) {
|
|
477
|
-
if (s.slice(s.length - 1) !== "0") {
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
s = s.substring(0, s.length - 1);
|
|
481
|
-
}
|
|
482
|
-
s = "0." + s;
|
|
483
|
-
} else {
|
|
484
|
-
s = (parseInt(estFee) / 10 ** chainDecimals).toString();
|
|
485
|
-
}
|
|
486
|
-
return parseFloat(s) !== 0 ? s : "0";
|
|
487
|
-
};
|
|
488
450
|
var unimplemented = ({ ...props }) => {
|
|
489
451
|
};
|
|
490
452
|
var mergeDeep = (target, ...sources) => {
|
|
@@ -507,8 +469,6 @@ var mergeDeep = (target, ...sources) => {
|
|
|
507
469
|
}
|
|
508
470
|
return mergeDeep(target, ...sources);
|
|
509
471
|
};
|
|
510
|
-
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
511
|
-
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
512
472
|
export {
|
|
513
473
|
addedTo,
|
|
514
474
|
appendOr,
|
|
@@ -521,7 +481,6 @@ export {
|
|
|
521
481
|
eqSet,
|
|
522
482
|
extractUrlValue,
|
|
523
483
|
formatAccountSs58,
|
|
524
|
-
formatNumber,
|
|
525
484
|
inChrome,
|
|
526
485
|
isSuperset,
|
|
527
486
|
isValidAddress,
|
|
@@ -544,7 +503,6 @@ export {
|
|
|
544
503
|
shuffle,
|
|
545
504
|
snakeToCamel,
|
|
546
505
|
sortWithNull,
|
|
547
|
-
transformToBaseUnit,
|
|
548
506
|
unescape,
|
|
549
507
|
unimplemented,
|
|
550
508
|
unitToPlanck,
|
package/package.json
CHANGED
package/unit.cjs
CHANGED
|
@@ -40,9 +40,7 @@ __export(unit_exports, {
|
|
|
40
40
|
localStorageOrDefault: () => localStorageOrDefault,
|
|
41
41
|
makeCancelable: () => makeCancelable,
|
|
42
42
|
matchedProperties: () => matchedProperties,
|
|
43
|
-
maxBigInt: () => maxBigInt,
|
|
44
43
|
mergeDeep: () => mergeDeep,
|
|
45
|
-
minBigInt: () => minBigInt,
|
|
46
44
|
planckToUnit: () => planckToUnit,
|
|
47
45
|
remToUnit: () => remToUnit,
|
|
48
46
|
removeVarFromUrlHash: () => removeVarFromUrlHash,
|
|
@@ -50,7 +48,6 @@ __export(unit_exports, {
|
|
|
50
48
|
setStateWithRef: () => setStateWithRef,
|
|
51
49
|
snakeToCamel: () => snakeToCamel,
|
|
52
50
|
sortWithNull: () => sortWithNull,
|
|
53
|
-
transformToBaseUnit: () => transformToBaseUnit,
|
|
54
51
|
unescape: () => unescape,
|
|
55
52
|
unimplemented: () => unimplemented,
|
|
56
53
|
unitToPlanck: () => unitToPlanck,
|
|
@@ -414,26 +411,6 @@ var makeCancelable = (promise) => {
|
|
|
414
411
|
}
|
|
415
412
|
};
|
|
416
413
|
};
|
|
417
|
-
var transformToBaseUnit = (estFee, chainDecimals) => {
|
|
418
|
-
const t = estFee.length - chainDecimals;
|
|
419
|
-
let s = "";
|
|
420
|
-
if (t < 0) {
|
|
421
|
-
for (let i = 0; i < Math.abs(t) - 1; i++) {
|
|
422
|
-
s += "0";
|
|
423
|
-
}
|
|
424
|
-
s = s + estFee;
|
|
425
|
-
for (let i = 0; i < s.length; i++) {
|
|
426
|
-
if (s.slice(s.length - 1) !== "0") {
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
s = s.substring(0, s.length - 1);
|
|
430
|
-
}
|
|
431
|
-
s = "0." + s;
|
|
432
|
-
} else {
|
|
433
|
-
s = (parseInt(estFee) / 10 ** chainDecimals).toString();
|
|
434
|
-
}
|
|
435
|
-
return parseFloat(s) !== 0 ? s : "0";
|
|
436
|
-
};
|
|
437
414
|
var unimplemented = ({ ...props }) => {
|
|
438
415
|
};
|
|
439
416
|
var mergeDeep = (target, ...sources) => {
|
|
@@ -456,8 +433,6 @@ var mergeDeep = (target, ...sources) => {
|
|
|
456
433
|
}
|
|
457
434
|
return mergeDeep(target, ...sources);
|
|
458
435
|
};
|
|
459
|
-
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
460
|
-
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
461
436
|
// Annotate the CommonJS export names for ESM import in node:
|
|
462
437
|
0 && (module.exports = {
|
|
463
438
|
addedTo,
|
|
@@ -471,9 +446,7 @@ var minBigInt = (...values) => values.reduce((min, current) => current < min ? c
|
|
|
471
446
|
localStorageOrDefault,
|
|
472
447
|
makeCancelable,
|
|
473
448
|
matchedProperties,
|
|
474
|
-
maxBigInt,
|
|
475
449
|
mergeDeep,
|
|
476
|
-
minBigInt,
|
|
477
450
|
planckToUnit,
|
|
478
451
|
remToUnit,
|
|
479
452
|
removeVarFromUrlHash,
|
|
@@ -481,7 +454,6 @@ var minBigInt = (...values) => values.reduce((min, current) => current < min ? c
|
|
|
481
454
|
setStateWithRef,
|
|
482
455
|
snakeToCamel,
|
|
483
456
|
sortWithNull,
|
|
484
|
-
transformToBaseUnit,
|
|
485
457
|
unescape,
|
|
486
458
|
unimplemented,
|
|
487
459
|
unitToPlanck,
|
package/unit.d.cts
CHANGED
|
@@ -135,17 +135,6 @@ declare const makeCancelable: (promise: Promise<AnyObject>) => {
|
|
|
135
135
|
promise: Promise<unknown>;
|
|
136
136
|
cancel: () => void;
|
|
137
137
|
};
|
|
138
|
-
/**
|
|
139
|
-
* The transformToBaseUnit function is used to transform a given estimated
|
|
140
|
-
* fee value from its current representation to its base unit representation,
|
|
141
|
-
* considering the provided chain decimals. The function is designed to handle
|
|
142
|
-
* cases where the chain decimals are either greater or less than the length
|
|
143
|
-
* of the estimated fee.
|
|
144
|
-
* @param {string} estFee : The estimated fee value that needs to be transformed
|
|
145
|
-
* to its base unit representation.
|
|
146
|
-
* @param {number} chainDecimals: The number of decimal places used by the blockchain.
|
|
147
|
-
*/
|
|
148
|
-
declare const transformToBaseUnit: (estFee: string, chainDecimals: number) => string;
|
|
149
138
|
/**
|
|
150
139
|
* @name unimplemented
|
|
151
140
|
* @summary A placeholder function to signal a deliberate unimplementation.
|
|
@@ -160,27 +149,5 @@ declare const unimplemented: ({ ...props }: {
|
|
|
160
149
|
* @param ...sources
|
|
161
150
|
*/
|
|
162
151
|
declare const mergeDeep: (target: AnyObject, ...sources: AnyObject[]) => AnyObject;
|
|
163
|
-
/**
|
|
164
|
-
* Finds the maximum value among a list of BigInt values.
|
|
165
|
-
*
|
|
166
|
-
* @function maxBigInt
|
|
167
|
-
* @param {...bigint} values - A list of BigInt values to compare.
|
|
168
|
-
* @returns {bigint} The largest BigInt value in the provided list.
|
|
169
|
-
* @example
|
|
170
|
-
* // Returns the maximum BigInt value
|
|
171
|
-
* maxBigInt(10n, 50n, 30n, 100n, 20n); // 100n
|
|
172
|
-
*/
|
|
173
|
-
declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
174
|
-
/**
|
|
175
|
-
* Finds the minimum value among a list of BigInt values.
|
|
176
|
-
*
|
|
177
|
-
* @function minBigInt
|
|
178
|
-
* @param {...bigint} values - A list of BigInt values to compare.
|
|
179
|
-
* @returns {bigint} The smallest BigInt value in the provided list.
|
|
180
|
-
* @example
|
|
181
|
-
* // Returns the minimum BigInt value
|
|
182
|
-
* minBigInt(10n, 50n, 30n, 100n, 20n); // 10n
|
|
183
|
-
*/
|
|
184
|
-
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
185
152
|
|
|
186
|
-
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties,
|
|
153
|
+
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash };
|
package/unit.d.ts
CHANGED
|
@@ -135,17 +135,6 @@ declare const makeCancelable: (promise: Promise<AnyObject>) => {
|
|
|
135
135
|
promise: Promise<unknown>;
|
|
136
136
|
cancel: () => void;
|
|
137
137
|
};
|
|
138
|
-
/**
|
|
139
|
-
* The transformToBaseUnit function is used to transform a given estimated
|
|
140
|
-
* fee value from its current representation to its base unit representation,
|
|
141
|
-
* considering the provided chain decimals. The function is designed to handle
|
|
142
|
-
* cases where the chain decimals are either greater or less than the length
|
|
143
|
-
* of the estimated fee.
|
|
144
|
-
* @param {string} estFee : The estimated fee value that needs to be transformed
|
|
145
|
-
* to its base unit representation.
|
|
146
|
-
* @param {number} chainDecimals: The number of decimal places used by the blockchain.
|
|
147
|
-
*/
|
|
148
|
-
declare const transformToBaseUnit: (estFee: string, chainDecimals: number) => string;
|
|
149
138
|
/**
|
|
150
139
|
* @name unimplemented
|
|
151
140
|
* @summary A placeholder function to signal a deliberate unimplementation.
|
|
@@ -160,27 +149,5 @@ declare const unimplemented: ({ ...props }: {
|
|
|
160
149
|
* @param ...sources
|
|
161
150
|
*/
|
|
162
151
|
declare const mergeDeep: (target: AnyObject, ...sources: AnyObject[]) => AnyObject;
|
|
163
|
-
/**
|
|
164
|
-
* Finds the maximum value among a list of BigInt values.
|
|
165
|
-
*
|
|
166
|
-
* @function maxBigInt
|
|
167
|
-
* @param {...bigint} values - A list of BigInt values to compare.
|
|
168
|
-
* @returns {bigint} The largest BigInt value in the provided list.
|
|
169
|
-
* @example
|
|
170
|
-
* // Returns the maximum BigInt value
|
|
171
|
-
* maxBigInt(10n, 50n, 30n, 100n, 20n); // 100n
|
|
172
|
-
*/
|
|
173
|
-
declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
174
|
-
/**
|
|
175
|
-
* Finds the minimum value among a list of BigInt values.
|
|
176
|
-
*
|
|
177
|
-
* @function minBigInt
|
|
178
|
-
* @param {...bigint} values - A list of BigInt values to compare.
|
|
179
|
-
* @returns {bigint} The smallest BigInt value in the provided list.
|
|
180
|
-
* @example
|
|
181
|
-
* // Returns the minimum BigInt value
|
|
182
|
-
* minBigInt(10n, 50n, 30n, 100n, 20n); // 10n
|
|
183
|
-
*/
|
|
184
|
-
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
185
152
|
|
|
186
|
-
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties,
|
|
153
|
+
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash };
|
package/unit.js
CHANGED
|
@@ -354,26 +354,6 @@ var makeCancelable = (promise) => {
|
|
|
354
354
|
}
|
|
355
355
|
};
|
|
356
356
|
};
|
|
357
|
-
var transformToBaseUnit = (estFee, chainDecimals) => {
|
|
358
|
-
const t = estFee.length - chainDecimals;
|
|
359
|
-
let s = "";
|
|
360
|
-
if (t < 0) {
|
|
361
|
-
for (let i = 0; i < Math.abs(t) - 1; i++) {
|
|
362
|
-
s += "0";
|
|
363
|
-
}
|
|
364
|
-
s = s + estFee;
|
|
365
|
-
for (let i = 0; i < s.length; i++) {
|
|
366
|
-
if (s.slice(s.length - 1) !== "0") {
|
|
367
|
-
break;
|
|
368
|
-
}
|
|
369
|
-
s = s.substring(0, s.length - 1);
|
|
370
|
-
}
|
|
371
|
-
s = "0." + s;
|
|
372
|
-
} else {
|
|
373
|
-
s = (parseInt(estFee) / 10 ** chainDecimals).toString();
|
|
374
|
-
}
|
|
375
|
-
return parseFloat(s) !== 0 ? s : "0";
|
|
376
|
-
};
|
|
377
357
|
var unimplemented = ({ ...props }) => {
|
|
378
358
|
};
|
|
379
359
|
var mergeDeep = (target, ...sources) => {
|
|
@@ -396,8 +376,6 @@ var mergeDeep = (target, ...sources) => {
|
|
|
396
376
|
}
|
|
397
377
|
return mergeDeep(target, ...sources);
|
|
398
378
|
};
|
|
399
|
-
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
400
|
-
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
401
379
|
export {
|
|
402
380
|
addedTo,
|
|
403
381
|
applyWidthAsPadding,
|
|
@@ -410,9 +388,7 @@ export {
|
|
|
410
388
|
localStorageOrDefault,
|
|
411
389
|
makeCancelable,
|
|
412
390
|
matchedProperties,
|
|
413
|
-
maxBigInt,
|
|
414
391
|
mergeDeep,
|
|
415
|
-
minBigInt,
|
|
416
392
|
planckToUnit,
|
|
417
393
|
remToUnit,
|
|
418
394
|
removeVarFromUrlHash,
|
|
@@ -420,7 +396,6 @@ export {
|
|
|
420
396
|
setStateWithRef,
|
|
421
397
|
snakeToCamel,
|
|
422
398
|
sortWithNull,
|
|
423
|
-
transformToBaseUnit,
|
|
424
399
|
unescape,
|
|
425
400
|
unimplemented,
|
|
426
401
|
unitToPlanck,
|