@w3ux/utils 1.1.1-beta.9 → 1.2.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 +3 -0
- package/base.d.cts +6 -1
- package/base.d.ts +6 -1
- package/base.js +2 -0
- package/index.cjs +4 -1
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/index.js +3 -1
- package/package.json +1 -1
- package/unit.cjs +2 -1
- package/unit.js +2 -1
package/base.cjs
CHANGED
|
@@ -32,6 +32,7 @@ __export(base_exports, {
|
|
|
32
32
|
pageFromUri: () => pageFromUri,
|
|
33
33
|
removeHexPrefix: () => removeHexPrefix,
|
|
34
34
|
rmCommas: () => rmCommas,
|
|
35
|
+
rmDecimals: () => rmDecimals,
|
|
35
36
|
shuffle: () => shuffle,
|
|
36
37
|
withTimeout: () => withTimeout
|
|
37
38
|
});
|
|
@@ -110,6 +111,7 @@ var pageFromUri = (pathname, fallback) => {
|
|
|
110
111
|
return page.trim();
|
|
111
112
|
};
|
|
112
113
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
114
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
113
115
|
var shuffle = (array) => {
|
|
114
116
|
let currentIndex = array.length;
|
|
115
117
|
let randomIndex;
|
|
@@ -171,6 +173,7 @@ var minBigInt = (...values) => values.reduce((min, current) => current < min ? c
|
|
|
171
173
|
pageFromUri,
|
|
172
174
|
removeHexPrefix,
|
|
173
175
|
rmCommas,
|
|
176
|
+
rmDecimals,
|
|
174
177
|
shuffle,
|
|
175
178
|
withTimeout
|
|
176
179
|
});
|
package/base.d.cts
CHANGED
|
@@ -43,6 +43,11 @@ declare const pageFromUri: (pathname: string, fallback: string) => string;
|
|
|
43
43
|
* @summary Removes the commas from a string.
|
|
44
44
|
*/
|
|
45
45
|
declare const rmCommas: (val: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* @name rmDecimals
|
|
48
|
+
* @summary Removes the decimal point and decimals from a string.
|
|
49
|
+
*/
|
|
50
|
+
declare const rmDecimals: (str: any) => any;
|
|
46
51
|
/**
|
|
47
52
|
* @name shuffle
|
|
48
53
|
* @summary Shuffle a set of objects.
|
|
@@ -101,4 +106,4 @@ declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
|
101
106
|
*/
|
|
102
107
|
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
103
108
|
|
|
104
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
|
|
109
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout };
|
package/base.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ declare const pageFromUri: (pathname: string, fallback: string) => string;
|
|
|
43
43
|
* @summary Removes the commas from a string.
|
|
44
44
|
*/
|
|
45
45
|
declare const rmCommas: (val: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* @name rmDecimals
|
|
48
|
+
* @summary Removes the decimal point and decimals from a string.
|
|
49
|
+
*/
|
|
50
|
+
declare const rmDecimals: (str: any) => any;
|
|
46
51
|
/**
|
|
47
52
|
* @name shuffle
|
|
48
53
|
* @summary Shuffle a set of objects.
|
|
@@ -101,4 +106,4 @@ declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
|
101
106
|
*/
|
|
102
107
|
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
103
108
|
|
|
104
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
|
|
109
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout };
|
package/base.js
CHANGED
|
@@ -73,6 +73,7 @@ var pageFromUri = (pathname, fallback) => {
|
|
|
73
73
|
return page.trim();
|
|
74
74
|
};
|
|
75
75
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
76
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
76
77
|
var shuffle = (array) => {
|
|
77
78
|
let currentIndex = array.length;
|
|
78
79
|
let randomIndex;
|
|
@@ -133,6 +134,7 @@ export {
|
|
|
133
134
|
pageFromUri,
|
|
134
135
|
removeHexPrefix,
|
|
135
136
|
rmCommas,
|
|
137
|
+
rmDecimals,
|
|
136
138
|
shuffle,
|
|
137
139
|
withTimeout
|
|
138
140
|
};
|
package/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ __export(src_exports, {
|
|
|
47
47
|
removeVarFromUrlHash: () => removeVarFromUrlHash,
|
|
48
48
|
removedFrom: () => removedFrom,
|
|
49
49
|
rmCommas: () => rmCommas,
|
|
50
|
+
rmDecimals: () => rmDecimals,
|
|
50
51
|
setStateWithRef: () => setStateWithRef,
|
|
51
52
|
shuffle: () => shuffle,
|
|
52
53
|
snakeToCamel: () => snakeToCamel,
|
|
@@ -135,6 +136,7 @@ var pageFromUri = (pathname, fallback) => {
|
|
|
135
136
|
return page.trim();
|
|
136
137
|
};
|
|
137
138
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
139
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
138
140
|
var shuffle = (array) => {
|
|
139
141
|
let currentIndex = array.length;
|
|
140
142
|
let randomIndex;
|
|
@@ -200,7 +202,7 @@ var planckToUnit = (val, units) => {
|
|
|
200
202
|
try {
|
|
201
203
|
units = Math.max(Math.round(units), 0);
|
|
202
204
|
const bigIntVal = typeof val === "bigint" ? val : BigInt(
|
|
203
|
-
typeof val === "number" ? Math.floor(val).toString() : rmCommas(val)
|
|
205
|
+
typeof val === "number" ? Math.floor(val).toString() : rmDecimals(rmCommas(val))
|
|
204
206
|
);
|
|
205
207
|
const divisor = units === 0 ? 1n : BigInt(10) ** BigInt(units);
|
|
206
208
|
const integerPart = bigIntVal / divisor;
|
|
@@ -422,6 +424,7 @@ var mergeDeep = (target, ...sources) => {
|
|
|
422
424
|
removeVarFromUrlHash,
|
|
423
425
|
removedFrom,
|
|
424
426
|
rmCommas,
|
|
427
|
+
rmDecimals,
|
|
425
428
|
setStateWithRef,
|
|
426
429
|
shuffle,
|
|
427
430
|
snakeToCamel,
|
package/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.cjs';
|
|
1
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout } from './base.cjs';
|
|
2
2
|
export { u8aConcat } from './convert.cjs';
|
|
3
3
|
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.cjs';
|
|
4
4
|
import '@w3ux/types';
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.js';
|
|
1
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout } from './base.js';
|
|
2
2
|
export { u8aConcat } from './convert.js';
|
|
3
3
|
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.js';
|
|
4
4
|
import '@w3ux/types';
|
package/index.js
CHANGED
|
@@ -73,6 +73,7 @@ var pageFromUri = (pathname, fallback) => {
|
|
|
73
73
|
return page.trim();
|
|
74
74
|
};
|
|
75
75
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
76
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
76
77
|
var shuffle = (array) => {
|
|
77
78
|
let currentIndex = array.length;
|
|
78
79
|
let randomIndex;
|
|
@@ -138,7 +139,7 @@ var planckToUnit = (val, units) => {
|
|
|
138
139
|
try {
|
|
139
140
|
units = Math.max(Math.round(units), 0);
|
|
140
141
|
const bigIntVal = typeof val === "bigint" ? val : BigInt(
|
|
141
|
-
typeof val === "number" ? Math.floor(val).toString() : rmCommas(val)
|
|
142
|
+
typeof val === "number" ? Math.floor(val).toString() : rmDecimals(rmCommas(val))
|
|
142
143
|
);
|
|
143
144
|
const divisor = units === 0 ? 1n : BigInt(10) ** BigInt(units);
|
|
144
145
|
const integerPart = bigIntVal / divisor;
|
|
@@ -359,6 +360,7 @@ export {
|
|
|
359
360
|
removeVarFromUrlHash,
|
|
360
361
|
removedFrom,
|
|
361
362
|
rmCommas,
|
|
363
|
+
rmDecimals,
|
|
362
364
|
setStateWithRef,
|
|
363
365
|
shuffle,
|
|
364
366
|
snakeToCamel,
|
package/package.json
CHANGED
package/unit.cjs
CHANGED
|
@@ -47,6 +47,7 @@ module.exports = __toCommonJS(unit_exports);
|
|
|
47
47
|
// src/base.ts
|
|
48
48
|
var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
|
|
49
49
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
50
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
50
51
|
|
|
51
52
|
// src/unit.ts
|
|
52
53
|
var import_substrate_bindings2 = require("@polkadot-api/substrate-bindings");
|
|
@@ -54,7 +55,7 @@ var planckToUnit = (val, units) => {
|
|
|
54
55
|
try {
|
|
55
56
|
units = Math.max(Math.round(units), 0);
|
|
56
57
|
const bigIntVal = typeof val === "bigint" ? val : BigInt(
|
|
57
|
-
typeof val === "number" ? Math.floor(val).toString() : rmCommas(val)
|
|
58
|
+
typeof val === "number" ? Math.floor(val).toString() : rmDecimals(rmCommas(val))
|
|
58
59
|
);
|
|
59
60
|
const divisor = units === 0 ? 1n : BigInt(10) ** BigInt(units);
|
|
60
61
|
const integerPart = bigIntVal / divisor;
|
package/unit.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/base.ts
|
|
2
2
|
import { AccountId } from "@polkadot-api/substrate-bindings";
|
|
3
3
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
4
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
4
5
|
|
|
5
6
|
// src/unit.ts
|
|
6
7
|
import { AccountId as AccountId2 } from "@polkadot-api/substrate-bindings";
|
|
@@ -8,7 +9,7 @@ var planckToUnit = (val, units) => {
|
|
|
8
9
|
try {
|
|
9
10
|
units = Math.max(Math.round(units), 0);
|
|
10
11
|
const bigIntVal = typeof val === "bigint" ? val : BigInt(
|
|
11
|
-
typeof val === "number" ? Math.floor(val).toString() : rmCommas(val)
|
|
12
|
+
typeof val === "number" ? Math.floor(val).toString() : rmDecimals(rmCommas(val))
|
|
12
13
|
);
|
|
13
14
|
const divisor = units === 0 ? 1n : BigInt(10) ** BigInt(units);
|
|
14
15
|
const integerPart = bigIntVal / divisor;
|