From 503a759889352f203df934c98957509ea7043af2 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 closes #38611 --- 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 | 5 ++++ test/parallel/test-webcrypto-keygen.js | 23 ++++++++++++++- 6 files changed, 110 insertions(+), 4 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index 429005799bd63fc..35b93ba198f3b97 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1485,6 +1485,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)`