@injectivelabs/utils 1.14.15 → 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 +6 -8
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,CAAC;IA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AVY,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","sourceRoot":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,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.
|
|
4
|
+
"version": "1.14.16",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "InjectiveLabs",
|
|
@@ -18,9 +18,8 @@
|
|
|
18
18
|
"~utils": "dist"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"
|
|
22
|
-
"build": "tsc --build
|
|
23
|
-
"build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && yarn build:post && link-module-alias",
|
|
21
|
+
"build": "tsc --build --force tsconfig.build.json && tsc --build --force tsconfig.build.esm.json && yarn build:post",
|
|
22
|
+
"build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && yarn build:post",
|
|
24
23
|
"build:post": "shx cp ../../etc/stub/package.json.stub dist/cjs/package.json && shx cp ../../etc/stub/package.esm.json.stub dist/esm/package.json",
|
|
25
24
|
"clean": "tsc --build tsconfig.build.json --clean && tsc --build tsconfig.build.esm.json --clean && shx rm -rf coverage *.log junit.xml dist && jest --clearCache && shx mkdir -p dist",
|
|
26
25
|
"test": "jest",
|
|
@@ -32,15 +31,14 @@
|
|
|
32
31
|
"start": "node dist/index.js"
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"@injectivelabs/exceptions": "^1.14.
|
|
36
|
-
"@injectivelabs/ts-types": "^1.14.
|
|
34
|
+
"@injectivelabs/exceptions": "^1.14.16",
|
|
35
|
+
"@injectivelabs/ts-types": "^1.14.16",
|
|
37
36
|
"axios": "^1.6.4",
|
|
38
37
|
"bignumber.js": "^9.0.1",
|
|
39
38
|
"http-status-codes": "^2.2.0",
|
|
40
|
-
"link-module-alias": "^1.2.0",
|
|
41
39
|
"shx": "^0.3.2",
|
|
42
40
|
"snakecase-keys": "^5.1.2",
|
|
43
41
|
"store2": "^2.12.0"
|
|
44
42
|
},
|
|
45
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "d36e6b972a245f8288032f26cf717d7bb0bfc60d"
|
|
46
44
|
}
|