time-to-botec

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

README.md (2074B)


      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 # isTruthy
     22 
     23 > Test if a value is truthy.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isTruthy = require( '@stdlib/assert/is-truthy' );
     31 ```
     32 
     33 #### isTruthy( value )
     34 
     35 Tests if a `value` is a value which translates to `true` when evaluated in a boolean context.
     36 
     37 ```javascript
     38 var bool = isTruthy( true );
     39 // returns true
     40 
     41 bool = isTruthy( [] );
     42 // returns true
     43 
     44 bool = isTruthy( false );
     45 // returns false
     46 
     47 bool = isTruthy( '' );
     48 // returns false
     49 
     50 bool = isTruthy( 0 );
     51 // returns false
     52 
     53 bool = isTruthy( NaN );
     54 // returns false
     55 
     56 bool = isTruthy( null );
     57 // returns false
     58 
     59 bool = isTruthy( void 0 );
     60 // returns false
     61 ```
     62 
     63 </section>
     64 
     65 <!-- /.usage -->
     66 
     67 <section class="examples">
     68 
     69 ## Examples
     70 
     71 <!-- eslint-disable no-empty-function, no-restricted-syntax -->
     72 
     73 <!-- eslint no-undef: "error" -->
     74 
     75 ```javascript
     76 var isTruthy = require( '@stdlib/assert/is-truthy' );
     77 
     78 var bool = isTruthy( true );
     79 // returns true
     80 
     81 bool = isTruthy( 'beep' );
     82 // returns true
     83 
     84 bool = isTruthy( 5 );
     85 // returns true
     86 
     87 bool = isTruthy( [] );
     88 // returns true
     89 
     90 bool = isTruthy( {} );
     91 // returns true
     92 
     93 bool = isTruthy( function foo() {} );
     94 // returns true
     95 
     96 bool = isTruthy( false );
     97 // returns false
     98 
     99 bool = isTruthy( 0 );
    100 // returns false
    101 
    102 bool = isTruthy( NaN );
    103 // returns false
    104 
    105 bool = isTruthy( '' );
    106 // returns false
    107 
    108 bool = isTruthy( void 0 );
    109 // returns false
    110 
    111 bool = isTruthy( null );
    112 // returns false
    113 ```
    114 
    115 </section>
    116 
    117 <!-- /.examples -->
    118 
    119 <section class="links">
    120 
    121 </section>
    122 
    123 <!-- /.links -->