@lad-tech/nsc-toolkit 1.17.5 → 1.18.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# [1.18.0](https://github.com/lad-tech/nsc-toolkit/compare/v1.17.6...v1.18.0) (2024-02-26)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* Сделать передачу logger в BufferToJsonTransform.ts опциональной ([#98](https://github.com/lad-tech/nsc-toolkit/issues/98)) ([01b0686](https://github.com/lad-tech/nsc-toolkit/commit/01b0686d44ec9a636244810b95712062b6fc2049))
|
package/dist/Root.js
CHANGED
|
@@ -43,7 +43,11 @@ class Root {
|
|
|
43
43
|
try {
|
|
44
44
|
if (!expired) {
|
|
45
45
|
const timeout = ownTimeout || this.castToNumber(this.getSettingFromEnv('DEFAULT_REPONSE_TIMEOUT'));
|
|
46
|
-
return Date.now() + timeout
|
|
46
|
+
return Date.now() + timeout;
|
|
47
|
+
}
|
|
48
|
+
if (ownTimeout) {
|
|
49
|
+
const customExpired = Date.now() + ownTimeout;
|
|
50
|
+
return Math.min(customExpired, expired);
|
|
47
51
|
}
|
|
48
52
|
return expired;
|
|
49
53
|
}
|
|
@@ -9,6 +9,7 @@ class BufferToJsonTransform extends stream_1.Transform {
|
|
|
9
9
|
this.logger = options.logger;
|
|
10
10
|
}
|
|
11
11
|
async _transform(tail, _, cb) {
|
|
12
|
+
var _a;
|
|
12
13
|
try {
|
|
13
14
|
tail = Buffer.concat([this.head, Buffer.from(tail)]);
|
|
14
15
|
const jsonData = JSON.parse(tail.toString());
|
|
@@ -18,7 +19,7 @@ class BufferToJsonTransform extends stream_1.Transform {
|
|
|
18
19
|
catch (error) {
|
|
19
20
|
if (error instanceof SyntaxError) {
|
|
20
21
|
this.head = Buffer.from(tail);
|
|
21
|
-
this.logger.error(BufferToJsonTransform.errors.CONVERSION_ERROR, tail.toString());
|
|
22
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(BufferToJsonTransform.errors.CONVERSION_ERROR, tail.toString());
|
|
22
23
|
cb();
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
@@ -5,9 +5,9 @@ import { Transform, TransformCallback, TransformOptions } from 'stream';
|
|
|
5
5
|
export declare class BufferToJsonTransform<T = any> extends Transform {
|
|
6
6
|
private head;
|
|
7
7
|
private static errors;
|
|
8
|
-
private logger
|
|
8
|
+
private logger?;
|
|
9
9
|
constructor(options: TransformOptions & {
|
|
10
|
-
logger
|
|
10
|
+
logger?: Logs.Logger;
|
|
11
11
|
});
|
|
12
12
|
_transform(tail: Buffer, _: BufferEncoding, cb: TransformCallback): Promise<void>;
|
|
13
13
|
}
|