sushi 6.1.7 → 6.1.9

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.
Files changed (37) hide show
  1. package/_cjs/generic/format/index.js +1 -0
  2. package/_cjs/generic/format/index.js.map +1 -1
  3. package/_cjs/generic/format/string.js +17 -0
  4. package/_cjs/generic/format/string.js.map +1 -0
  5. package/_cjs/kvm/format/index.js +18 -0
  6. package/_cjs/kvm/format/index.js.map +1 -0
  7. package/_cjs/kvm/format/pact-decimal.js +10 -0
  8. package/_cjs/kvm/format/pact-decimal.js.map +1 -0
  9. package/_cjs/kvm/index.js +1 -0
  10. package/_cjs/kvm/index.js.map +1 -1
  11. package/_esm/generic/format/index.js +1 -0
  12. package/_esm/generic/format/index.js.map +1 -1
  13. package/_esm/generic/format/string.js +14 -0
  14. package/_esm/generic/format/string.js.map +1 -0
  15. package/_esm/kvm/format/index.js +2 -0
  16. package/_esm/kvm/format/index.js.map +1 -0
  17. package/_esm/kvm/format/pact-decimal.js +6 -0
  18. package/_esm/kvm/format/pact-decimal.js.map +1 -0
  19. package/_esm/kvm/index.js +1 -0
  20. package/_esm/kvm/index.js.map +1 -1
  21. package/_types/generic/format/index.d.ts +1 -0
  22. package/_types/generic/format/index.d.ts.map +1 -1
  23. package/_types/generic/format/string.d.ts +2 -0
  24. package/_types/generic/format/string.d.ts.map +1 -0
  25. package/_types/kvm/format/index.d.ts +2 -0
  26. package/_types/kvm/format/index.d.ts.map +1 -0
  27. package/_types/kvm/format/pact-decimal.d.ts +2 -0
  28. package/_types/kvm/format/pact-decimal.d.ts.map +1 -0
  29. package/_types/kvm/index.d.ts +1 -0
  30. package/_types/kvm/index.d.ts.map +1 -1
  31. package/generic/format/index.ts +1 -0
  32. package/generic/format/string.test.ts +24 -0
  33. package/generic/format/string.ts +18 -0
  34. package/kvm/format/index.ts +1 -0
  35. package/kvm/format/pact-decimal.ts +6 -0
  36. package/kvm/index.ts +1 -0
  37. package/package.json +1 -1
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./number.js"), exports);
18
18
  __exportStar(require("./percent.js"), exports);
19
19
  __exportStar(require("./price.js"), exports);
