@naturalcycles/js-lib 15.18.0 → 15.19.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.
@@ -1,6 +1,7 @@
1
1
  import { _isBackendErrorResponseObject, _isErrorLike, _isErrorObject } from '../error/error.util.js';
2
2
  import { _jsonParseIfPossible } from './json.util.js';
3
3
  import { _safeJsonStringify } from './safeJsonStringify.js';
4
+ import { _truncateMiddle } from './string.util.js';
4
5
  const supportsAggregateError = typeof globalThis.AggregateError === 'function';
5
6
  let globalStringifyFunction = _safeJsonStringify;
6
7
  /**
@@ -127,7 +128,7 @@ export function _stringify(obj, opt = {}) {
127
128
  // Handle maxLen
128
129
  const { maxLen = 10_000 } = opt;
129
130
  if (maxLen && s.length > maxLen) {
130
- s = s.slice(0, maxLen) + `... ${Math.ceil(s.length / 1024)} KB message truncated`;
131
+ return _truncateMiddle(s, maxLen, `\n... ${Math.ceil(s.length / 1024)} Kb message truncated ...\n`);
131
132
  }
132
133
  return s;
133
134
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.18.0",
4
+ "version": "15.19.0",
5
5
  "dependencies": {
6
6
  "tslib": "^2",
7
7
  "zod": "^4"
@@ -12,7 +12,7 @@
12
12
  "@types/semver": "^7",
13
13
  "crypto-js": "^4",
14
14
  "dayjs": "^1",
15
- "@naturalcycles/dev-lib": "19.11.0"
15
+ "@naturalcycles/dev-lib": "18.4.2"
16
16
  },
17
17
  "exports": {
18
18
  ".": "./dist/index.js",
@@ -2,6 +2,7 @@ import { _isBackendErrorResponseObject, _isErrorLike, _isErrorObject } from '../
2
2
  import type { Reviver } from '../types.js'
3
3
  import { _jsonParseIfPossible } from './json.util.js'
4
4
  import { _safeJsonStringify } from './safeJsonStringify.js'
5
+ import { _truncateMiddle } from './string.util.js'
5
6
 
6
7
  const supportsAggregateError = typeof globalThis.AggregateError === 'function'
7
8
 
@@ -179,7 +180,7 @@ export function _stringify(obj: any, opt: StringifyOptions = {}): string {
179
180
  // Handle maxLen
180
181
  const { maxLen = 10_000 } = opt
181
182
  if (maxLen && s.length > maxLen) {
182
- s = s.slice(0, maxLen) + `... ${Math.ceil(s.length / 1024)} KB message truncated`
183
+ return _truncateMiddle(s, maxLen, `\n... ${Math.ceil(s.length / 1024)} Kb message truncated ...\n`)
183
184
  }
184
185
 
185
186
  return s