cafe-utility 21.4.0 → 21.5.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/index.d.ts +2 -0
- package/index.js +8 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -342,6 +342,7 @@ declare function diffKeys(objectA: CafeObject, objectB: CafeObject): {
|
|
|
342
342
|
declare function pickRandomKey(object: CafeObject): string;
|
|
343
343
|
declare function mapRandomKey<T>(object: CafeObject<T>, mapFunction: (value: T) => T): string;
|
|
344
344
|
declare function fromObjectString<T>(string: string): T;
|
|
345
|
+
declare function fromDecimals(number: string, decimals: number, unit?: string): string;
|
|
345
346
|
interface NumberFormatOptions {
|
|
346
347
|
precision?: number;
|
|
347
348
|
longForm?: boolean;
|
|
@@ -595,6 +596,7 @@ export declare const Numbers: {
|
|
|
595
596
|
increment: typeof increment;
|
|
596
597
|
decrement: typeof decrement;
|
|
597
598
|
format: typeof formatNumber;
|
|
599
|
+
fromDecimals: typeof fromDecimals;
|
|
598
600
|
asMegabytes: typeof asMegabytes;
|
|
599
601
|
convertBytes: typeof convertBytes;
|
|
600
602
|
hexToRgb: typeof hexToRgb;
|
package/index.js
CHANGED
|
@@ -1594,6 +1594,13 @@ const thresholds = [1e3, 1e6, 1e9, 1e12, 1e15, 1e18, 1e21, 1e24, 1e27, 1e30, 1e9
|
|
|
1594
1594
|
'decillion'
|
|
1595
1595
|
],
|
|
1596
1596
|
shortNumberUnits = ['K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'O', 'N', 'gwei', 'bzz', 'eth', 'btc', 'dai', 'D']
|
|
1597
|
+
function fromDecimals(n, t, e) {
|
|
1598
|
+
let r = n.length - t
|
|
1599
|
+
if (r <= 0) return '0.' + '0'.repeat(-r) + n + (e ? ' ' + e : '')
|
|
1600
|
+
let o = n.substring(0, r),
|
|
1601
|
+
i = n.substring(r)
|
|
1602
|
+
return o === '' && (o = '0'), o + '.' + i + (e ? ' ' + e : '')
|
|
1603
|
+
}
|
|
1597
1604
|
function formatNumber(n, t) {
|
|
1598
1605
|
var e, r
|
|
1599
1606
|
const o = (e = t?.longForm) !== null && e !== void 0 ? e : !1,
|
|
@@ -2382,6 +2389,7 @@ function raycastCircle(n, t, e) {
|
|
|
2382
2389
|
increment,
|
|
2383
2390
|
decrement,
|
|
2384
2391
|
format: formatNumber,
|
|
2392
|
+
fromDecimals,
|
|
2385
2393
|
asMegabytes,
|
|
2386
2394
|
convertBytes,
|
|
2387
2395
|
hexToRgb,
|