time-to-botec

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

README.md (2901B)


      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 # isFinite
     22 
     23 > Test if a value is a finite number.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 <!-- eslint-disable stdlib/no-redeclare -->
     30 
     31 ```javascript
     32 var isFinite = require( '@stdlib/assert/is-finite' );
     33 ```
     34 
     35 #### isFinite( value )
     36 
     37 Tests if a value is a finite `number`.
     38 
     39 <!-- eslint-disable stdlib/no-redeclare, no-new-wrappers -->
     40 
     41 ```javascript
     42 var Number = require( '@stdlib/number/ctor' );
     43 
     44 var bool = isFinite( 5.0 );
     45 // returns true
     46 
     47 bool = isFinite( new Number( 5.0 ) );
     48 // returns true
     49 
     50 bool = isFinite( 1.0/0.0 );
     51 // returns false
     52 
     53 bool = isFinite( null );
     54 // returns false
     55 ```
     56 
     57 #### isFinite.isPrimitive( value )
     58 
     59 Tests if a `value` is a primitive `number` having a finite value.
     60 
     61 <!-- eslint-disable stdlib/no-redeclare, no-new-wrappers -->
     62 
     63 ```javascript
     64 var Number = require( '@stdlib/number/ctor' );
     65 
     66 var bool = isFinite.isPrimitive( -3.0 );
     67 // returns true
     68 
     69 bool = isFinite.isPrimitive( new Number( -3.0 ) );
     70 // returns false
     71 ```
     72 
     73 #### isFinite.isObject( value )
     74 
     75 Tests if a `value` is a `Number` object having a finite value.
     76 
     77 <!-- eslint-disable stdlib/no-redeclare, no-new-wrappers -->
     78 
     79 ```javascript
     80 var Number = require( '@stdlib/number/ctor' );
     81 
     82 var bool = isFinite.isObject( 3.0 );
     83 // returns false
     84 
     85 bool = isFinite.isObject( new Number( 3.0 ) );
     86 // returns true
     87 ```
     88 
     89 </section>
     90 
     91 <!-- /.usage -->
     92 
     93 <section class="notes">
     94 
     95 ## Notes
     96 
     97 -   In contrast to the built-in [`isFinite`][mdn-is-finite], input values are **not** coerced to numbers.
     98 
     99 </section>
    100 
    101 <!-- /.notes -->
    102 
    103 <section class="examples">
    104 
    105 ## Examples
    106 
    107 <!-- eslint-disable stdlib/no-redeclare, no-new-wrappers -->
    108 
    109 <!-- eslint no-undef: "error" -->
    110 
    111 ```javascript
    112 var Number = require( '@stdlib/number/ctor' );
    113 var isFinite = require( '@stdlib/assert/is-finite' );
    114 
    115 var bool = isFinite( -5.0 );
    116 // returns true
    117 
    118 bool = isFinite( 0.0 );
    119 // returns true
    120 
    121 bool = isFinite( new Number( 5.0 ) );
    122 // returns true
    123 
    124 bool = isFinite( 5.256 );
    125 // returns true
    126 
    127 bool = isFinite( 1.0/0.0 );
    128 // returns false
    129 
    130 bool = isFinite( -1.0/0.0 );
    131 // returns false
    132 
    133 bool = isFinite( '5' );
    134 // returns false
    135 
    136 bool = isFinite( null );
    137 // returns false
    138 ```
    139 
    140 </section>
    141 
    142 <!-- /.examples -->
    143 
    144 <section class="links">
    145 
    146 [mdn-is-finite]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite
    147 
    148 </section>
    149 
    150 <!-- /.links -->