@stdlib/array-to-view-iterator 0.0.2 → 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
 
@@ -309,6 +327,10 @@ This package is part of [stdlib][stdlib], a standard library for JavaScript and
309
327
 
310
328
  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].
311
329
 
330
+ #### Community
331
+
332
+ [![Chat][chat-image]][chat-url]
333
+
312
334
  ---
313
335
 
314
336
  ## License
@@ -318,7 +340,7 @@ See [LICENSE][stdlib-license].
318
340
 
319
341
  ## Copyright
320
342
 
321
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
343
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
322
344
 
323
345
  </section>
324
346
 
@@ -337,15 +359,43 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
337
359
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-to-view-iterator/main.svg
338
360
  [coverage-url]: https://codecov.io/github/stdlib-js/array-to-view-iterator?branch=main
339
361
 
340
- [dependencies-image]: https://img.shields.io/david/stdlib-js/array-to-view-iterator
362
+ <!--
363
+
364
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/array-to-view-iterator.svg
341
365
  [dependencies-url]: https://david-dm.org/stdlib-js/array-to-view-iterator/main
342
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
+
376
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
377
+ [chat-url]: https://gitter.im/stdlib-js/stdlib/
378
+
343
379
  [stdlib]: https://github.com/stdlib-js/stdlib
344
380
 
345
381
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
346
382
 
347
383
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-to-view-iterator/main/LICENSE
348
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
+
349
399
  </section>
350
400
 
351
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.2",
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": {
@@ -28,7 +28,7 @@
28
28
  "examples": "make examples",
29
29
  "benchmark": "make benchmark"
30
30
  },
31
- "homepage": "https://github.com/stdlib-js/stdlib",
31
+ "homepage": "https://stdlib.io",
32
32
  "repository": {
33
33
  "type": "git",
34
34
  "url": "git://github.com/stdlib-js/array-to-view-iterator.git"
@@ -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",
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- # CHANGELOG
2
-
3
- > Package changelog.
4
-
5
- See [GitHub Releases](https://github.com/stdlib-js/array-to-view-iterator/releases) for the changelog.