README.md (2852B)
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 # Constructors 22 23 > Array constructors. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var ctors = require( '@stdlib/array/ctors' ); 41 ``` 42 43 #### ctors( dtype ) 44 45 Returns an array constructor for a specified data type. 46 47 ```javascript 48 var ctor = ctors( 'float64' ); 49 // returns <Function> 50 ``` 51 52 The function returns constructors for the following data types: 53 54 - `float32`: single-precision floating-point numbers. 55 - `float64`: double-precision floating-point numbers. 56 - `generic`: values of any type. 57 - `int16`: signed 16-bit integers. 58 - `int32`: signed 32-bit integers. 59 - `int8`: signed 8-bit integers. 60 - `uint16`: unsigned 16-bit integers. 61 - `uint32`: unsigned 32-bit integers. 62 - `uint8`: unsigned 8-bit integers. 63 - `uint8c`: unsigned clamped 8-bit integers. 64 65 If provided an unknown or unsupported data type, the function returns `null`. 66 67 ```javascript 68 var ctor = ctors( 'float' ); 69 // returns null 70 ``` 71 72 </section> 73 74 <!-- /.usage --> 75 76 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 77 78 <section class="notes"> 79 80 </section> 81 82 <!-- /.notes --> 83 84 <!-- Package usage examples. --> 85 86 <section class="examples"> 87 88 ## Examples 89 90 <!-- eslint no-undef: "error" --> 91 92 ```javascript 93 var dtypes = require( '@stdlib/array/dtypes' ); 94 var ctors = require( '@stdlib/array/ctors' ); 95 96 var DTYPES = dtypes(); 97 var ctor; 98 var i; 99 100 for ( i = 0; i < DTYPES.length; i++ ) { 101 ctor = ctors( DTYPES[ i ] ); 102 console.log( ctor ); 103 } 104 ``` 105 106 </section> 107 108 <!-- /.examples --> 109 110 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 111 112 <section class="references"> 113 114 </section> 115 116 <!-- /.references --> 117 118 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 119 120 <section class="links"> 121 122 </section> 123 124 <!-- /.links -->