time-to-botec

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

README.md (3021B)


      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 # none
     22 
     23 > Test whether all elements in a collection are falsy.
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <!-- Package usage documentation. -->
     34 
     35 <section class="usage">
     36 
     37 ## Usage
     38 
     39 ```javascript
     40 var none = require( '@stdlib/utils/none' );
     41 ```
     42 
     43 #### none( collection )
     44 
     45 Tests whether all elements in a `collection` are falsy.
     46 
     47 ```javascript
     48 var arr = [ 0, 0, 0, 0, 0 ];
     49 
     50 var bool = none( arr );
     51 // returns true
     52 ```
     53 
     54 If provided an empty `collection`, the function returns `true`.
     55 
     56 ```javascript
     57 var bool = none( [] );
     58 // returns true
     59 ```
     60 
     61 </section>
     62 
     63 <!-- /.usage -->
     64 
     65 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     66 
     67 <section class="notes">
     68 
     69 ## Notes
     70 
     71 -   A `collection` may be either an [`Array`][mdn-array], [`Typed Array`][mdn-typed-array], or an array-like [`Object`][mdn-object] (excluding `strings` and `functions`).
     72 -   The function does **not** skip `undefined` elements and is thus not optimized for sparse collections.
     73 
     74 </section>
     75 
     76 <!-- /.notes -->
     77 
     78 <!-- Package usage examples. -->
     79 
     80 <section class="examples">
     81 
     82 ## Examples
     83 
     84 <!-- eslint no-undef: "error" -->
     85 
     86 ```javascript
     87 var randu = require( '@stdlib/random/base/randu' );
     88 var none = require( '@stdlib/utils/none' );
     89 
     90 var bool;
     91 var arr;
     92 var i;
     93 
     94 arr = new Array( 100 );
     95 for ( i = 0; i < arr.length; i++ ) {
     96     arr[ i ] = ( randu() > 0.95 );
     97 }
     98 
     99 bool = none( arr );
    100 // returns <boolean>
    101 ```
    102 
    103 </section>
    104 
    105 <!-- /.examples -->
    106 
    107 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    108 
    109 <section class="references">
    110 
    111 </section>
    112 
    113 <!-- /.references -->
    114 
    115 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    116 
    117 <section class="links">
    118 
    119 [mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
    120 
    121 [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
    122 
    123 [mdn-object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
    124 
    125 </section>
    126 
    127 <!-- /.links -->