@stdlib/array-to-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
  # array2iterator
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.
26
26
 
@@ -101,9 +101,9 @@ v = it.next().value;
101
101
 
102
102
  The invoked function is provided three arguments:
103
103
 
104
- - `value`: iterated value
105
- - `index`: iterated value index
106
- - `src`: source array-like object
104
+ - **value**: iterated value.
105
+ - **index**: iterated value index.
106
+ - **src**: source array-like object.
107
107
 
108
108
  ```javascript
109
109
  function fcn( v, i ) {
@@ -167,6 +167,7 @@ var count = ctx.count;
167
167
  - If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use [`@stdlib/array/to-sparse-iterator`][@stdlib/array/to-sparse-iterator].
168
168
  - 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.
169
169
  - 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.
170
+ - The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]).
170
171
 
171
172
  </section>
172
173
 
@@ -219,6 +220,23 @@ while ( true ) {
219
220
 
220
221
  <!-- /.references -->
221
222
 
223
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
224
+
225
+ <section class="related">
226
+
227
+ * * *
228
+
229
+ ## See Also
230
+
231
+ - <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>
232
+ - <span class="package-name">[`@stdlib/array/to-circular-iterator`][@stdlib/array/to-circular-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator which repeatedly iterates over the elements of an array-like object.</span>
233
+ - <span class="package-name">[`@stdlib/array/to-iterator-right`][@stdlib/array/to-iterator-right]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object, iterating from right to left.</span>
234
+ - <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>
235
+
236
+ </section>
237
+
238
+ <!-- /.related -->
239
+
222
240
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
223
241
 
224
242
 
@@ -232,6 +250,10 @@ This package is part of [stdlib][stdlib], a standard library for JavaScript and
232
250
 
233
251
  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].
234
252
 
253
+ #### Community
254
+
255
+ [![Chat][chat-image]][chat-url]
256
+
235
257
  ---
236
258
 
237
259
  ## License
@@ -241,7 +263,7 @@ See [LICENSE][stdlib-license].
241
263
 
242
264
  ## Copyright
243
265
 
244
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
266
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
245
267
 
246
268
  </section>
247
269
 
@@ -260,16 +282,44 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
260
282
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-to-iterator/main.svg
261
283
  [coverage-url]: https://codecov.io/github/stdlib-js/array-to-iterator?branch=main
262
284
 
263
- [dependencies-image]: https://img.shields.io/david/stdlib-js/array-to-iterator
285
+ <!--
286
+
287
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/array-to-iterator.svg
264
288
  [dependencies-url]: https://david-dm.org/stdlib-js/array-to-iterator/main
265
289
 
290
+ -->
291
+
292
+ [umd]: https://github.com/umdjs/umd
293
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
294
+
295
+ [deno-url]: https://github.com/stdlib-js/array-to-iterator/tree/deno
296
+ [umd-url]: https://github.com/stdlib-js/array-to-iterator/tree/umd
297
+ [esm-url]: https://github.com/stdlib-js/array-to-iterator/tree/esm
298
+
299
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
300
+ [chat-url]: https://gitter.im/stdlib-js/stdlib/
301
+
266
302
  [stdlib]: https://github.com/stdlib-js/stdlib
267
303
 
268
304
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
269
305
 
270
306
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-to-iterator/main/LICENSE
271
307
 
272
- [@stdlib/array/to-sparse-iterator]: https://github.com/stdlib-js/array-to-sparse-iterator
308
+ [@stdlib/array/to-sparse-iterator]: https://www.npmjs.com/package/@stdlib/array-to-sparse-iterator
309
+
310
+ [@stdlib/array/complex64]: https://www.npmjs.com/package/@stdlib/array-complex64
311
+
312
+ <!-- <related-links> -->
313
+
314
+ [@stdlib/array/from-iterator]: https://www.npmjs.com/package/@stdlib/array-from-iterator
315
+
316
+ [@stdlib/array/to-circular-iterator]: https://www.npmjs.com/package/@stdlib/array-to-circular-iterator
317
+
318
+ [@stdlib/array/to-iterator-right]: https://www.npmjs.com/package/@stdlib/array-to-iterator-right
319
+
320
+ [@stdlib/array/to-strided-iterator]: https://www.npmjs.com/package/@stdlib/array-to-strided-iterator
321
+
322
+ <!-- </related-links> -->
273
323
 
274
324
  </section>
275
325
 
@@ -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.
package/lib/main.js CHANGED
@@ -24,6 +24,7 @@ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-propert
24
24
  var isFunction = require( '@stdlib/assert-is-function' );
25
25
  var isCollection = require( '@stdlib/assert-is-collection' );
26
26
  var iteratorSymbol = require( '@stdlib/symbol-iterator' );
27
+ var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
27
28
 
28
29
 
29
30
  // MAIN //
@@ -57,6 +58,7 @@ function array2iterator( src ) {
57
58
  var iter;
58
59
  var FLG;
59
60
  var fcn;
61
+ var get;
60
62
  var i;
61
63
  if ( !isCollection( src ) ) {
62
64
  throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + src + '`.' );
@@ -83,6 +85,9 @@ function array2iterator( src ) {
83
85
  if ( iteratorSymbol ) {
84
86
  setReadOnly( iter, iteratorSymbol, factory );
85
87
  }
88
+ // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):
89
+ get = arraylike2object( src ).getter;
90
+
86
91
  return iter;
87
92
 
88
93
  /**
@@ -99,7 +104,7 @@ function array2iterator( src ) {
99
104
  };
100
105
  }
101
106
  return {
102
- 'value': fcn.call( thisArg, src[ i ], i, src ),
107
+ 'value': fcn.call( thisArg, get( src, i ), i, src ),
103
108
  'done': false
104
109
  };
105
110
  }
@@ -118,7 +123,7 @@ function array2iterator( src ) {
118
123
  };
119
124
  }
120
125
  return {
121
- 'value': src[ i ],
126
+ 'value': get( src, i ),
122
127
  'done': false
123
128
  };
124
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/array-to-iterator",
3
- "version": "0.0.2",
3
+ "version": "0.0.6",
4
4
  "description": "Create an iterator from an array-like object.",
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-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/symbol-iterator": "^0.0.x",
@@ -44,9 +45,13 @@
44
45
  "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x"
45
46
  },
46
47
  "devDependencies": {
48
+ "@stdlib/array-complex64": "^0.0.x",
47
49
  "@stdlib/array-float64": "^0.0.x",
48
50
  "@stdlib/assert-is-iterator-like": "^0.0.x",
49
51
  "@stdlib/bench": "^0.0.x",
52
+ "@stdlib/complex-float32": "^0.0.x",
53
+ "@stdlib/complex-imagf": "^0.0.x",
54
+ "@stdlib/complex-realf": "^0.0.x",
50
55
  "@stdlib/math-base-assert-is-nan": "^0.0.x",
51
56
  "@stdlib/random-base-randu": "^0.0.x",
52
57
  "@stdlib/utils-inmap": "^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-iterator/releases) for the changelog.