File tree Expand file tree Collapse file tree 1 file changed +18
-16
lines changed
packages/middleware-flexible-checksums/src Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -3,26 +3,28 @@ import { numToUint8 } from "@aws-crypto/util";
33import { Checksum } from "@smithy/types" ;
44import * as zlib from "zlib" ;
55
6+ class NodeCrc32 implements Checksum {
7+ checksum = 0 ;
8+
9+ update ( data : Uint8Array ) {
10+ // @ts -expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
11+ this . checksum = zlib . crc32 ( data , this . checksum ) ;
12+ }
13+
14+ async digest ( ) {
15+ return numToUint8 ( this . checksum ) ;
16+ }
17+
18+ reset ( ) {
19+ this . checksum = 0 ;
20+ }
21+ }
22+
623export const getCrc32ChecksumAlgorithmFunction = ( ) => {
724 // @ts -expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
825 if ( typeof zlib . crc32 === "undefined" ) {
926 return AwsCrc32 ;
1027 }
1128
12- return class NodeCrc32 implements Checksum {
13- checksum = 0 ;
14-
15- update ( data : Uint8Array ) {
16- // @ts -expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
17- this . checksum = zlib . crc32 ( data , this . checksum ) ;
18- }
19-
20- async digest ( ) {
21- return numToUint8 ( this . checksum ) ;
22- }
23-
24- reset ( ) {
25- this . checksum = 0 ;
26- }
27- } ;
29+ return NodeCrc32 ;
2830} ;
You can’t perform that action at this time.
0 commit comments