@injectivelabs/utils 1.14.16-beta.0 → 1.14.16
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/dist/cjs/formatters.d.ts +2 -0
- package/dist/cjs/formatters.d.ts.map +1 -1
- package/dist/cjs/formatters.js +20 -1
- package/dist/cjs/formatters.js.map +1 -1
- package/dist/esm/formatters.d.ts +2 -0
- package/dist/esm/formatters.d.ts.map +1 -1
- package/dist/esm/formatters.js +17 -0
- package/dist/esm/formatters.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/formatters.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { AccountAddress } from '@injectivelabs/ts-types';
|
|
2
2
|
export declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string;
|
|
3
|
+
export declare const toPascalCase: (str: string) => string;
|
|
4
|
+
export declare const snakeToPascal: (str: string) => string;
|
|
3
5
|
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,eAAO,MAAM,mBAAmB,YACrB,cAAc,4BAEtB,MASF,CAAA"}
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,eAAO,MAAM,mBAAmB,YACrB,cAAc,4BAEtB,MASF,CAAA;AAED,eAAO,MAAM,YAAY,QAAS,MAAM,KAAG,MAU1C,CAAA;AAED,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,MAU3C,CAAA"}
|
package/dist/cjs/formatters.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatWalletAddress = void 0;
|
|
3
|
+
exports.snakeToPascal = exports.toPascalCase = exports.formatWalletAddress = void 0;
|
|
4
4
|
const formatWalletAddress = (address, substrLength = 6) => {
|
|
5
5
|
if (address.length <= 10) {
|
|
6
6
|
return address;
|
|
@@ -8,4 +8,23 @@ const formatWalletAddress = (address, substrLength = 6) => {
|
|
|
8
8
|
return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`;
|
|
9
9
|
};
|
|
10
10
|
exports.formatWalletAddress = formatWalletAddress;
|
|
11
|
+
const toPascalCase = (str) => {
|
|
12
|
+
return `${str}`
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.replace(new RegExp(/[-_]+/, 'g'), ' ')
|
|
15
|
+
.replace(new RegExp(/[^\w\s]/, 'g'), '')
|
|
16
|
+
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`)
|
|
17
|
+
.replace(new RegExp(/\w/), (s) => s.toUpperCase());
|
|
18
|
+
};
|
|
19
|
+
exports.toPascalCase = toPascalCase;
|
|
20
|
+
const snakeToPascal = (str) => {
|
|
21
|
+
return str
|
|
22
|
+
.split('/')
|
|
23
|
+
.map((snake) => snake
|
|
24
|
+
.split('_')
|
|
25
|
+
.map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1))
|
|
26
|
+
.join(''))
|
|
27
|
+
.join('/');
|
|
28
|
+
};
|
|
29
|
+
exports.snakeToPascal = snakeToPascal;
|
|
11
30
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/formatters.ts"],"names":[],"mappings":";;;AAEO,MAAM,mBAAmB,GAAG,CACjC,OAAuB,EACvB,YAAY,GAAG,CAAC,EACR,EAAE;IACV,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QACzB,OAAO,OAAO,CAAA;IAChB,CA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AAA;AAVY,QAAA,YAAY,gBAUxB;AAEM,MAAM,aAAa,GAAG,CAAC,GAAW,EAAU,EAAE;IACnD,OAAO,GAAG;SACP,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACb,KAAK;SACF,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACjE,IAAI,CAAC,EAAE,CAAC,CACZ;SACA,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC,CAAA;AAVY,QAAA,aAAa,iBAUzB"}
|
package/dist/esm/formatters.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { AccountAddress } from '@injectivelabs/ts-types';
|
|
2
2
|
export declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string;
|
|
3
|
+
export declare const toPascalCase: (str: string) => string;
|
|
4
|
+
export declare const snakeToPascal: (str: string) => string;
|
|
3
5
|
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,eAAO,MAAM,mBAAmB,YACrB,cAAc,4BAEtB,MASF,CAAA"}
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,eAAO,MAAM,mBAAmB,YACrB,cAAc,4BAEtB,MASF,CAAA;AAED,eAAO,MAAM,YAAY,QAAS,MAAM,KAAG,MAU1C,CAAA;AAED,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,MAU3C,CAAA"}
|
package/dist/esm/formatters.js
CHANGED
|
@@ -4,4 +4,21 @@ export const formatWalletAddress = (address, substrLength = 6) => {
|
|
|
4
4
|
}
|
|
5
5
|
return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`;
|
|
6
6
|
};
|
|
7
|
+
export const toPascalCase = (str) => {
|
|
8
|
+
return `${str}`
|
|
9
|
+
.toLowerCase()
|
|
10
|
+
.replace(new RegExp(/[-_]+/, 'g'), ' ')
|
|
11
|
+
.replace(new RegExp(/[^\w\s]/, 'g'), '')
|
|
12
|
+
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`)
|
|
13
|
+
.replace(new RegExp(/\w/), (s) => s.toUpperCase());
|
|
14
|
+
};
|
|
15
|
+
export const snakeToPascal = (str) => {
|
|
16
|
+
return str
|
|
17
|
+
.split('/')
|
|
18
|
+
.map((snake) => snake
|
|
19
|
+
.split('_')
|
|
20
|
+
.map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1))
|
|
21
|
+
.join(''))
|
|
22
|
+
.join('/');
|
|
23
|
+
};
|
|
7
24
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/formatters.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAAuB,EACvB,YAAY,GAAG,CAAC,EACR,EAAE;IACV,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QACzB,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,MAAM,OAAO,CAAC,KAAK,CACzD,OAAO,CAAC,MAAM,GAAG,YAAY,EAC7B,OAAO,CAAC,MAAM,CACf,EAAE,CAAA;AACL,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"formatters.js","sour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,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACjE,IAAI,CAAC,EAAE,CAAC,CACZ;SACA,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/utils",
|
|
3
3
|
"description": "List of utils and helper functions that can be reused throughout Injective's projects.",
|
|
4
|
-
"version": "1.14.16
|
|
4
|
+
"version": "1.14.16",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "InjectiveLabs",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"start": "node dist/index.js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@injectivelabs/exceptions": "^1.14.16
|
|
35
|
-
"@injectivelabs/ts-types": "^1.14.16
|
|
34
|
+
"@injectivelabs/exceptions": "^1.14.16",
|
|
35
|
+
"@injectivelabs/ts-types": "^1.14.16",
|
|
36
36
|
"axios": "^1.6.4",
|
|
37
37
|
"bignumber.js": "^9.0.1",
|
|
38
38
|
"http-status-codes": "^2.2.0",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"snakecase-keys": "^5.1.2",
|
|
41
41
|
"store2": "^2.12.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "d36e6b972a245f8288032f26cf717d7bb0bfc60d"
|
|
44
44
|
}
|