@edgeandnode/eds-utils 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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/bigIntToNumber.d.ts +17 -0
- package/dist/bigIntToNumber.d.ts.map +1 -0
- package/dist/bigIntToNumber.js +25 -0
- package/dist/bigIntToNumber.js.map +1 -0
- package/dist/camelToKebab.d.ts +3 -0
- package/dist/camelToKebab.d.ts.map +1 -0
- package/dist/camelToKebab.js +15 -0
- package/dist/camelToKebab.js.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -0
- package/dist/createIdenticon.d.ts +2 -0
- package/dist/createIdenticon.d.ts.map +1 -0
- package/dist/createIdenticon.js +75 -0
- package/dist/createIdenticon.js.map +1 -0
- package/dist/formatAddress.d.ts +14 -0
- package/dist/formatAddress.d.ts.map +1 -0
- package/dist/formatAddress.js +28 -0
- package/dist/formatAddress.js.map +1 -0
- package/dist/formatBigInt.d.ts +23 -0
- package/dist/formatBigInt.d.ts.map +1 -0
- package/dist/formatBigInt.js +38 -0
- package/dist/formatBigInt.js.map +1 -0
- package/dist/getKey.d.ts +14 -0
- package/dist/getKey.d.ts.map +1 -0
- package/dist/getKey.js +36 -0
- package/dist/getKey.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/loremIpsum.d.ts +11 -0
- package/dist/loremIpsum.d.ts.map +1 -0
- package/dist/loremIpsum.js +136 -0
- package/dist/loremIpsum.js.map +1 -0
- package/dist/numberToBigInt.d.ts +18 -0
- package/dist/numberToBigInt.d.ts.map +1 -0
- package/dist/numberToBigInt.js +27 -0
- package/dist/numberToBigInt.js.map +1 -0
- package/dist/parseBigInt.d.ts +25 -0
- package/dist/parseBigInt.d.ts.map +1 -0
- package/dist/parseBigInt.js +35 -0
- package/dist/parseBigInt.js.map +1 -0
- package/dist/parseNumber.d.ts +17 -0
- package/dist/parseNumber.d.ts.map +1 -0
- package/dist/parseNumber.js +18 -0
- package/dist/parseNumber.js.map +1 -0
- package/dist/sliceWrap.d.ts +3 -0
- package/dist/sliceWrap.d.ts.map +1 -0
- package/dist/sliceWrap.js +11 -0
- package/dist/sliceWrap.js.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +37 -0
- package/src/bigIntToNumber.ts +34 -0
- package/src/camelToKebab.ts +16 -0
- package/src/constants.ts +2 -0
- package/src/createIdenticon.ts +84 -0
- package/src/formatAddress.ts +33 -0
- package/src/formatBigInt.ts +60 -0
- package/src/getKey.ts +37 -0
- package/src/index.ts +13 -0
- package/src/loremIpsum.ts +143 -0
- package/src/numberToBigInt.ts +38 -0
- package/src/parseBigInt.ts +51 -0
- package/src/parseNumber.ts +24 -0
- package/src/sliceWrap.ts +9 -0
- package/src/types.ts +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Edge & Node
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @edgeandnode/eds-utils
|
|
2
|
+
|
|
3
|
+
General utility functions for The Edge Design System.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @edgeandnode/eds-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Utilities
|
|
12
|
+
|
|
13
|
+
### BigInt Formatting
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { bigIntToNumber, formatBigInt, numberToBigInt, parseBigInt } from '@edgeandnode/eds-utils'
|
|
17
|
+
|
|
18
|
+
// Format a BigInt with decimals (precision defaults to 18)
|
|
19
|
+
formatBigInt(1000000000000000000n) // "1"
|
|
20
|
+
formatBigInt(1500000000000000000n) // "1.5"
|
|
21
|
+
|
|
22
|
+
// Parse a string to BigInt
|
|
23
|
+
parseBigInt('1.5') // 1500000000000000000n
|
|
24
|
+
|
|
25
|
+
// Convert between BigInt and number
|
|
26
|
+
bigIntToNumber(1000000000000000000n) // 1
|
|
27
|
+
numberToBigInt(1.5) // 1500000000000000000n
|
|
28
|
+
|
|
29
|
+
// Custom precision
|
|
30
|
+
formatBigInt(1000000n, { precision: 6n }) // "1"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### String Utilities
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { camelToKebab } from '@edgeandnode/eds-utils'
|
|
37
|
+
|
|
38
|
+
camelToKebab('backgroundColor') // "background-color"
|
|
39
|
+
camelToKebab('HTMLElement') // "html-element"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Identicon Generation
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { createIdenticon } from '@edgeandnode/eds-utils'
|
|
46
|
+
|
|
47
|
+
// Generate a deterministic identicon SVG from an Ethereum address
|
|
48
|
+
const svg = createIdenticon('0x1234...')
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface BigIntToNumberOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The number of digits starting from the right of `value` to consider as decimal places.
|
|
4
|
+
*
|
|
5
|
+
* @default 18n
|
|
6
|
+
*/
|
|
7
|
+
precision?: bigint | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Converts a bigint to a number.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The bigint to convert to a number.
|
|
13
|
+
* @param options - Conversion options.
|
|
14
|
+
* @returns The number representation of `value`
|
|
15
|
+
*/
|
|
16
|
+
export declare function bigIntToNumber(value: bigint, options?: BigIntToNumberOptions): number;
|
|
17
|
+
//# sourceMappingURL=bigIntToNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigIntToNumber.d.ts","sourceRoot":"","sources":["../src/bigIntToNumber.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAiBrF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a bigint to a number.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The bigint to convert to a number.
|
|
5
|
+
* @param options - Conversion options.
|
|
6
|
+
* @returns The number representation of `value`
|
|
7
|
+
*/
|
|
8
|
+
export function bigIntToNumber(value, options) {
|
|
9
|
+
const { precision = 18n } = options ?? {};
|
|
10
|
+
if (precision < 0n) {
|
|
11
|
+
throw new Error(`[bigIntToNumber] \`precision\` must be positive, got ${precision}`);
|
|
12
|
+
}
|
|
13
|
+
if (precision === 0n) {
|
|
14
|
+
return Number(value);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const valueString = String(value);
|
|
18
|
+
const decimalPointIndex = valueString.length - Number(precision);
|
|
19
|
+
if (decimalPointIndex <= 0) {
|
|
20
|
+
return Number(`0.${'0'.repeat(Math.abs(decimalPointIndex))}${valueString}`);
|
|
21
|
+
}
|
|
22
|
+
return Number(`${valueString.slice(0, decimalPointIndex)}.${valueString.slice(decimalPointIndex)}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=bigIntToNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigIntToNumber.js","sourceRoot":"","sources":["../src/bigIntToNumber.ts"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,OAA+B;IAC3E,MAAM,EAAE,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IACzC,IAAI,SAAS,GAAG,EAAE,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,wDAAwD,SAAS,EAAE,CAAC,CAAA;IACtF,CAAC;IACD,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;SAAM,CAAC;QACN,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QACjC,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;QAChE,IAAI,iBAAiB,IAAI,CAAC,EAAE,CAAC;YAC3B,OAAO,MAAM,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,WAAW,EAAE,CAAC,CAAA;QAC7E,CAAC;QACD,OAAO,MAAM,CACX,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CACrF,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camelToKebab.d.ts","sourceRoot":"","sources":["../src/camelToKebab.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,UAc1C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Converts a camelCase string to kebab-case. */
|
|
2
|
+
export function camelToKebab(string) {
|
|
3
|
+
return (string
|
|
4
|
+
// Insert dash between a group of uppercase letters and an uppercase letter followed by lowercase (`HTTPSEncryptionMethod200Success` => `HTTPS-EncryptionMethod200Success`)
|
|
5
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
|
6
|
+
// Insert dash between a lowercase letter and an uppercase letter (`HTTPS-EncryptionMethod200Success` => `HTTPS-Encryption-Method200Success`)
|
|
7
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
8
|
+
// Insert dash between a letter and a digit (`HTTPS-Encryption-Method200Success` => `HTTPS-Encryption-Method-200Success`)
|
|
9
|
+
.replace(/([A-Za-z])(\d)/g, '$1-$2')
|
|
10
|
+
// Insert dash between a digit and a letter (`HTTPS-Encryption-Method-200Success` => `HTTPS-Encryption-Method-200-Success`)
|
|
11
|
+
.replace(/(\d)([A-Za-z])/g, '$1-$2')
|
|
12
|
+
// Convert to lowercase (`HTTPS-Encryption-Method-200-Success` => `https-encryption-method-200-success`)
|
|
13
|
+
.toLowerCase());
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=camelToKebab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camelToKebab.js","sourceRoot":"","sources":["../src/camelToKebab.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,CACL,MAAM;QACJ,2KAA2K;SAC1K,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC;QAC1C,6IAA6I;SAC5I,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;QACpC,yHAAyH;SACxH,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;QACpC,2HAA2H;SAC1H,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;QACpC,wGAAwG;SACvG,WAAW,EAAE,CACjB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,+CAA+C,CAAA;AACxE,eAAO,MAAM,mBAAmB,+CAA+C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,4CAA4C,CAAA;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,4CAA4C,CAAA,CAAC,uCAAuC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIdenticon.d.ts","sourceRoot":"","sources":["../src/createIdenticon.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,UA6E9C"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import md5 from 'md5';
|
|
2
|
+
import { sliceWrap } from './sliceWrap.js';
|
|
3
|
+
const identiconCache = new Map();
|
|
4
|
+
export function createIdenticon(address) {
|
|
5
|
+
const lowercasedAddress = address.toLowerCase();
|
|
6
|
+
// Check the cache first
|
|
7
|
+
const cachedIdenticon = identiconCache.get(lowercasedAddress);
|
|
8
|
+
if (cachedIdenticon) {
|
|
9
|
+
return cachedIdenticon;
|
|
10
|
+
}
|
|
11
|
+
const hash = md5(lowercasedAddress);
|
|
12
|
+
const bytesPerPixel = 3;
|
|
13
|
+
const pixels = 5;
|
|
14
|
+
const rowPadding = (4 - ((pixels * bytesPerPixel) % 4)) % 4;
|
|
15
|
+
const pixelArraySize = pixels * (pixels * bytesPerPixel + rowPadding);
|
|
16
|
+
const fileHeaderSize = 14;
|
|
17
|
+
const dibHeaderSize = 40;
|
|
18
|
+
const totalHeaderSize = fileHeaderSize + dibHeaderSize;
|
|
19
|
+
const bufferSize = totalHeaderSize + pixelArraySize;
|
|
20
|
+
const buffer = new Uint8Array(bufferSize);
|
|
21
|
+
// Set up the bitmap headers
|
|
22
|
+
buffer[0] = 0x42; // 'B'
|
|
23
|
+
buffer[1] = 0x4d; // 'M'
|
|
24
|
+
buffer[2] = bufferSize & 0xff;
|
|
25
|
+
buffer[3] = (bufferSize >> 8) & 0xff;
|
|
26
|
+
buffer[4] = (bufferSize >> 16) & 0xff;
|
|
27
|
+
buffer[5] = (bufferSize >> 24) & 0xff;
|
|
28
|
+
buffer[10] = totalHeaderSize; // Pixel data offset
|
|
29
|
+
buffer[14] = dibHeaderSize;
|
|
30
|
+
buffer[18] = pixels & 0xff;
|
|
31
|
+
buffer[19] = (pixels >> 8) & 0xff;
|
|
32
|
+
buffer[22] = pixels & 0xff;
|
|
33
|
+
buffer[23] = (pixels >> 8) & 0xff;
|
|
34
|
+
buffer[26] = 1; // Planes
|
|
35
|
+
buffer[28] = 24; // Bits per pixel
|
|
36
|
+
// Determine the primary color based on the hash
|
|
37
|
+
const match = /#(..)(..)(..)/.exec(`#${hash.slice(0, 6)}`);
|
|
38
|
+
if (!match)
|
|
39
|
+
throw new Error('[createIdenticon] Invalid color format');
|
|
40
|
+
const [r, g, b] = match.slice(1).map((hex) => parseInt(hex, 16));
|
|
41
|
+
const primaryColor = [b, g, r];
|
|
42
|
+
const backgroundColor = [255, 255, 255];
|
|
43
|
+
// Draw the image
|
|
44
|
+
const hashBinary = hash
|
|
45
|
+
.split('')
|
|
46
|
+
.map((el) => parseInt(el, 16))
|
|
47
|
+
.map((num) => (num < 8 ? 0 : 1));
|
|
48
|
+
const hashBinaryMap = [];
|
|
49
|
+
const columns = Math.ceil(pixels / 2);
|
|
50
|
+
for (let x = 0; x < columns; x++) {
|
|
51
|
+
hashBinaryMap[x] = sliceWrap(hashBinary, x * pixels, (x + 1) * pixels);
|
|
52
|
+
}
|
|
53
|
+
let position = totalHeaderSize;
|
|
54
|
+
for (let y = pixels - 1; y >= 0; y--) {
|
|
55
|
+
for (let x = 0; x < pixels; x++) {
|
|
56
|
+
const color = hashBinaryMap[x > columns - 1 ? pixels - 1 - x : x]?.[y]
|
|
57
|
+
? primaryColor
|
|
58
|
+
: backgroundColor;
|
|
59
|
+
buffer[position++] = color[0];
|
|
60
|
+
buffer[position++] = color[1];
|
|
61
|
+
buffer[position++] = color[2];
|
|
62
|
+
}
|
|
63
|
+
position += rowPadding;
|
|
64
|
+
}
|
|
65
|
+
// Convert the image to a base64 string
|
|
66
|
+
let binary = '';
|
|
67
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
68
|
+
binary += String.fromCharCode(buffer[i]);
|
|
69
|
+
}
|
|
70
|
+
const identicon = `data:image/bmp;base64,${btoa(binary)}`;
|
|
71
|
+
// Store it in the cache, then return it
|
|
72
|
+
identiconCache.set(lowercasedAddress, identicon);
|
|
73
|
+
return identicon;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=createIdenticon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIdenticon.js","sourceR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CAAC,CAAA;YAC7B,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YAC7B,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QAC/B,CAAC;QACD,QAAQ,IAAI,UAAU,CAAA;IACxB,CAAC;IAED,uCAAuC;IACvC,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAA;IAC3C,CAAC;IACD,MAAM,SAAS,GAAG,yBAAyB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAA;IAEzD,wCAAwC;IACxC,cAAc,CAAC,GAAG,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAA;IAChD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type FormatAddressOptions = {
|
|
2
|
+
/** @default 'short' */
|
|
3
|
+
style?: 'short' | 'full' | undefined;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Formats an EVM wallet address as a string.
|
|
7
|
+
*
|
|
8
|
+
* @param address - The address to format.
|
|
9
|
+
* @param options - Formatting options.
|
|
10
|
+
* @returns The formatted address string.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatAddress(address: string, options?: FormatAddressOptions): string;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=formatAddress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatAddress.d.ts","sourceRoot":"","sources":["../src/formatAddress.ts"],"names":[],"mappings":"AAIA,KAAK,oBAAoB,GAAG;IAC1B,uBAAuB;IACvB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;CACrC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAgBzF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getAddress } from 'viem';
|
|
2
|
+
import { ZERO_ADDRESS } from './constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Formats an EVM wallet address as a string.
|
|
5
|
+
*
|
|
6
|
+
* @param address - The address to format.
|
|
7
|
+
* @param options - Formatting options.
|
|
8
|
+
* @returns The formatted address string.
|
|
9
|
+
*/
|
|
10
|
+
export function formatAddress(address, options = {}) {
|
|
11
|
+
const { style = 'short' } = options;
|
|
12
|
+
if (!address)
|
|
13
|
+
address = ZERO_ADDRESS;
|
|
14
|
+
try {
|
|
15
|
+
address = address.startsWith('0x') ? getAddress(address) : address;
|
|
16
|
+
}
|
|
17
|
+
catch { }
|
|
18
|
+
switch (style) {
|
|
19
|
+
case 'short':
|
|
20
|
+
const lengthOnEachSide = 6;
|
|
21
|
+
if (address.length <= lengthOnEachSide * 2 + 1)
|
|
22
|
+
return address;
|
|
23
|
+
return `${address.slice(0, lengthOnEachSide)}–${address.slice(-lengthOnEachSide)}`;
|
|
24
|
+
case 'full':
|
|
25
|
+
return address;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=formatAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatAddress.js","sourceRoot":"","sources":["../src/formatAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAO7C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,OAAO,GAAyB,EAAE;IAC/E,MAAM,EAAE,KAAK,GAAG,OAAO,EAAE,GAAG,OAAO,CAAA;IAEnC,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,YAAY,CAAA;IACpC,IAAI,CAAC;QACH,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IACpE,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,OAAO;YACV,MAAM,gBAAgB,GAAG,CAAC,CAAA;YAC1B,IAAI,OAAO,CAAC,MAAM,IAAI,gBAAgB,GAAG,CAAC,GAAG,CAAC;gBAAE,OAAO,OAAO,CAAA;YAC9D,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,EAAE,CAAA;QACpF,KAAK,MAAM;YACT,OAAO,OAAO,CAAA;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface BigIntFormatOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The number of digits starting from the right of `value` to consider as decimal places.
|
|
4
|
+
*
|
|
5
|
+
* @default 18n
|
|
6
|
+
*/
|
|
7
|
+
precision?: bigint | undefined;
|
|
8
|
+
/** @default 0 */
|
|
9
|
+
minimumFractionDigits?: number | undefined;
|
|
10
|
+
/** @default 20 */
|
|
11
|
+
maximumFractionDigits?: number | undefined;
|
|
12
|
+
/** @default 'auto' */
|
|
13
|
+
trailingZeroDisplay?: 'auto' | 'stripIfInteger' | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Formats a bigint as a string.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The bigint to format.
|
|
19
|
+
* @param options - Formatting options.
|
|
20
|
+
* @returns The string representation of `value`
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatBigInt(value: bigint, options?: BigIntFormatOptions): string;
|
|
23
|
+
//# sourceMappingURL=formatBigInt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatBigInt.d.ts","sourceRoot":"","sources":["../src/formatBigInt.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,iBAAiB;IACjB,qBAAqB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1C,kBAAkB;IAClB,qBAAqB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1C,sBAAsB;IACtB,mBAAmB,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAA;CAC5D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAqCjF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a bigint as a string.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The bigint to format.
|
|
5
|
+
* @param options - Formatting options.
|
|
6
|
+
* @returns The string representation of `value`
|
|
7
|
+
*/
|
|
8
|
+
export function formatBigInt(value, options) {
|
|
9
|
+
const { precision = 18n, minimumFractionDigits = 0, maximumFractionDigits = 20, trailingZeroDisplay = 'auto', } = options ?? {};
|
|
10
|
+
if (precision < 0n) {
|
|
11
|
+
throw new Error(`[formatBigInt] \`precision\` must be positive, got ${precision}`);
|
|
12
|
+
}
|
|
13
|
+
if (minimumFractionDigits > maximumFractionDigits) {
|
|
14
|
+
throw new Error(`[formatBigInt] \`minimumFractionDigits\` (${minimumFractionDigits}) cannot be greater than \`maximumFractionDigits\` (${maximumFractionDigits})`);
|
|
15
|
+
}
|
|
16
|
+
const isNegative = value < 0n;
|
|
17
|
+
const absValue = isNegative ? value * -1n : value;
|
|
18
|
+
const precisionFactor = 10n ** precision;
|
|
19
|
+
const integerPart = absValue / precisionFactor;
|
|
20
|
+
const integerPartString = `${isNegative ? '-' : ''}${integerPart.toLocaleString('en-US')}`;
|
|
21
|
+
const decimalPart = absValue % precisionFactor;
|
|
22
|
+
let decimalPartString = '';
|
|
23
|
+
if ((decimalPart > 0n || minimumFractionDigits > 0) && maximumFractionDigits > 0) {
|
|
24
|
+
decimalPartString = decimalPart
|
|
25
|
+
.toLocaleString('en-US', {
|
|
26
|
+
useGrouping: false,
|
|
27
|
+
})
|
|
28
|
+
.padStart(Number(precision), '0')
|
|
29
|
+
.replace(/0+$/, '')
|
|
30
|
+
.padEnd(minimumFractionDigits, '0')
|
|
31
|
+
.slice(0, maximumFractionDigits);
|
|
32
|
+
if (trailingZeroDisplay === 'stripIfInteger' && decimalPartString.replace(/0/g, '') === '') {
|
|
33
|
+
decimalPartString = '';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return `${integerPartString}${decimalPartString ? `.${decimalPartString}` : ''}`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=formatBigInt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatBigInt.js","sourceRoot":"","sources":["../src/formatBigInt.ts"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,OAA6B;IACvE,MAAM,EACJ,SAAS,GAAG,GAAG,EACf,qBAAqB,GAAG,CAAC,EACzB,qBAAqB,GAAG,EAAE,EAC1B,mBAAmB,GAAG,MAAM,GAC7B,GAAG,OAAO,IAAI,EAAE,CAAA;IAEjB,IAAI,SAAS,GAAG,EAAE,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,sDAAsD,SAAS,EAAE,CAAC,CAAA;IACpF,CAAC;IACD,IAAI,qBAAqB,GAAG,qBAAqB,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,6CAA6C,qBAAqB,uDAAuD,qBAAqB,GAAG,CAClJ,CAAA;IACH,CAAC;IACD,MAAM,UAAU,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|
2
|
+
* Generates a stable, unique string key for any JS value.
|
|
3
|
+
*
|
|
4
|
+
* - null / undefined => 'null' / 'undefined'
|
|
5
|
+
* - string / number / boolean => `${type}:${value}` (e.g. 'string:hello', 'number:42',
|
|
6
|
+
* 'boolean:false')
|
|
7
|
+
* - registered symbols (`Symbol.for('foo')`) => 'symbol:foo'
|
|
8
|
+
* - objects / functions / non-registered symbols => one-time ID (e.g. 'ref:1', 'ref:2', etc.)
|
|
9
|
+
*
|
|
10
|
+
* @param value - Any JavaScript value.
|
|
11
|
+
* @returns A string that uniquely and consistently identifies the value.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getKey(value: unknown): string;
|
|
14
|
+
//# sourceMappingURL=getKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKey.d.ts","sourceRoot":"","sources":["../src/getKey.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAqB7C"}
|
package/dist/getKey.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const refMap = new WeakMap();
|
|
2
|
+
let refCounter = 0;
|
|
3
|
+
/**
|
|
4
|
+
* Generates a stable, unique string key for any JS value.
|
|
5
|
+
*
|
|
6
|
+
* - null / undefined => 'null' / 'undefined'
|
|
7
|
+
* - string / number / boolean => `${type}:${value}` (e.g. 'string:hello', 'number:42',
|
|
8
|
+
* 'boolean:false')
|
|
9
|
+
* - registered symbols (`Symbol.for('foo')`) => 'symbol:foo'
|
|
10
|
+
* - objects / functions / non-registered symbols => one-time ID (e.g. 'ref:1', 'ref:2', etc.)
|
|
11
|
+
*
|
|
12
|
+
* @param value - Any JavaScript value.
|
|
13
|
+
* @returns A string that uniquely and consistently identifies the value.
|
|
14
|
+
*/
|
|
15
|
+
export function getKey(value) {
|
|
16
|
+
if (value === null)
|
|
17
|
+
return 'null';
|
|
18
|
+
if (value === undefined)
|
|
19
|
+
return 'undefined';
|
|
20
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
21
|
+
return `${typeof value}:${value}`;
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === 'symbol') {
|
|
24
|
+
const registryKey = Symbol.keyFor(value);
|
|
25
|
+
if (registryKey !== undefined) {
|
|
26
|
+
return `symbol:${registryKey}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
let id = refMap.get(value);
|
|
30
|
+
if (!id) {
|
|
31
|
+
id = `ref:${++refCounter}`;
|
|
32
|
+
refMap.set(value, id);
|
|
33
|
+
}
|
|
34
|
+
return id;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=getKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKey.js","sourceRoot":"","sources":["../src/getKey.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAkB,CAAA;AAC5C,IAAI,UAAU,GAAG,CAAC,CAAA;AAElB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAA;IACjC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,WAAW,CAAA;IAE3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACzF,OAAO,GAAG,OAAO,KAAK,IAAI,KAAK,EAAE,CAAA;IACnC,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACxC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,UAAU,WAAW,EAAE,CAAA;QAChC,CAAC;IACH,CAAC;IAED,IAAI,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,CAAA;QAC1B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACvB,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './constants.ts';
|
|
2
|
+
export * from './types.ts';
|
|
3
|
+
export { bigIntToNumber, type BigIntToNumberOptions } from './bigIntToNumber.ts';
|
|
4
|
+
export { camelToKebab } from './camelToKebab.ts';
|
|
5
|
+
export { createIdenticon } from './createIdenticon.ts';
|
|
6
|
+
export { formatAddress } from './formatAddress.ts';
|
|
7
|
+
export { formatBigInt, type BigIntFormatOptions } from './formatBigInt.ts';
|
|
8
|
+
export { getKey } from './getKey.ts';
|
|
9
|
+
export { loremIpsum } from './loremIpsum.ts';
|
|
10
|
+
export { numberToBigInt, type NumberToBigIntOptions } from './numberToBigInt.ts';
|
|
11
|
+
export { parseBigInt, type ParseBigIntOptions } from './parseBigInt.ts';
|
|
12
|
+
export { parseNumber, type ParseNumberOptions } from './parseNumber.ts';
|
|
13
|
+
export { sliceWrap } from './sliceWrap.ts';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export { bigIntToNumber } from './bigIntToNumber.js';
|
|
4
|
+
export { camelToKebab } from './camelToKebab.js';
|
|
5
|
+
export { createIdenticon } from './createIdenticon.js';
|
|
6
|
+
export { formatAddress } from './formatAddress.js';
|
|
7
|
+
export { formatBigInt } from './formatBigInt.js';
|
|
8
|
+
export { getKey } from './getKey.js';
|
|
9
|
+
export { loremIpsum } from './loremIpsum.js';
|
|
10
|
+
export { numberToBigInt } from './numberToBigInt.js';
|
|
11
|
+
export { parseBigInt } from './parseBigInt.js';
|
|
12
|
+
export { parseNumber } from './parseNumber.js';
|
|
13
|
+
export { sliceWrap } from './sliceWrap.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,cAAc,EAA8B,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAA4B,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAA8B,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,WAAW,EAA2B,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,WAAW,EAA2B,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates lorem ipsum text.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} [count=4] - The number of words, sentences, or paragraphs to generate. Default is
|
|
5
|
+
* `4`
|
|
6
|
+
* @param {'words' | 'sentences' | 'paragraphs'} [units='sentences'] - The units to generate.
|
|
7
|
+
* Default is `'sentences'`
|
|
8
|
+
* @returns {string} The generated text.
|
|
9
|
+
*/
|
|
10
|
+
export declare function loremIpsum(count?: number, units?: 'words' | 'sentences' | 'paragraphs'): string;
|
|
11
|
+
//# sourceMappingURL=loremIpsum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loremIpsum.d.ts","sourceRoot":"","sources":["../src/loremIpsum.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,KAAK,GAAE,MAAU,EACjB,KAAK,GAAE,OAAO,GAAG,WAAW,GAAG,YAA0B,GACxD,MAAM,CAeR"}
|