time-to-botec

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

README.md (2677B)


      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 # isBigInt
     22 
     23 > Test if a value is a [BigInt][mdn-bigint].
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isBigInt = require( '@stdlib/assert/is-bigint' );
     31 ```
     32 
     33 #### isBigInt( value )
     34 
     35 Tests if a value is a [`BigInt`][mdn-bigint].
     36 
     37 ```javascript
     38 var BigInt = require( '@stdlib/bigint/ctor' );
     39 
     40 var bool = isBigInt( BigInt( '1' ) );
     41 // returns true
     42 
     43 bool = isBigInt( Object( BigInt( '1' ) ) );
     44 // returns true
     45 ```
     46 
     47 #### isBigInt.isPrimitive( value )
     48 
     49 Tests if a `value` is a primitive [`BigInt`][mdn-bigint].
     50 
     51 ```javascript
     52 var BigInt = require( '@stdlib/bigint/ctor' );
     53 
     54 var bool = isBigInt.isPrimitive( BigInt( '1' ) );
     55 // returns true
     56 
     57 bool = isBigInt.isPrimitive( Object( BigInt( '1' ) ) );
     58 // returns false
     59 ```
     60 
     61 #### isBigInt.isObject( value )
     62 
     63 Tests if a `value` is a [`BigInt`][mdn-bigint] object.
     64 
     65 ```javascript
     66 var BigInt = require( '@stdlib/bigint/ctor' );
     67 
     68 var bool = isBigInt.isObject( BigInt( '1' ) );
     69 // returns false
     70 
     71 bool = isBigInt.isObject( Object( BigInt( '1' ) ) );
     72 // returns true
     73 ```
     74 
     75 </section>
     76 
     77 <!-- /.usage -->
     78 
     79 <section class="examples">
     80 
     81 ## Examples
     82 
     83 <!-- eslint-disable no-restricted-syntax, no-empty-function -->
     84 
     85 <!-- eslint no-undef: "error" -->
     86 
     87 ```javascript
     88 var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' );
     89 var BigInt = require( '@stdlib/bigint/ctor' );
     90 var isBigInt = require( '@stdlib/assert/is-bigint' );
     91 
     92 var bool;
     93 if ( hasBigIntSupport() ) {
     94     bool = isBigInt( BigInt( '1' ) );
     95     // returns true
     96 } else {
     97     console.log( 'Environment does not support BigInts.' );
     98 }
     99 bool = isBigInt( 1 );
    100 // returns false
    101 
    102 bool = isBigInt( '1' );
    103 // returns false
    104 
    105 bool = isBigInt( {} );
    106 // returns false
    107 
    108 bool = isBigInt( [] );
    109 // returns false
    110 
    111 bool = isBigInt( null );
    112 // returns false
    113 
    114 bool = isBigInt( void 0 );
    115 // returns false
    116 
    117 bool = isBigInt( true );
    118 // returns false
    119 
    120 bool = isBigInt( function foo() {} );
    121 // returns false
    122 ```
    123 
    124 </section>
    125 
    126 <!-- /.examples -->
    127 
    128 <section class="links">
    129 
    130 [mdn-bigint]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
    131 
    132 </section>
    133 
    134 <!-- /.links -->