README.md (2252B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 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 # isComplexLike 22 23 > Test if a value is a complex number-like object. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isComplexLike = require( '@stdlib/assert/is-complex-like' ); 31 ``` 32 33 #### isComplexLike( value ) 34 35 Tests if a value is a complex number-like `object`. 36 37 ```javascript 38 var Complex128 = require( '@stdlib/complex/float64' ); 39 var Complex64 = require( '@stdlib/complex/float32' ); 40 41 var x = new Complex128( 1.0, 3.0 ); 42 var bool = isComplexLike( x ); 43 // returns true 44 45 x = new Complex64( 3.0, 1.0 ); 46 bool = isComplexLike( x ); 47 // returns true 48 49 x = { 50 're': 1.0, 51 'im': -1.0 52 }; 53 bool = isComplexLike( x ); 54 // returns true 55 ``` 56 57 </section> 58 59 <!-- /.usage --> 60 61 <section class="notes"> 62 63 ## Notes 64 65 - A complex number-like `object` is defined as an `object` having the following properties assigned to numeric values: 66 67 - **re**: real component. 68 - **im**: imaginary component. 69 70 </section> 71 72 <!-- /.notes --> 73 74 <section class="examples"> 75 76 ## Examples 77 78 <!-- eslint no-undef: "error" --> 79 80 <!-- eslint-disable object-curly-newline, object-property-newline --> 81 82 ```javascript 83 var Complex64 = require( '@stdlib/complex/float32' ); 84 var Complex128 = require( '@stdlib/complex/float64' ); 85 var isComplexLike = require( '@stdlib/assert/is-complex-like' ); 86 87 var out = isComplexLike( new Complex64( 2.0, 2.0 ) ); 88 // returns true 89 90 out = isComplexLike( new Complex128( 3.0, 1.0 ) ); 91 // returns true 92 93 out = isComplexLike( { 're': 1.0, 'im': -1.0 } ); 94 // returns true 95 96 out = isComplexLike( {} ); 97 // returns false 98 99 out = isComplexLike( null ); 100 // returns false 101 ``` 102 103 </section> 104 105 <!-- /.examples --> 106 107 <section class="links"> 108 109 </section> 110 111 <!-- /.links -->