@rsdk/common.node 4.1.0 → 4.2.0-next.1

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
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.2.0-next.1](https://github.com/R-Vision/rsdk/compare/v4.2.0-next.0...v4.2.0-next.1) (2024-02-02)
7
+
8
+ ### Features
9
+
10
+ * rework work with async context ([#201](https://github.com/R-Vision/rsdk/issues/201)) ([26de1a8](https://github.com/R-Vision/rsdk/commit/26de1a814692bcd082c2f1aaedad1215ec0df1a0))
11
+
12
+ ## [4.2.0-next.0](https://github.com/R-Vision/rsdk/compare/v4.1.0...v4.2.0-next.0) (2024-02-02)
13
+
14
+ ### Features
15
+
16
+ * **s3:** added @rsdk/s3 package ([03bd9ea](https://github.com/R-Vision/rsdk/commit/03bd9ea7e5f78be6c93b1a2547fe7c2639ca0146))
17
+
6
18
  ## [4.1.0](https://github.com/R-Vision/rsdk/compare/v4.1.0-next.1...v4.1.0) (2024-01-24)
7
19
 
8
20
  **Note:** Version bump only for package @rsdk/common.node
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { omitUndefined } from './object';
1
2
  export { Concurrency } from './concurrency.decorator';
2
3
  export { Deferred } from './deferred';
3
4
  export { MaybeReadonlyArray } from './types';
package/dist/index.js CHANGED
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Deferred = exports.Concurrency = void 0;
17
+ exports.Deferred = exports.Concurrency = exports.omitUndefined = void 0;
18
+ var object_1 = require("./object");
19
+ Object.defineProperty(exports, "omitUndefined", { enumerable: true, get: function () { return object_1.omitUndefined; } });
18
20
  var concurrency_decorator_1 = require("./concurrency.decorator");
19
21
  Object.defineProperty(exports, "Concurrency", { enumerable: true, get: function () { return concurrency_decorator_1.Concurrency; } });
20
22
  var deferred_1 = require("./deferred");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iEAAsD;AAA7C,oHAAA,WAAW,OAAA;AAEpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAIjB,yCAAuB;AACvB,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AAEtB,iEAAsD;AAA7C,oHAAA,WAAW,OAAA;AAEpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAIjB,yCAAuB;AACvB,kDAAgC"}
package/dist/misc.d.ts CHANGED
@@ -1,8 +1,15 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
3
4
  import type { PathLike } from 'node:fs';
4
5
  import type { Readable } from 'node:stream';
5
6
  /**
6
7
  * Writes contents of readable stream to file
7
8
  */
8
9
  export declare const streamWriteFile: (stream: Readable, path: PathLike) => Promise<void>;
10
+ /**
11
+ * Reads stream to Node.js Buffer chunk by chunk
12
+ * @param stream Readable stream
13
+ * @returns Promise<Buffer>
14
+ */
15
+ export declare const streamToBuffer: (stream: Readable) => Promise<Buffer>;
package/dist/misc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.streamWriteFile = void 0;
3
+ exports.streamToBuffer = exports.streamWriteFile = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
5
  /**
6
6
  * Writes contents of readable stream to file
@@ -13,4 +13,17 @@ const streamWriteFile = (stream, path) => {
13
13
  });
14
14
  };
15
15
  exports.streamWriteFile = streamWriteFile;
16
+ /**
17
+ * Reads stream to Node.js Buffer chunk by chunk
18
+ * @param stream Readable stream
19
+ * @returns Promise<Buffer>
20
+ */
21
+ const streamToBuffer = async (stream) => {
22
+ const chunks = [];
23
+ for await (const chunk of stream) {
24
+ chunks.push(Buffer.from(chunk));
25
+ }
26
+ return Buffer.concat(chunks);
27
+ };
28
+ exports.streamToBuffer = streamToBuffer;
16
29
  //# sourceMappingURL=misc.js.map
package/dist/misc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"misc.js","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":";;;AACA,qCAA4C;AAG5C;;GAEG;AACI,MAAM,eAAe,GAAG,CAC7B,MAAgB,EAChB,IAAc,EACC,EAAE;IACjB,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,CAAC,IAAI,CAAC,IAAA,2BAAiB,EAAC,IAAI,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B"}
1
+ {"version":3,"file":"misc.js","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":";;;AACA,qCAA4C;AAG5C;;GAEG;AACI,MAAM,eAAe,GAAG,CAC7B,MAAgB,EAChB,IAAc,EACC,EAAE;IACjB,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,CAAC,IAAI,CAAC,IAAA,2BAAiB,EAAC,IAAI,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B;AAEF;;;;GAIG;AACI,MAAM,cAAc,GAAG,KAAK,EAAE,MAAgB,EAAmB,EAAE;IACxE,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * TODO: Разробраться. Эти проблемы решают сейчас в разных проектах
3
+ * самыми разными способами
4
+ *
5
+ * a.fedorov
6
+ */
7
+ export declare const omitUndefined: <R extends Record<string, any>>(record: R) => { [k in keyof R]: undefined extends R[k] ? never : R[k]; };
package/dist/object.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omitUndefined = void 0;
4
+ /**
5
+ * TODO: Разробраться. Эти проблемы решают сейчас в разных проектах
6
+ * самыми разными способами
7
+ *
8
+ * a.fedorov
9
+ */
10
+ const omitUndefined = (record) => Object.fromEntries(Object.entries(record).filter(([_, value]) => value !== undefined));
11
+ exports.omitUndefined = omitUndefined;
12
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAC3B,MAAS,EAGT,EAAE,CACF,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAC5D,CAAC;AAPE,QAAA,aAAa,iBAOf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/common.node",
3
- "version": "4.1.0",
3
+ "version": "4.2.0-next.1",
4
4
  "description": "Useful common classes, functions and types",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -19,5 +19,5 @@
19
19
  "toml": "^3.0.0",
20
20
  "yaml": "^2.3.1"
21
21
  },
22
- "gitHead": "3215698c567d2eb6018b2e1147217cd305f696c2"
22
+ "gitHead": "e42244b7badde74fec2badc60a85d53878fe75ae"
23
23
  }
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { omitUndefined } from './object';
2
+
1
3
  export { Concurrency } from './concurrency.decorator';
2
4
 
3
5
  export { Deferred } from './deferred';
package/src/misc.ts CHANGED
@@ -15,3 +15,18 @@ export const streamWriteFile = (
15
15
  stream.once('end', resolve);
16
16
  });
17
17
  };
18
+
19
+ /**
20
+ * Reads stream to Node.js Buffer chunk by chunk
21
+ * @param stream Readable stream
22
+ * @returns Promise<Buffer>
23
+ */
24
+ export const streamToBuffer = async (stream: Readable): Promise<Buffer> => {
25
+ const chunks = [];
26
+
27
+ for await (const chunk of stream) {
28
+ chunks.push(Buffer.from(chunk));
29
+ }
30
+
31
+ return Buffer.concat(chunks);
32
+ };
package/src/object.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * TODO: Разробраться. Эти проблемы решают сейчас в разных проектах
3
+ * самыми разными способами
4
+ *
5
+ * a.fedorov
6
+ */
7
+ export const omitUndefined = <R extends Record<string, any>>(
8
+ record: R,
9
+ ): {
10
+ [k in keyof R]: undefined extends R[k] ? never : R[k];
11
+ } =>
12
+ Object.fromEntries(
13
+ Object.entries(record).filter(([_, value]) => value !== undefined),
14
+ ) as any;