20
+ __exportStar(require("./string.js"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../generic/format/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,+CAA4B;AAC5B,6CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../generic/format/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,+CAA4B;AAC5B,6CAA0B;AAC1B,8CAA2B"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.truncateString = truncateString;
4
+ function truncateString(str, maxLength, type) {
5
+ if (str.length <= maxLength) {
6
+ return str;
7
+ }
8
+ switch (type) {
9
+ case 'middle': {
10
+ const half = Math.floor(maxLength / 2);
11
+ return `${str.slice(0, half)}...${str.slice(str.length - half)}`;
12
+ }
13
+ case 'end':
14
+ return `${str.slice(0, maxLength)}...`;
15
+ }
16
+ }
17
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../generic/format/string.ts"],"names":[],"mappings":";;AAAA,wCAiBC;AAjBD,SAAgB,cAAc,CAC5B,GAAW,EACX,SAAiB,EACjB,IAAsB;IAEtB,IAAI,GAAG,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;YACtC,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;QAClE,CAAC;QACD,KAAK,KAAK;YACR,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAA;IAC1C,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./pact-decimal.js"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../kvm/format/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatPactDecimal = void 0;
4
+ const decimal_js_light_1 = require("decimal.js-light");
5
+ const formatPactDecimal = (value) => {
6
+ const dec = new decimal_js_light_1.Decimal(value);
7
+ return dec.toFixed(dec.dp() > 0 ? dec.dp() : 1);
8
+ };
9
+ exports.formatPactDecimal = formatPactDecimal;
10
+ //# sourceMappingURL=pact-decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pact-decimal.js","sourceRoot":"","sources":["../../../kvm/format/pact-decimal.ts"],"names":[],"mappings":";;;AAAA,uDAA0C;AAEnC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAU,EAAE;IACzD,MAAM,GAAG,GAAG,IAAI,0BAAO,CAAC,KAAK,CAAC,CAAA;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACjD,CAAC,CAAA;AAHY,QAAA,iBAAiB,qBAG7B"}
package/_cjs/kvm/index.js CHANGED
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./chain/index.js"), exports);
18
18
  __exportStar(require("./currency/index.js"), exports);
19
+ __exportStar(require("./format/index.js"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../kvm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,sDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../kvm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,sDAAmC;AACnC,oDAAiC"}
@@ -1,4 +1,5 @@
1
1
  export * from './number.js';
2
2
  export * from './percent.js';
3
3
  export * from './price.js';
4
+ export * from './string.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../generic/format/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../generic/format/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,14 @@
1
+ export function truncateString(str, maxLength, type) {
2
+ if (str.length <= maxLength) {
3
+ return str;
4
+ }
5
+ switch (type) {
6
+ case 'middle': {
7
+ const half = Math.floor(maxLength / 2);
8
+ return `${str.slice(0, half)}...${str.slice(str.length - half)}`;
9
+ }
10
+ case 'end':
11
+ return `${str.slice(0, maxLength)}...`;
12
+ }
13
+ }
14
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../generic/format/string.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,SAAiB,EACjB,IAAsB;IAEtB,IAAI,GAAG,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;YACtC,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;QAClE,CAAC;QACD,KAAK,KAAK;YACR,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAA;IAC1C,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './pact-decimal.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../kvm/format/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { Decimal } from 'decimal.js-light';
2
+ export const formatPactDecimal = (value) => {
3
+ const dec = new Decimal(value);
4
+ return dec.toFixed(dec.dp() > 0 ? dec.dp() : 1);
5
+ };
6
+ //# sourceMappingURL=pact-decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pact-decimal.js","sourceRoot":"","sources":["../../../kvm/format/pact-decimal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAU,EAAE;IACzD,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAA;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACjD,CAAC,CAAA"}
package/_esm/kvm/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './chain/index.js';
2
2
  export * from './currency/index.js';
3
+ export * from './format/index.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../kvm/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../kvm/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from './number.js';
2
2
  export * from './percent.js';
3
3
  export * from './price.js';
4
+ export * from './string.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../generic/format/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../generic/format/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function truncateString(str: string, maxLength: number, type: 'end' | 'middle'): string;
2
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../generic/format/string.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,KAAK,GAAG,QAAQ,GACrB,MAAM,CAaR"}
@@ -0,0 +1,2 @@
1
+ export * from './pact-decimal.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../kvm/format/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const formatPactDecimal: (value: number) => string;
2
+ //# sourceMappingURL=pact-decimal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pact-decimal.d.ts","sourceRoot":"","sources":["../../../kvm/format/pact-decimal.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,MAGjD,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export * from './chain/index.js';
2
2
  export * from './currency/index.js';
3
+ export * from './format/index.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../kvm/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../kvm/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export * from './number.js'
2
2
  export * from './percent.js'
3
3
  export * from './price.js'
4
+ export * from './string.js'
@@ -0,0 +1,24 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { truncateString } from './string.js'
3
+
4
+ describe('truncateString', () => {
5
+ it('returns the original string when length is within the limit', () => {
6
+ expect(truncateString('Sushi', 10, 'end')).toBe('Sushi')
7
+ expect(truncateString('Roll', 4, 'middle')).toBe('Roll')
8
+ })
9
+
10
+ it('truncates from the end when type is end', () => {
11
+ expect(truncateString('SushiSwap', 5, 'end')).toBe('Sushi...')
12
+ expect(truncateString('Tempura', 0, 'end')).toBe('...')
13
+ })
14
+
15
+ it('truncates from the middle when type is middle', () => {
16
+ expect(truncateString('SushiSwap', 4, 'middle')).toBe('Su...ap')
17
+ expect(truncateString('abcdefghij', 6, 'middle')).toBe('abc...hij')
18
+ })
19
+
20
+ it('uses the floor of half the max length for middle truncation', () => {
21
+ expect(truncateString('abcdefghij', 5, 'middle')).toBe('ab...ij')
22
+ expect(truncateString('abcdefghij', 3, 'middle')).toBe('a...j')
23
+ })
24
+ })
@@ -0,0 +1,18 @@
1
+ export function truncateString(
2
+ str: string,
3
+ maxLength: number,
4
+ type: 'end' | 'middle',
5
+ ): string {
6
+ if (str.length <= maxLength) {
7
+ return str
8
+ }
9
+
10
+ switch (type) {
11
+ case 'middle': {
12
+ const half = Math.floor(maxLength / 2)
13
+ return `${str.slice(0, half)}...${str.slice(str.length - half)}`
14
+ }
15
+ case 'end':
16
+ return `${str.slice(0, maxLength)}...`
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export * from './pact-decimal.js'
@@ -0,0 +1,6 @@
1
+ import { Decimal } from 'decimal.js-light'
2
+
3
+ export const formatPactDecimal = (value: number): string => {
4
+ const dec = new Decimal(value)
5
+ return dec.toFixed(dec.dp() > 0 ? dec.dp() : 1)
6
+ }
package/kvm/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './chain/index.js'
2
2
  export * from './currency/index.js'
3
+ export * from './format/index.js'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sushi",
3
3
  "description": "Sushi",
4
- "version": "6.1.7",
4
+ "version": "6.1.9",
5
5
  "type": "module",
6
6
  "main": "./_cjs/generic/index.js",
7
7
  "module": "./_esm/generic/index.js",