README.md (2904B)
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 # isDataView 22 23 > Test if a value is a [DataView][mdn-dataview]. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isDataView = require( '@stdlib/assert/is-dataview' ); 31 ``` 32 33 #### isDataView( value ) 34 35 Tests if a value is a [`DataView`][mdn-dataview]. 36 37 ```javascript 38 var ArrayBuffer = require( '@stdlib/array/buffer' ); 39 var DataView = require( '@stdlib/array/dataview' ); 40 41 var bool = isDataView( new DataView( new ArrayBuffer( 10 ) ) ); 42 // returns true 43 44 bool = isDataView( [] ); 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 Uint8Array = require( '@stdlib/array/uint8' ); 65 var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); 66 var Uint16Array = require( '@stdlib/array/uint16' ); 67 var Uint32Array = require( '@stdlib/array/uint32' ); 68 var ArrayBuffer = require( '@stdlib/array/buffer' ); 69 var DataView = require( '@stdlib/array/dataview' ); 70 var isDataView = require( '@stdlib/assert/is-dataview' ); 71 72 var bool = isDataView( new DataView( new ArrayBuffer( 10 ) ) ); 73 // returns true 74 75 bool = isDataView( new Float32Array( 10 ) ); 76 // returns false 77 78 bool = isDataView( new Int8Array( 10 ) ); 79 // returns false 80 81 bool = isDataView( new Uint8Array( 10 ) ); 82 // returns false 83 84 bool = isDataView( new Uint8ClampedArray( 10 ) ); 85 // returns false 86 87 bool = isDataView( new Int16Array( 10 ) ); 88 // returns false 89 90 bool = isDataView( new Uint16Array( 10 ) ); 91 // returns false 92 93 bool = isDataView( new Int32Array( 10 ) ); 94 // returns false 95 96 bool = isDataView( new Uint32Array( 10 ) ); 97 // returns false 98 99 bool = isDataView( new Float64Array( 10 ) ); 100 // returns false 101 102 bool = isDataView( new Array( 10 ) ); 103 // returns false 104 105 bool = isDataView( new ArrayBuffer( 10 ) ); 106 // returns false 107 108 bool = isDataView( {} ); 109 // returns false 110 111 bool = isDataView( null ); 112 // returns false 113 ``` 114 115 </section> 116 117 <!-- /.examples --> 118 119 <section class="links"> 120 121 [mdn-dataview]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView 122 123 </section> 124 125 <!-- /.links -->