@gkucmierz/utils 4.0.1 → 4.0.2
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/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
const formatBigNumberBoth = (num, separator = '', wrapFn = _ => _) => {
|
|
16
16
|
const str = String(num);
|
|
17
17
|
const rev = [...str].reverse().join('');
|
|
18
|
-
const match = rev.match(/(\d
|
|
18
|
+
const match = rev.match(/(\d*\.[+-]?)|(\d{3}[+-]?)|(\d{1,3}[+-]?)|([+-])/g);
|
|
19
19
|
const revInside = (match && match.join('') === rev)
|
|
20
20
|
? match.map(part => [...part].reverse().join(''))
|
|
21
21
|
: [str];
|
|
@@ -45,6 +45,13 @@ export const formatBigNumber = formatBigNumberBoth;
|
|
|
45
45
|
*/
|
|
46
46
|
export const formatBigNumberBI = formatBigNumberBoth;
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Creates an alternating span wrapper function for number segments with 'even' and 'odd' classes.
|
|
50
|
+
* Useful for syntax highlighting or alternating styles of formatted number segments.
|
|
51
|
+
*
|
|
52
|
+
* @returns {function(string): string} A wrapper callback function for number segments.
|
|
53
|
+
* @see {@link https://instacode.app/run/FASwtgDg9gTgLgAgN4IO4wIYQGIDsEC+CAZjFGAgEQACA5gNYCuAxmCAKYwBeA9I3CAA2AZ0oBuYMHRY8EoA|▶ Try it live in Instacode}
|
|
54
|
+
*/
|
|
48
55
|
export const wrapFn = () => {
|
|
49
56
|
let even = true;
|
|
50
57
|
return part => {
|
|
@@ -53,3 +60,4 @@ export const wrapFn = () => {
|
|
|
53
60
|
return `<span class="${cls}">${part}</span>`;
|
|
54
61
|
};
|
|
55
62
|
};
|
|
63
|
+
|