@stdlib/array-to-view-iterator 0.0.5 → 0.0.6

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
  # arrayview2iterator
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
  > Create an iterator from an array-like object view.
26
26
 
@@ -177,10 +177,10 @@ v = it.next().value;
177
177
 
178
178
  The invoked function is provided four arguments:
179
179
 
180
- - `value`: iterated value
181
- - `index`: iterated value index
182
- - `n`: iteration count (zero-based)
183
- - `src`: source array-like object
180
+ - **value**: iterated value.
181
+ - **index**: iterated value index.
182
+ - **n**: iteration count (zero-based).
183
+ - **src**: source array-like object.
184
184
 
185
185
  ```javascript
186
186
  function fcn( v, i ) {
@@ -244,6 +244,7 @@ var count = ctx.count;
244
244
  - If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use a custom iterator.
245
245
  - A returned iterator does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an iterator. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned iterator.
246
246
  - In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined iterator, invoke this method directly.
247
+ - The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]).
247
248
 
248
249
  </section>
249
250
 
@@ -296,6 +297,23 @@ while ( true ) {
296
297
 
297
298
  <!-- /.references -->
298
299
 
300
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
301
+
302
+ <section class="related">
303
+
304
+ * * *
305
+
306
+ ## See Also
307
+
308
+ - <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>
309
+ - <span class="package-name">[`@stdlib/array/to-iterator`][@stdlib/array/to-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object.</span>
310
+ - <span class="package-name">[`@stdlib/array/to-strided-iterator`][@stdlib/array/to-strided-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from a strided array-like object.</span>
311
+ - <span class="package-name">[`@stdlib/array/to-view-iterator-right`][@stdlib/array/to-view-iterator-right]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object view, iterating from right to left.</span>
312
+
313
+ </section>
314
+
315
+ <!-- /.related -->
316
+
299
317
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
300
318
 
301
319
 
@@ -322,7 +340,7 @@ See [LICENSE][stdlib-license].
322
340
 
323
341
  ## Copyright
324
342
 
325
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
343
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
326
344
 
327
345
  </section>
328
346
 
@@ -341,9 +359,20 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
341
359
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-to-view-iterator/main.svg
342
360
  [coverage-url]: https://codecov.io/github/stdlib-js/array-to-view-iterator?branch=main
343
361
 
362
+ <!--
363
+
344
364
  [dependencies-image]: https://img.shields.io/david/stdlib-js/array-to-view-iterator.svg
345
365
  [dependencies-url]: https://david-dm.org/stdlib-js/array-to-view-iterator/main
346
366
 
367
+ -->
368
+
369
+ [umd]: https://github.com/umdjs/umd
370
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
371
+
372
+ [deno-url]: https://github.com/stdlib-js/array-to-view-iterator/tree/deno
373
+ [umd-url]: https://github.com/stdlib-js/array-to-view-iterator/tree/umd
374
+ [esm-url]: https://github.com/stdlib-js/array-to-view-iterator/tree/esm
375
+
347
376
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
348
377
  [chat-url]: https://gitter.im/stdlib-js/stdlib/
349
378
 
@@ -353,6 +382,20 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
353
382
 
354
383
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-to-view-iterator/main/LICENSE
355
384
 
385
+ [@stdlib/array/complex64]: https://www.npmjs.com/package/@stdlib/array-complex64
386
+
387
+ <!-- <related-links> -->
388
+
389
+ [@stdlib/array/from-iterator]: https://www.npmjs.com/package/@stdlib/array-from-iterator
390
+
391
+ [@stdlib/array/to-iterator]: https://www.npmjs.com/package/@stdlib/array-to-iterator
392
+
393
+ [@stdlib/array/to-strided-iterator]: https://www.npmjs.com/package/@stdlib/array-to-strided-iterator
394
+
395
+ [@stdlib/array/to-view-iterator-right]: https://www.npmjs.com/package/@stdlib/array-to-view-iterator-right
396
+
397
+ <!-- </related-links> -->
398
+
356
399
  </section>
357
400
 
358
401
  <!-- /.links -->
package/docs/repl.txt CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  {{alias}}( src[, begin[, end]][, mapFcn[, thisArg]] )
3
- Returns an iterator which iterates over the elements of an array-like
4
- object view.
3
+ Returns an iterator which iterates over the elements of an array-like object
4
+ view.
5
5
 
6
6
  When invoked, an input function is provided four arguments:
7
7
 
@@ -58,7 +58,7 @@ type Binary = ( value: any, index: number ) => any;
58
58
  * @param src - source array-like object
59
59
  * @returns iterator value
60
60
  */
61
- type Tertiary = ( value: any, index: number, src: ArrayLike<any> ) => any;
61
+ type Ternary = ( value: any, index: number, src: ArrayLike<any> ) => any;
62
62
 
63
63
  /**
64
64
  * Map function invoked for each iterated value.
@@ -68,7 +68,7 @@ type Tertiary = ( value: any, index: number, src: ArrayLike<any> ) => any;
68
68
  * @param src - source array-like object
69
69
  * @returns iterator value
70
70
  */
71
- type MapFunction = Nullary | Unary | Binary | Tertiary;
71
+ type MapFunction = Nullary | Unary | Binary | Ternary;
72
72
 
73
73
  /**
74
74
  * Returns an iterator which iterates over each element in an array-like object view.
package/lib/main.js CHANGED
@@ -25,6 +25,7 @@ var isFunction = require( '@stdlib/assert-is-function' );
25
25
  var isCollection = require( '@stdlib/assert-is-collection' );
26
26
  var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
27
27
  var iteratorSymbol = require( '@stdlib/symbol-iterator' );
28
+ var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
28
29
 
29
30
 
30
31
  // MAIN //
@@ -63,6 +64,7 @@ function arrayview2iterator( src ) {
63
64
  var FLG;
64
65
  var fcn;
65
66
  var end;
67
+ var get;
66
68
  var i;
67
69
  if ( !isCollection( src ) ) {
68
70
  throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + src + '`.' );
@@ -137,6 +139,9 @@ function arrayview2iterator( src ) {
137
139
  if ( iteratorSymbol ) {
138
140
  setReadOnly( iter, iteratorSymbol, factory );
139
141
  }
142
+ // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):
143
+ get = arraylike2object( src ).getter;
144
+
140
145
  return iter;
141
146
 
142
147
  /**
@@ -153,7 +158,7 @@ function arrayview2iterator( src ) {
153
158
  };
154
159
  }
155
160
  return {
156
- 'value': fcn.call( thisArg, src[ i ], i, i-begin, src ),
161
+ 'value': fcn.call( thisArg, get( src, i ), i, i-begin, src ),
157
162
  'done': false
158
163
  };
159
164
  }
@@ -172,7 +177,7 @@ function arrayview2iterator( src ) {
172
177
  };
173
178
  }
174
179
  return {
175
- 'value': src[ i ],
180
+ 'value': get( src, i ),
176
181
  'done': false
177
182
  };
178
183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/array-to-view-iterator",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Create an iterator from an array-like object view.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,6 +37,7 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
+ "@stdlib/array-base-arraylike2object": "^0.0.x",
40
41
  "@stdlib/assert-is-collection": "^0.0.x",
41
42
  "@stdlib/assert-is-function": "^0.0.x",
42
43
  "@stdlib/assert-is-integer": "^0.0.x",