time-to-botec

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

README.md (3015B)


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