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