time-to-botec

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

README.md (3412B)


      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 # isSharedArrayBuffer
     22 
     23 > Test if a value is a [SharedArrayBuffer][mdn-sharedarraybuffer].
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isSharedArrayBuffer = require( '@stdlib/assert/is-sharedarraybuffer' );
     31 ```
     32 
     33 #### isSharedArrayBuffer( value )
     34 
     35 Tests if a value is a [`SharedArrayBuffer`][mdn-sharedarraybuffer].
     36 
     37 <!-- eslint-disable no-unused-vars -->
     38 
     39 ```javascript
     40 var SharedArrayBuffer = require( '@stdlib/array/shared-buffer' );
     41 
     42 var bool;
     43 try {
     44     bool = isSharedArrayBuffer( new SharedArrayBuffer( 10 ) );
     45     // returns true
     46 } catch ( err ) {
     47     console.log( 'Environment does not support SharedArrayBuffers.' );
     48 }
     49 
     50 bool = isSharedArrayBuffer( [] );
     51 // returns false
     52 ```
     53 
     54 </section>
     55 
     56 <!-- /.usage -->
     57 
     58 <section class="examples">
     59 
     60 ## Examples
     61 
     62 <!-- eslint-disable no-unused-vars -->
     63 
     64 <!-- eslint no-undef: "error" -->
     65 
     66 ```javascript
     67 var Float32Array = require( '@stdlib/array/float32' );
     68 var Float64Array = require( '@stdlib/array/float64' );
     69 var Int8Array = require( '@stdlib/array/int8' );
     70 var Int16Array = require( '@stdlib/array/int16' );
     71 var Int32Array = require( '@stdlib/array/int32' );
     72 var Uint8Array = require( '@stdlib/array/uint8' );
     73 var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
     74 var Uint16Array = require( '@stdlib/array/uint16' );
     75 var Uint32Array = require( '@stdlib/array/uint32' );
     76 var ArrayBuffer = require( '@stdlib/array/buffer' );
     77 var SharedArrayBuffer = require( '@stdlib/array/shared-buffer' );
     78 var isSharedArrayBuffer = require( '@stdlib/assert/is-sharedarraybuffer' );
     79 
     80 var bool;
     81 try {
     82     bool = isSharedArrayBuffer( new SharedArrayBuffer( 10 ) );
     83     // returns true
     84 } catch ( err ) {
     85     console.log( 'Environment does not support SharedArrayBuffers.' );
     86 }
     87 bool = isSharedArrayBuffer( new ArrayBuffer( 10 ) );
     88 // returns false
     89 
     90 bool = isSharedArrayBuffer( new Float32Array( 10 ) );
     91 // returns false
     92 
     93 bool = isSharedArrayBuffer( new Int8Array( 10 ) );
     94 // returns false
     95 
     96 bool = isSharedArrayBuffer( new Uint8Array( 10 ) );
     97 // returns false
     98 
     99 bool = isSharedArrayBuffer( new Uint8ClampedArray( 10 ) );
    100 // returns false
    101 
    102 bool = isSharedArrayBuffer( new Int16Array( 10 ) );
    103 // returns false
    104 
    105 bool = isSharedArrayBuffer( new Uint16Array( 10 ) );
    106 // returns false
    107 
    108 bool = isSharedArrayBuffer( new Int32Array( 10 ) );
    109 // returns false
    110 
    111 bool = isSharedArrayBuffer( new Uint32Array( 10 ) );
    112 // returns false
    113 
    114 bool = isSharedArrayBuffer( new Float64Array( 10 ) );
    115 // returns false
    116 
    117 bool = isSharedArrayBuffer( new Array( 10 ) );
    118 // returns false
    119 
    120 bool = isSharedArrayBuffer( {} );
    121 // returns false
    122 
    123 bool = isSharedArrayBuffer( null );
    124 // returns false
    125 ```
    126 
    127 </section>
    128 
    129 <!-- /.examples -->
    130 
    131 <section class="links">
    132 
    133 [mdn-sharedarraybuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
    134 
    135 </section>
    136 
    137 <!-- /.links -->