time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (2868B)


      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 # isObjectLike
     22 
     23 > Test if a value is object-like.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isObjectLike = require( '@stdlib/assert/is-object-like' );
     31 ```
     32 
     33 #### isObjectLike( value )
     34 
     35 Tests if a `value` is object-like.
     36 
     37 ```javascript
     38 var bool = isObjectLike( {} );
     39 // returns true
     40 
     41 bool = isObjectLike( [] );
     42 // returns true
     43 
     44 bool = isObjectLike( true );
     45 // returns false
     46 ```
     47 
     48 #### isObjectLike.isObjectLikeArray( value )
     49 
     50 Tests if a `value` is an `array` of object-like values.
     51 
     52 ```javascript
     53 var bool = isObjectLike.isObjectLikeArray( [ {}, [] ] );
     54 // returns true
     55 
     56 bool = isObjectLike.isObjectLikeArray( [ {}, '3.0' ] );
     57 // returns false
     58 
     59 bool = isObjectLike.isObjectLikeArray( [] );
     60 // returns false
     61 ```
     62 
     63 </section>
     64 
     65 <!-- /.usage -->
     66 
     67 <section class="notes">
     68 
     69 ## Notes
     70 
     71 -   Return values are the same as would be obtained using the built-in [`typeof`][type-of] operator **except** that `null` is **not** considered an `object`.
     72 
     73     ```javascript
     74     var bool = ( typeof null === 'object' );
     75     // returns true
     76 
     77     bool = isObjectLike( null );
     78     // returns false
     79     ```
     80 
     81 </section>
     82 
     83 <!-- /.notes -->
     84 
     85 <section class="examples">
     86 
     87 ## Examples
     88 
     89 <!-- eslint-disable no-empty-function, no-restricted-syntax -->
     90 
     91 <!-- eslint no-undef: "error" -->
     92 
     93 ```javascript
     94 var Int8Array = require( '@stdlib/array/int8' );
     95 var ArrayBuffer = require( '@stdlib/array/buffer' );
     96 var isObjectLike = require( '@stdlib/assert/is-object-like' );
     97 
     98 var bool = isObjectLike( {} );
     99 // returns true
    100 
    101 bool = isObjectLike( [] );
    102 // returns true
    103 
    104 bool = isObjectLike( /./ );
    105 // returns true
    106 
    107 bool = isObjectLike( new Date() );
    108 // returns true
    109 
    110 bool = isObjectLike( Math );
    111 // returns true
    112 
    113 bool = isObjectLike( JSON );
    114 // returns true
    115 
    116 bool = isObjectLike( new Int8Array() );
    117 // returns true
    118 
    119 bool = isObjectLike( new ArrayBuffer() );
    120 // returns true
    121 
    122 bool = isObjectLike( 'a' );
    123 // returns false
    124 
    125 bool = isObjectLike( 5 );
    126 // returns false
    127 
    128 bool = isObjectLike( null );
    129 // returns false
    130 
    131 bool = isObjectLike( void 0 );
    132 // returns false
    133 
    134 bool = isObjectLike( function foo() {} );
    135 // returns false
    136 ```
    137 
    138 </section>
    139 
    140 <!-- /.examples -->
    141 
    142 <section class="links">
    143 
    144 [type-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
    145 
    146 </section>
    147 
    148 <!-- /.links -->