@stdlib/iter-to-array-view 0.0.6 → 0.0.7

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/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2021 The Stdlib Authors.
1
+ Copyright (c) 2016-2022 The Stdlib Authors.
package/README.md CHANGED
@@ -20,7 +20,7 @@ limitations under the License.
20
20
 
21
21
  # iterator2arrayview
22
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]
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
24
 
25
25
  > Fill an array-like object view with values returned from an iterator.
26
26
 
@@ -132,9 +132,9 @@ var arr = iterator2arrayview( iter, new Float64Array( 4 ), fcn );
132
132
 
133
133
  The invoked function is provided three arguments:
134
134
 
135
- - `value`: iterated value
136
- - `index`: destination index
137
- - `n`: iteration count (zero-based)
135
+ - **value**: iterated value.
136
+ - **index**: destination index.
137
+ - **n**: iteration count (zero-based).
138
138
 
139
139
  ```javascript
140
140
  var Uint8Array = require( '@stdlib/array-uint8' );
@@ -183,6 +183,7 @@ var count = ctx.count;
183
183
  ## Notes
184
184
 
185
185
  - Iteration stops when an output array view is full **or** an iterator finishes; whichever comes first.
186
+ - The function supports output array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]).
186
187
 
187
188
  </section>
188
189
 
@@ -229,6 +230,22 @@ for ( i = 0; i < arr.length; i++ ) {
229
230
 
230
231
  <!-- /.references -->
231
232
 
233
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
234
+
235
+ <section class="related">
236
+
237
+ * * *
238
+
239
+ ## See Also
240
+
241
+ - <span class="package-name">[`@stdlib/array/from-iterator`][@stdlib/array/from-iterator]</span><span class="delimiter">: </span><span class="description">create (or fill) an array from an iterator.</span>
242
+ - <span class="package-name">[`@stdlib/array/to-view-iterator`][@stdlib/array/to-view-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object view.</span>
243
+ - <span class="package-name">[`@stdlib/iter/to-array-view-right`][@stdlib/iter/to-array-view-right]</span><span class="delimiter">: </span><span class="description">fill an array-like object view from right to left with values returned from an iterator.</span>
244
+
245
+ </section>
246
+
247
+ <!-- /.related -->
248
+
232
249
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
233
250
 
234
251
 
@@ -255,7 +272,7 @@ See [LICENSE][stdlib-license].
255
272
 
256
273
  ## Copyright
257
274
 
258
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
275
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
259
276
 
260
277
  </section>
261
278
 
@@ -274,9 +291,20 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
274
291
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/iter-to-array-view/main.svg
275
292
  [coverage-url]: https://codecov.io/github/stdlib-js/iter-to-array-view?branch=main
276
293
 
294
+ <!--
295
+
277
296
  [dependencies-image]: https://img.shields.io/david/stdlib-js/iter-to-array-view.svg
278
297
  [dependencies-url]: https://david-dm.org/stdlib-js/iter-to-array-view/main
279
298
 
299
+ -->
300
+
301
+ [umd]: https://github.com/umdjs/umd
302
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
303
+
304
+ [deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno
305
+ [umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd
306
+ [esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm
307
+
280
308
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
281
309
  [chat-url]: https://gitter.im/stdlib-js/stdlib/
282
310
 
@@ -286,6 +314,18 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
286
314
 
287
315
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/iter-to-array-view/main/LICENSE
288
316
 
317
+ [@stdlib/array/complex64]: https://www.npmjs.com/package/@stdlib/array-complex64
318
+
319
+ <!-- <related-links> -->
320
+
321
+ [@stdlib/array/from-iterator]: https://www.npmjs.com/package/@stdlib/array-from-iterator
322
+
323
+ [@stdlib/array/to-view-iterator]: https://www.npmjs.com/package/@stdlib/array-to-view-iterator
324
+
325
+ [@stdlib/iter/to-array-view-right]: https://www.npmjs.com/package/@stdlib/iter-to-array-view-right
326
+
327
+ <!-- </related-links> -->
328
+
289
329
  </section>
290
330
 
291
331
  <!-- /.links -->
@@ -59,7 +59,7 @@ type Binary = ( value: any, index: number ) => any;
59
59
  * @param src - source array-like object
60
60
  * @returns iterator value
61
61
  */
62
- type Tertiary = ( value: any, index: number, src: ArrayLike<any> ) => any;
62
+ type Ternary = ( value: any, index: number, src: ArrayLike<any> ) => any;
63
63
 
64
64
  /**
65
65
  * Map function invoked for each iterated value.
@@ -69,7 +69,7 @@ type Tertiary = ( value: any, index: number, src: ArrayLike<any> ) => any;
69
69
  * @param src - source array-like object
70
70
  * @returns iterator value
71
71
  */
72
- type MapFunction = Nullary | Unary | Binary | Tertiary;
72
+ type MapFunction = Nullary | Unary | Binary | Ternary;
73
73
 
74
74
  /**
75
75
  * Fills an array-like object view with values returned from an iterator.
package/lib/main.js CHANGED
@@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' );
24
24
  var isCollection = require( '@stdlib/assert-is-collection' );
25
25
  var isIteratorLike = require( '@stdlib/assert-is-iterator-like' );
26
26
  var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
27
- var hasOwnProp = require( '@stdlib/assert-has-own-property' );
27
+ var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
28
28
 
29
29
 
30
30
  // MAIN //
@@ -62,6 +62,7 @@ function iterator2arrayview( iterator, out ) {
62
62
  var begin;
63
63
  var end;
64
64
  var fcn;
65
+ var set;
65
66
  var i;
66
67
  var v;
67
68
 
@@ -139,29 +140,26 @@ function iterator2arrayview( iterator, out ) {
139
140
  begin = 0;
140
141
  }
141
142
  }
143
+ set = arraylike2object( out ).setter;
142
144
  i = begin - 1;
143
145
  if ( fcn ) {
144
146
  while ( i < end-1 ) {
145
147
  i += 1;
146
148
  v = iterator.next();
147
- if ( hasOwnProp( v, 'value' ) ) {
148
- out[ i ] = fcn.call( thisArg, v.value, i, i-begin );
149
- }
150
149
  if ( v.done ) {
151
150
  break;
152
151
  }
152
+ set( out, i, fcn.call( thisArg, v.value, i, i-begin ) );
153
153
  }
154
154
  return out;
155
155
  }
156
156
  while ( i < end-1 ) {
157
157
  i += 1;
158
158
  v = iterator.next();
159
- if ( hasOwnProp( v, 'value' ) ) {
160
- out[ i ] = v.value;
161
- }
162
159
  if ( v.done ) {
163
160
  break;
164
161
  }
162
+ set( out, i, v.value );
165
163
  }
166
164
  return out;
167
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/iter-to-array-view",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Fill an array-like object view with values returned from an iterator.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,7 +37,7 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/assert-has-own-property": "^0.0.x",
40
+ "@stdlib/array-base-arraylike2object": "^0.0.x",
41
41
  "@stdlib/assert-is-collection": "^0.0.x",
42
42
  "@stdlib/assert-is-function": "^0.0.x",
43
43
  "@stdlib/assert-is-integer": "^0.0.x",
@@ -45,11 +45,14 @@
45
45
  "@stdlib/types": "^0.0.x"
46
46
  },
47
47
  "devDependencies": {
48
+ "@stdlib/array-complex128": "^0.0.x",
48
49
  "@stdlib/array-float64": "^0.0.x",
49
50
  "@stdlib/array-to-iterator": "^0.0.x",
50
51
  "@stdlib/bench": "^0.0.x",
52
+ "@stdlib/complex-float64": "^0.0.x",
51
53
  "@stdlib/math-base-assert-is-nan": "^0.0.x",
52
54
  "@stdlib/random-iter-randu": "^0.0.x",
55
+ "@stdlib/strided-base-reinterpret-complex128": "^0.0.x",
53
56
  "@stdlib/utils-noop": "^0.0.x",
54
57
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
55
58
  "istanbul": "^0.4.1",