@aws-sdk/chunked-stream-reader-node 3.183.0 → 3.186.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
@@ -3,6 +3,14 @@
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
+ # [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/chunked-stream-reader-node
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
7
15
 
8
16
  **Note:** Version bump only for package @aws-sdk/chunked-stream-reader-node
package/dist-es/index.js CHANGED
@@ -1,24 +1,25 @@
1
- export function streamReader(stream, onChunk, chunkSize = 1048576) {
2
- return new Promise((resolve, reject) => {
3
- let temporaryBuffer;
1
+ export function streamReader(stream, onChunk, chunkSize) {
2
+ if (chunkSize === void 0) { chunkSize = 1048576; }
3
+ return new Promise(function (resolve, reject) {
4
+ var temporaryBuffer;
4
5
  stream.on("error", reject);
5
- stream.on("end", () => {
6
- if (temporaryBuffer?.byteLength) {
7
- for (let i = 0; i < temporaryBuffer.byteLength; i += chunkSize) {
6
+ stream.on("end", function () {
7
+ if (temporaryBuffer === null || temporaryBuffer === void 0 ? void 0 : temporaryBuffer.byteLength) {
8
+ for (var i = 0; i < temporaryBuffer.byteLength; i += chunkSize) {
8
9
  onChunk(temporaryBuffer.subarray(i, Math.min(i + chunkSize, temporaryBuffer.byteLength)));
9
10
  }
10
11
  temporaryBuffer = void 0;
11
12
  }
12
13
  resolve();
13
14
  });
14
- stream.on("data", (chunk) => {
15
+ stream.on("data", function (chunk) {
15
16
  if (!temporaryBuffer) {
16
17
  temporaryBuffer = chunk;
17
18
  }
18
19
  else {
19
20
  temporaryBuffer = mergeUint8Arrays(temporaryBuffer, chunk);
20
21
  }
21
- let pointer = 0;
22
+ var pointer = 0;
22
23
  while (temporaryBuffer.byteLength - pointer >= chunkSize) {
23
24
  onChunk(temporaryBuffer.subarray(pointer, pointer + chunkSize));
24
25
  pointer += chunkSize;
@@ -29,7 +30,7 @@ export function streamReader(stream, onChunk, chunkSize = 1048576) {
29
30
  });
30
31
  }
31
32
  function mergeUint8Arrays(a, b) {
32
- const result = new Uint8Array(a.byteLength + b.byteLength);
33
+ var result = new Uint8Array(a.byteLength + b.byteLength);
33
34
  result.set(a);
34
35
  result.set(b, a.byteLength);
35
36
  return result;
@@ -1,12 +1,15 @@
1
+ import { __extends } from "tslib";
1
2
  import { Readable } from "stream";
2
- export class ReadFromBuffers extends Readable {
3
- constructor(options) {
4
- super(options);
5
- this.numBuffersRead = 0;
6
- this.buffersToRead = options.buffers;
7
- this.errorAfter = typeof options.errorAfter === "number" ? options.errorAfter : -1;
3
+ var ReadFromBuffers = (function (_super) {
4
+ __extends(ReadFromBuffers, _super);
5
+ function ReadFromBuffers(options) {
6
+ var _this = _super.call(this, options) || this;
7
+ _this.numBuffersRead = 0;
8
+ _this.buffersToRead = options.buffers;
9
+ _this.errorAfter = typeof options.errorAfter === "number" ? options.errorAfter : -1;
10
+ return _this;
8
11
  }
9
- _read() {
12
+ ReadFromBuffers.prototype._read = function () {
10
13
  if (this.errorAfter !== -1 && this.errorAfter === this.numBuffersRead) {
11
14
  this.emit("error", new Error("Mock Error"));
12
15
  return;
@@ -15,5 +18,7 @@ export class ReadFromBuffers extends Readable {
15
18
  return this.push(null);
16
19
  }
17
20
  return this.push(this.buffersToRead[this.numBuffersRead++]);
18
- }
19
- }
21
+ };
22
+ return ReadFromBuffers;
23
+ }(Readable));
24
+ export { ReadFromBuffers };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/chunked-stream-reader-node",
3
- "version": "3.183.0",
3
+ "version": "3.186.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",