README.md (2952B)
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 # isNumericArray 22 23 > Test if a value is a numeric array. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isNumericArray = require( '@stdlib/assert/is-numeric-array' ); 31 ``` 32 33 #### isNumericArray( value ) 34 35 Tests if a value is a numeric array. 36 37 ```javascript 38 var Int8Array = require( '@stdlib/array/int8' ); 39 40 var bool = isNumericArray( new Int8Array( 10 ) ); 41 // returns true 42 43 bool = isNumericArray( [ 1, 2, 3 ] ); 44 // returns true 45 46 bool = isNumericArray( [ '1', '2', '3' ] ); 47 // returns false 48 ``` 49 50 </section> 51 52 <!-- /.usage --> 53 54 <section class="examples"> 55 56 ## Examples 57 58 <!-- TODO: update once Buffer wrapper --> 59 60 <!-- eslint no-undef: "error" --> 61 62 <!-- eslint-disable no-buffer-constructor --> 63 64 ```javascript 65 var Buffer = require( '@stdlib/buffer/ctor' ); 66 var Int8Array = require( '@stdlib/array/int8' ); 67 var Uint8Array = require( '@stdlib/array/uint8' ); 68 var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); 69 var Int16Array = require( '@stdlib/array/int16' ); 70 var Uint16Array = require( '@stdlib/array/uint16' ); 71 var Int32Array = require( '@stdlib/array/int32' ); 72 var Uint32Array = require( '@stdlib/array/uint32' ); 73 var Float32Array = require( '@stdlib/array/float32' ); 74 var Float64Array = require( '@stdlib/array/float64' ); 75 var isNumericArray = require( '@stdlib/assert/is-numeric-array' ); 76 77 var arr = new Int8Array( 10 ); 78 var bool = isNumericArray( arr ); 79 // returns true 80 81 arr = new Uint8Array( 10 ); 82 bool = isNumericArray( arr ); 83 // returns true 84 85 arr = new Uint8ClampedArray( 10 ); 86 bool = isNumericArray( arr ); 87 // returns true 88 89 arr = new Int16Array( 10 ); 90 bool = isNumericArray( arr ); 91 // returns true 92 93 arr = new Uint16Array( 10 ); 94 bool = isNumericArray( arr ); 95 // returns true 96 97 arr = new Int32Array( 10 ); 98 bool = isNumericArray( arr ); 99 // returns true 100 101 arr = new Uint32Array( 10 ); 102 bool = isNumericArray( arr ); 103 // returns true 104 105 arr = new Float32Array( 10 ); 106 bool = isNumericArray( arr ); 107 // returns true 108 109 arr = new Float64Array( 10 ); 110 bool = isNumericArray( arr ); 111 // returns true 112 113 arr = [ 1, 2, 3 ]; 114 bool = isNumericArray( arr ); 115 // returns true 116 117 bool = isNumericArray( [] ); 118 // returns false 119 120 bool = isNumericArray( {} ); 121 // returns false 122 123 bool = isNumericArray( null ); 124 // returns false 125 126 bool = isNumericArray( new Buffer( 10 ) ); 127 // returns false 128 ``` 129 130 </section> 131 132 <!-- /.examples --> 133 134 <section class="links"> 135 136 </section> 137 138 <!-- /.links -->