1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.isInstanceOf = void 0;
|
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 | function isInstanceOf(value, Clazz) {
|
19 | return (((value && value.constructor) === Clazz) ||
|
20 | value instanceof Clazz);
|
21 | }
|
22 | exports.isInstanceOf = isInstanceOf;
|