time-to-botec

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

README.md (2849B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2021 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 # isArrayBufferView
     22 
     23 > Test if a value is an [ArrayBuffer][mdn-arraybuffer] view.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isArrayBufferView = require( '@stdlib/assert/is-arraybuffer-view' );
     31 ```
     32 
     33 #### isArrayBufferView( value )
     34 
     35 Tests if a value is an [`ArrayBuffer`][mdn-arraybuffer] view such as a [`DataView`][mdn-dataview] or [`TypedArray`][mdn-typed-array].
     36 
     37 ```javascript
     38 var Int8Array = require( '@stdlib/array/int8' );
     39 var ArrayBuffer = require( '@stdlib/array/buffer' );
     40 
     41 var bool = isArrayBufferView( new Int8Array( 10 ) );
     42 // returns true
     43 
     44 bool = isArrayBufferView( new ArrayBuffer( 10 ) );
     45 // returns false
     46 ```
     47 
     48 </section>
     49 
     50 <!-- /.usage -->
     51 
     52 <section class="examples">
     53 
     54 ## Examples
     55 
     56 <!-- eslint no-undef: "error" -->
     57 
     58 ```javascript
     59 var Float32Array = require( '@stdlib/array/float32' );
     60 var Float64Array = require( '@stdlib/array/float64' );
     61 var Int8Array = require( '@stdlib/array/int8' );
     62 var Int16Array = require( '@stdlib/array/int16' );
     63 var Int32Array = require( '@stdlib/array/int32' );
     64 var Uint16Array = require( '@stdlib/array/uint16' );
     65 var ArrayBuffer = require( '@stdlib/array/buffer' );
     66 var isArrayBufferView = require( '@stdlib/assert/is-arraybuffer-view' );
     67 
     68 var bool = isArrayBufferView( new Int8Array( 10 ) );
     69 // returns true
     70 
     71 bool = isArrayBufferView( new Int16Array( 10 ) );
     72 // returns true
     73 
     74 bool = isArrayBufferView( new Uint16Array( 10 ) );
     75 // returns true
     76 
     77 bool = isArrayBufferView( new Int32Array( 10 ) );
     78 // returns true
     79 
     80 bool = isArrayBufferView( new Float64Array( 10 ) );
     81 // returns true
     82 
     83 bool = isArrayBufferView( new Float32Array( 10 ) );
     84 // returns true
     85 
     86 bool = isArrayBufferView( new ArrayBuffer( 10 ) );
     87 // returns false
     88 
     89 bool = isArrayBufferView( [] );
     90 // returns false
     91 
     92 bool = isArrayBufferView( {} );
     93 // returns false
     94 
     95 bool = isArrayBufferView( null );
     96 // returns false
     97 ```
     98 
     99 </section>
    100 
    101 <!-- /.examples -->
    102 
    103 <section class="links">
    104 
    105 [mdn-arraybuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
    106 
    107 [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
    108 
    109 [mdn-dataview]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
    110 
    111 </section>
    112 
    113 <!-- /.links -->