README.md (1878B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2021 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # isClass 22 23 > Test if a value is a [class][mdn-class]. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isClass = require( '@stdlib/assert/is-class' ); 31 ``` 32 33 #### isClass( value ) 34 35 Tests if a value is a [`class`][mdn-class]. 36 37 <!-- eslint-disable max-classes-per-file, no-restricted-syntax --> 38 39 ```javascript 40 var bool = isClass( class Animal { 41 speak() { 42 return this; 43 } 44 } ); 45 // returns true 46 47 var Rectangle = class { 48 constructor( height, width ) { 49 this.height = height; 50 this.width = width; 51 } 52 }; 53 54 bool = isClass( Rectangle ); 55 // returns true 56 57 bool = isClass( null ); 58 // returns false 59 ``` 60 61 </section> 62 63 <!-- /.usage --> 64 65 <section class="examples"> 66 67 ## Examples 68 69 <!-- eslint no-undef: "error" --> 70 71 <!-- eslint-disable no-restricted-syntax, no-empty-function --> 72 73 ```javascript 74 var isClass = require( '@stdlib/assert/is-class' ); 75 76 var bool = isClass( class Person {} ); 77 // returns true 78 79 bool = isClass( function Person() {} ); 80 // returns false 81 82 bool = isClass( [] ); 83 // returns false 84 85 bool = isClass( {} ); 86 // returns false 87 88 bool = isClass( null ); 89 // returns false 90 ``` 91 92 </section> 93 94 <!-- /.examples --> 95 96 <section class="links"> 97 98 [mdn-class]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes 99 100 </section> 101 102 <!-- /.links -->