@aws-sdk/hash-stream-node
Advanced tools
Comparing version 3.52.0 to 3.53.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [3.53.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.52.0...v3.53.0) (2022-02-24) | ||
### Bug Fixes | ||
* **hash-stream-node:** support file stream in readableStreamHasher ([#3338](https://github.com/aws/aws-sdk-js-v3/issues/3338)) ([1e3faa1](https://github.com/aws/aws-sdk-js-v3/commit/1e3faa1976a5119dcc985c8f513833e3d01fe3dc)) | ||
* **hash-stream-node:** throw error if non-file readableStream is flowing ([#3341](https://github.com/aws/aws-sdk-js-v3/issues/3341)) ([76df645](https://github.com/aws/aws-sdk-js-v3/commit/76df645d6109f6ce853830236a0bc77960b97f6c)) | ||
# [3.52.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.51.0...v3.52.0) (2022-02-18) | ||
@@ -8,0 +20,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readableStreamHasher = void 0; | ||
const fsCreateReadStream_1 = require("./fsCreateReadStream"); | ||
const HashCalculator_1 = require("./HashCalculator"); | ||
const isFileStream_1 = require("./isFileStream"); | ||
const readableStreamHasher = (hashCtor, readableStream) => { | ||
if (!isFileStream_1.isFileStream(readableStream) && readableStream.readableFlowing !== null) { | ||
throw new Error("Unable to calculate hash for flowing readable stream"); | ||
} | ||
const streamToPipe = isFileStream_1.isFileStream(readableStream) ? fsCreateReadStream_1.fsCreateReadStream(readableStream) : readableStream; | ||
const hash = new hashCtor(); | ||
const hashCalculator = new HashCalculator_1.HashCalculator(hash); | ||
readableStream.pipe(hashCalculator); | ||
streamToPipe.pipe(hashCalculator); | ||
return new Promise((resolve, reject) => { | ||
readableStream.on("error", (err) => { | ||
streamToPipe.on("error", (err) => { | ||
hashCalculator.end(); | ||
@@ -12,0 +18,0 @@ reject(err); |
@@ -0,8 +1,14 @@ | ||
import { fsCreateReadStream } from "./fsCreateReadStream"; | ||
import { HashCalculator } from "./HashCalculator"; | ||
import { isFileStream } from "./isFileStream"; | ||
export var readableStreamHasher = function (hashCtor, readableStream) { | ||
if (!isFileStream(readableStream) && readableStream.readableFlowing !== null) { | ||
throw new Error("Unable to calculate hash for flowing readable stream"); | ||
} | ||
var streamToPipe = isFileStream(readableStream) ? fsCreateReadStream(readableStream) : readableStream; | ||
var hash = new hashCtor(); | ||
var hashCalculator = new HashCalculator(hash); | ||
readableStream.pipe(hashCalculator); | ||
streamToPipe.pipe(hashCalculator); | ||
return new Promise(function (resolve, reject) { | ||
readableStream.on("error", function (err) { | ||
streamToPipe.on("error", function (err) { | ||
hashCalculator.end(); | ||
@@ -9,0 +15,0 @@ reject(err); |
{ | ||
"name": "@aws-sdk/hash-stream-node", | ||
"version": "3.52.0", | ||
"version": "3.53.0", | ||
"scripts": { | ||
@@ -22,3 +22,3 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"dependencies": { | ||
"@aws-sdk/types": "3.52.0", | ||
"@aws-sdk/types": "3.53.0", | ||
"tslib": "^2.3.0" | ||
@@ -25,0 +25,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56158
28
225
4
+ Added@aws-sdk/types@3.53.0(transitive)
- Removed@aws-sdk/types@3.52.0(transitive)
Updated@aws-sdk/types@3.53.0