From fbf02e3198f04efa94aa643a62c4dd734afab75b Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 10 May 2021 12:33:11 +0200 Subject: [PATCH] util: add util.types.isKeyObject and util.types.isCryptoKey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #38611 PR-URL: https://github.com/nodejs/node/pull/38619 Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- doc/api/util.md | 20 +++++++++++++ lib/internal/crypto/keys.js | 4 +-- lib/internal/util/types.js | 37 ++++++++++++++++++++++++ test/parallel/test-crypto-key-objects.js | 25 +++++++++++++++- test/parallel/test-util-types.js | 10 +++++++ test/parallel/test-webcrypto-keygen.js | 23 ++++++++++++++- 6 files changed, 115 insertions(+), 4 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index 4f3ff2e7358df9..93042b3d5ff58e 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1483,6 +1483,16 @@ util.types.isBoxedPrimitive(Object(Symbol('foo'))); // Returns true util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true ``` +### `util.types.isCryptoKey(value)` + + +* `value` {Object} +* Returns: {boolean} + +Returns `true` if `value` is a {CryptoKey}, `false` otherwise. + ### `util.types.isDataView(value)` + +* `value` {Object} +* Returns: {boolean} + +Returns `true` if `value` is a {KeyObject}, `false` otherwise. + ### `util.types.isMap(value)`