@stdlib/array-full-like 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +481 -0
- package/NOTICE +1 -0
- package/README.md +224 -0
- package/docs/repl.txt +45 -0
- package/docs/types/index.d.ts +724 -0
- package/docs/types/test.ts +97 -0
- package/lib/index.js +46 -0
- package/lib/main.js +77 -0
- package/package.json +145 -0
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
@license Apache-2.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2022 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
|
+
# fullLike
|
|
22
|
+
|
|
23
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
24
|
+
|
|
25
|
+
> Create a filled array having the same length and data type as a provided array.
|
|
26
|
+
|
|
27
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
28
|
+
|
|
29
|
+
<section class="intro">
|
|
30
|
+
|
|
31
|
+
</section>
|
|
32
|
+
|
|
33
|
+
<!-- /.intro -->
|
|
34
|
+
|
|
35
|
+
<!-- Package usage documentation. -->
|
|
36
|
+
|
|
37
|
+
<section class="installation">
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @stdlib/array-full-like
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
</section>
|
|
46
|
+
|
|
47
|
+
<section class="usage">
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
var fullLike = require( '@stdlib/array-full-like' );
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### fullLike( x, value\[, dtype] )
|
|
56
|
+
|
|
57
|
+
Creates a filled array having the same length and data type as a provided array `x`.
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
var x = [ 1, 2, 3, 4, 5 ];
|
|
61
|
+
|
|
62
|
+
var arr = fullLike( x, 1 );
|
|
63
|
+
// returns [ 1, 1, 1, 1, 1 ]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The function supports the following data types:
|
|
67
|
+
|
|
68
|
+
- `float64`: double-precision floating-point numbers (IEEE 754)
|
|
69
|
+
- `float32`: single-precision floating-point numbers (IEEE 754)
|
|
70
|
+
- `complex128`: double-precision complex floating-point numbers
|
|
71
|
+
- `complex64`: single-precision complex floating-point numbers
|
|
72
|
+
- `int32`: 32-bit two's complement signed integers
|
|
73
|
+
- `uint32`: 32-bit unsigned integers
|
|
74
|
+
- `int16`: 16-bit two's complement signed integers
|
|
75
|
+
- `uint16`: 16-bit unsigned integers
|
|
76
|
+
- `int8`: 8-bit two's complement signed integers
|
|
77
|
+
- `uint8`: 8-bit unsigned integers
|
|
78
|
+
- `uint8c`: 8-bit unsigned integers clamped to `0-255`
|
|
79
|
+
- `generic`: generic JavaScript values
|
|
80
|
+
|
|
81
|
+
By default, the output array data type is inferred from the provided array `x`. To return an array having a different data type, provide a `dtype` argument.
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
var x = [ 1, 1 ];
|
|
85
|
+
|
|
86
|
+
var arr = fullLike( x, 1, 'int32' );
|
|
87
|
+
// returns <Int32Array>[ 1, 1 ]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
</section>
|
|
91
|
+
|
|
92
|
+
<!-- /.usage -->
|
|
93
|
+
|
|
94
|
+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
95
|
+
|
|
96
|
+
<section class="notes">
|
|
97
|
+
|
|
98
|
+
## Notes
|
|
99
|
+
|
|
100
|
+
- If provided a number and the output array data type is a complex number data type, the function returns a complex number array where each element has a real component whose value equals the provided fill value and where each element has an imaginary component equal to `0`.
|
|
101
|
+
|
|
102
|
+
</section>
|
|
103
|
+
|
|
104
|
+
<!-- /.notes -->
|
|
105
|
+
|
|
106
|
+
<!-- Package usage examples. -->
|
|
107
|
+
|
|
108
|
+
<section class="examples">
|
|
109
|
+
|
|
110
|
+
## Examples
|
|
111
|
+
|
|
112
|
+
<!-- eslint no-undef: "error" -->
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
var dtypes = require( '@stdlib/array-dtypes' );
|
|
116
|
+
var zeros = require( '@stdlib/array-zeros' );
|
|
117
|
+
var fullLike = require( '@stdlib/array-full-like' );
|
|
118
|
+
|
|
119
|
+
// Create a zero-filled array:
|
|
120
|
+
var x = zeros( 4, 'complex128' );
|
|
121
|
+
|
|
122
|
+
// Get a list of array data types:
|
|
123
|
+
var dt = dtypes();
|
|
124
|
+
|
|
125
|
+
// Generate filled arrays...
|
|
126
|
+
var y;
|
|
127
|
+
var i;
|
|
128
|
+
for ( i = 0; i < dt.length; i++ ) {
|
|
129
|
+
y = fullLike( x, 1.0, dt[ i ] );
|
|
130
|
+
console.log( y );
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
</section>
|
|
135
|
+
|
|
136
|
+
<!-- /.examples -->
|
|
137
|
+
|
|
138
|
+
<!-- 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. -->
|
|
139
|
+
|
|
140
|
+
<section class="references">
|
|
141
|
+
|
|
142
|
+
</section>
|
|
143
|
+
|
|
144
|
+
<!-- /.references -->
|
|
145
|
+
|
|
146
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
147
|
+
|
|
148
|
+
<section class="related">
|
|
149
|
+
|
|
150
|
+
</section>
|
|
151
|
+
|
|
152
|
+
<!-- /.related -->
|
|
153
|
+
|
|
154
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
<section class="main-repo" >
|
|
158
|
+
|
|
159
|
+
* * *
|
|
160
|
+
|
|
161
|
+
## Notice
|
|
162
|
+
|
|
163
|
+
This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
|
|
164
|
+
|
|
165
|
+
For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
|
|
166
|
+
|
|
167
|
+
#### Community
|
|
168
|
+
|
|
169
|
+
[![Chat][chat-image]][chat-url]
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
See [LICENSE][stdlib-license].
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
## Copyright
|
|
179
|
+
|
|
180
|
+
Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
181
|
+
|
|
182
|
+
</section>
|
|
183
|
+
|
|
184
|
+
<!-- /.stdlib -->
|
|
185
|
+
|
|
186
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
187
|
+
|
|
188
|
+
<section class="links">
|
|
189
|
+
|
|
190
|
+
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-full-like.svg
|
|
191
|
+
[npm-url]: https://npmjs.org/package/@stdlib/array-full-like
|
|
192
|
+
|
|
193
|
+
[test-image]: https://github.com/stdlib-js/array-full-like/actions/workflows/test.yml/badge.svg
|
|
194
|
+
[test-url]: https://github.com/stdlib-js/array-full-like/actions/workflows/test.yml
|
|
195
|
+
|
|
196
|
+
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-full-like/main.svg
|
|
197
|
+
[coverage-url]: https://codecov.io/github/stdlib-js/array-full-like?branch=main
|
|
198
|
+
|
|
199
|
+
<!--
|
|
200
|
+
|
|
201
|
+
[dependencies-image]: https://img.shields.io/david/stdlib-js/array-full-like.svg
|
|
202
|
+
[dependencies-url]: https://david-dm.org/stdlib-js/array-full-like/main
|
|
203
|
+
|
|
204
|
+
-->
|
|
205
|
+
|
|
206
|
+
[umd]: https://github.com/umdjs/umd
|
|
207
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
208
|
+
|
|
209
|
+
[deno-url]: https://github.com/stdlib-js/array-full-like/tree/deno
|
|
210
|
+
[umd-url]: https://github.com/stdlib-js/array-full-like/tree/umd
|
|
211
|
+
[esm-url]: https://github.com/stdlib-js/array-full-like/tree/esm
|
|
212
|
+
|
|
213
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
214
|
+
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
215
|
+
|
|
216
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
217
|
+
|
|
218
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
219
|
+
|
|
220
|
+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-full-like/main/LICENSE
|
|
221
|
+
|
|
222
|
+
</section>
|
|
223
|
+
|
|
224
|
+
<!-- /.links -->
|
package/docs/repl.txt
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
{{alias}}( x[, dtype] )
|
|
3
|
+
Returns a filled array having the same length and data type as a provided
|
|
4
|
+
input array.
|
|
5
|
+
|
|
6
|
+
The function supports the following data types:
|
|
7
|
+
|
|
8
|
+
- float64: double-precision floating-point numbers (IEEE 754)
|
|
9
|
+
- float32: single-precision floating-point numbers (IEEE 754)
|
|
10
|
+
- complex128: double-precision complex floating-point numbers
|
|
11
|
+
- complex64: single-precision complex floating-point numbers
|
|
12
|
+
- int32: 32-bit two's complement signed integers
|
|
13
|
+
- uint32: 32-bit unsigned integers
|
|
14
|
+
- int16: 16-bit two's complement signed integers
|
|
15
|
+
- uint16: 16-bit unsigned integers
|
|
16
|
+
- int8: 8-bit two's complement signed integers
|
|
17
|
+
- uint8: 8-bit unsigned integers
|
|
18
|
+
- uint8c: 8-bit unsigned integers clamped to 0-255
|
|
19
|
+
- generic: generic JavaScript values
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
x: TypedArray|Array
|
|
24
|
+
Input array.
|
|
25
|
+
|
|
26
|
+
dtype: string (optional)
|
|
27
|
+
Data type. If not provided, the output array data type is inferred from
|
|
28
|
+
the input array.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
out: TypedArray|Array
|
|
33
|
+
Output array.
|
|
34
|
+
|
|
35
|
+
Examples
|
|
36
|
+
--------
|
|
37
|
+
> var x = new {{alias:@stdlib/array/float64}}( 2 );
|
|
38
|
+
> var y = {{alias}}( x, 1.0 )
|
|
39
|
+
<Float64Array>[ 1.0, 1.0 ]
|
|
40
|
+
> y = {{alias}}( x, 1.0, 'float32' )
|
|
41
|
+
<Float32Array>[ 1.0, 1.0 ]
|
|
42
|
+
|
|
43
|
+
See Also
|
|
44
|
+
--------
|
|
45
|
+
|