From 016fc3506578209b71e9cfc47dcd2ab1d0e6c772 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Wed, 26 Apr 2023 19:38:13 -0700 Subject: [PATCH] Types: added definitions for Hash.copy() method. --- test/ts/test.ts | 1 + ts/njs_modules/crypto.d.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/test/ts/test.ts b/test/ts/test.ts index 5522f4a1..127fb089 100644 --- a/test/ts/test.ts +++ b/test/ts/test.ts @@ -188,6 +188,7 @@ function crypto_module(str: NjsByteString) { h = cr.createHash("sha1"); h = h.update(str).update(Buffer.from([0])); + h = h.copy(); b = h.digest(); s = cr.createHash("sha256").digest("hex"); diff --git a/ts/njs_modules/crypto.d.ts b/ts/njs_modules/crypto.d.ts index ea554f34..70801144 100644 --- a/ts/njs_modules/crypto.d.ts +++ b/ts/njs_modules/crypto.d.ts @@ -7,6 +7,12 @@ declare module "crypto" { export type DigestEncoding = Exclude; export interface Hash { + /** + * Returns a new Hash object that contains a deep copy of + * the internal state of the current Hash object. + */ + copy(): Hash; + /** * Updates the hash content with the given `data` and returns self. */ -- 2.47.3