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.

21 lines (20 loc) 757 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readableStreamHasher = void 0; const HashCalculator_1 = require("./HashCalculator"); const readableStreamHasher = (hashCtor, readableStream) => { const hash = new hashCtor(); const hashCalculator = new HashCalculator_1.HashCalculator(hash); readableStream.pipe(hashCalculator); return new Promise((resolve, reject) => { readableStream.on("error", (err) => { hashCalculator.end(); reject(err); }); hashCalculator.on("error", reject); hashCalculator.on("finish", () => { hash.digest().then(resolve).catch(reject); }); }); }; exports.readableStreamHasher = readableStreamHasher;