@autonomys/auto-utils 0.6.4 → 0.6.6

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/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './network';
6
6
  export * from './number';
7
7
  export * from './read';
8
8
  export * from './save';
9
+ export * from './string';
9
10
  export * from './wallet';
10
11
  export * from './constants';
11
12
  export * from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AAExB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AAExB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./network"), exports);
23
23
  __exportStar(require("./number"), exports);
24
24
  __exportStar(require("./read"), exports);
25
25
  __exportStar(require("./save"), exports);
26
+ __exportStar(require("./string"), exports);
26
27
  __exportStar(require("./wallet"), exports);
27
28
  __exportStar(require("./constants"), exports);
28
29
  __exportStar(require("./types"), exports);
@@ -0,0 +1,5 @@
1
+ export declare const stringify: (value: any) => string;
2
+ export declare const shortString: (value: string, initialLength?: number, endLength?: number) => string;
3
+ export declare const capitalizeFirstLetter: (string: string) => string;
4
+ export declare const fixLengthEntryId: (blockHeight: bigint, indexInBlock?: bigint) => string;
5
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,UAAW,GAAG,WACyD,CAAA;AAE7F,eAAO,MAAM,WAAW,UAAW,MAAM,iDAAsC,MACf,CAAA;AAEhE,eAAO,MAAM,qBAAqB,WAAY,MAAM,WACY,CAAA;AAEhE,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,iBAAiB,MAAM,KAAG,MAQ7E,CAAA"}
package/dist/string.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // file: src/string.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.fixLengthEntryId = exports.capitalizeFirstLetter = exports.shortString = exports.stringify = void 0;
5
+ const stringify = (value) => JSON.stringify(value, (_, value) => (typeof value === 'bigint' ? value.toString() : value));
6
+ exports.stringify = stringify;
7
+ const shortString = (value, initialLength = 6, endLength = -4) => `${value.slice(0, initialLength)}...${value.slice(endLength)}`;
8
+ exports.shortString = shortString;
9
+ const capitalizeFirstLetter = (string) => string ? string.charAt(0).toUpperCase() + string.slice(1) : '';
10
+ exports.capitalizeFirstLetter = capitalizeFirstLetter;
11
+ const fixLengthEntryId = (blockHeight, indexInBlock) => {
12
+ const totalLength = 32;
13
+ const str1 = blockHeight.toString().padStart(totalLength, '0');
14
+ if (indexInBlock === undefined)
15
+ return str1;
16
+ const str2 = indexInBlock.toString().padStart(totalLength, '0');
17
+ return `${str1}-${str2}`;
18
+ };
19
+ exports.fixLengthEntryId = fixLengthEntryId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autonomys/auto-utils",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -38,5 +38,5 @@
38
38
  "browser": {
39
39
  "fs": false
40
40
  },
41
- "gitHead": "cbeaa151644f75d43e7e36b5a817d580bff09ebd"
41
+ "gitHead": "94646ea042d018cd883558fb6ca750ed49d95dae"
42
42
  }