UNPKG

576 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3
4/**
5 * @name isInstanceOf
6 * @summary Tests for a instance of a class.
7 * @description
8 * Checks to see if the input value is an instance of the test class.
9 * @example
10 * <BR>
11 *
12 * ```javascript
13 * import { isInstanceOf } from '@polkadot/util';
14 *
15 * console.log('isInstanceOf', isInstanceOf(new Array(0), Array)); // => true
16 * ```
17 */
18// eslint-disable-next-line @typescript-eslint/ban-types
19export function isInstanceOf(value, clazz) {
20 return value instanceof clazz;
21}
\No newline at end of file