UNPKG

@softchef/cdk-iot-device-management

Version:

IoT device management is composed of things, thing types, thing groups, jobs, files API services. The constructs can be used independently, that are based on full-managed service to create an API Gateway & Lambda function.

17 lines (16 loc) 593 B
import { HashCalculator } from "./HashCalculator"; export var readableStreamHasher = function (hashCtor, readableStream) { var hash = new hashCtor(); var hashCalculator = new HashCalculator(hash); readableStream.pipe(hashCalculator); return new Promise(function (resolve, reject) { readableStream.on("error", function (err) { hashCalculator.end(); reject(err); }); hashCalculator.on("error", reject); hashCalculator.on("finish", function () { hash.digest().then(resolve).catch(reject); }); }); };