UNPKG

serverless-spy

Version:

CDK-based library for writing elegant integration tests on AWS serverless architecture and an additional web console to monitor events in real time.

24 lines (23 loc) 552 B
import { AwsCrc32 } from "@aws-crypto/crc32"; import { numToUint8 } from "@aws-crypto/util"; import * as zlib from "zlib"; class NodeCrc32 { constructor() { this.checksum = 0; } update(data) { this.checksum = zlib.crc32(data, this.checksum); } async digest() { return numToUint8(this.checksum); } reset() { this.checksum = 0; } } export const getCrc32ChecksumAlgorithmFunction = () => { if (typeof zlib.crc32 === "undefined") { return AwsCrc32; } return NodeCrc32; };