time-to-botec

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

README.md (2132B)


      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 # isPrimitive
     22 
     23 > Test if a value is a JavaScript primitive.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isPrimitive = require( '@stdlib/assert/is-primitive' );
     31 ```
     32 
     33 #### isPrimitive( value )
     34 
     35 Tests if a `value` is a JavaScript primitive.
     36 
     37 ```javascript
     38 var bool = isPrimitive( false );
     39 // returns true
     40 ```
     41 
     42 </section>
     43 
     44 <!-- /.usage -->
     45 
     46 <section class="notes">
     47 
     48 ## Notes
     49 
     50 -   Seven primitives:
     51 
     52     -   `string`
     53     -   `number`
     54     -   `boolean`
     55     -   `null`
     56     -   `undefined`
     57     -   `symbol` (ES6/ES2015)
     58     -   `bigint` (ES11/ES2020)
     59 
     60 </section>
     61 
     62 <!-- /.notes -->
     63 
     64 <section class="examples">
     65 
     66 ## Examples
     67 
     68 <!-- eslint-disable no-restricted-syntax, no-new-object, no-new-wrappers, no-empty-function, no-array-constructor -->
     69 
     70 <!-- eslint no-undef: "error" -->
     71 
     72 ```javascript
     73 var isPrimitive = require( '@stdlib/assert/is-primitive' );
     74 
     75 var bool = isPrimitive( false );
     76 // returns true
     77 
     78 bool = isPrimitive( 0 );
     79 // returns true
     80 
     81 bool = isPrimitive( '' );
     82 // returns true
     83 
     84 bool = isPrimitive( null );
     85 // returns true
     86 
     87 bool = isPrimitive( void 0 );
     88 // returns true
     89 
     90 bool = isPrimitive( [] );
     91 // returns false
     92 
     93 bool = isPrimitive( {} );
     94 // returns false
     95 
     96 bool = isPrimitive( function noop() {} );
     97 // returns false
     98 
     99 bool = isPrimitive( new Boolean() );
    100 // returns false
    101 
    102 bool = isPrimitive( new String() );
    103 // returns false
    104 
    105 bool = isPrimitive( new Array() );
    106 // returns false
    107 
    108 bool = isPrimitive( new Object() );
    109 // returns false
    110 ```
    111 
    112 </section>
    113 
    114 <!-- /.examples -->
    115 
    116 <section class="links">
    117 
    118 </section>
    119 
    120 <!-- /.links -->