@stdlib/array-to-circular-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
  # circarray2iterator
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 which repeatedly iterates over the elements of an array-like object.
26
26
 
@@ -179,10 +179,10 @@ v = it.next().value;
179
179
 
180
180
  The invoked function is provided four arguments:
181
181
 
182
- - `value`: iterated value
183
- - `index`: iterated value index
184
- - `n`: iteration count
185
- - `src`: source array-like object
182
+ - **value**: iterated value.
183
+ - **index**: iterated value index.
184
+ - **n**: iteration count.
185
+ - **src**: source array-like object.
186
186
 
187
187
  ```javascript
188
188
  function fcn( v, i ) {
@@ -246,6 +246,7 @@ var count = ctx.count;
246
246
  - If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use a custom iterator.
247
247
  - 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.
248
248
  - 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.
249
+ - The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]).
249
250
 
250
251
  </section>
251
252
 
@@ -301,6 +302,21 @@ while ( true ) {
301
302
 
302
303
  <!-- /.references -->
303
304
 
305
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
306
+
307
+ <section class="related">
308
+
309
+ * * *
310
+
311
+ ## See Also
312
+
313
+ - <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>
314
+ - <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>
315
+
316
+ </section>
317
+
318
+ <!-- /.related -->
319
+
304
320
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
305
321
 
306
322
 
@@ -314,6 +330,10 @@ This package is part of [stdlib][stdlib], a standard library for JavaScript and
314
330
 
315
331
  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].
316
332
 
333
+ #### Community
334
+
335
+ [![Chat][chat-image]][chat-url]
336
+
317
337
  ---
318
338
 
319
339
  ## License
@@ -323,7 +343,7 @@ See [LICENSE][stdlib-license].
323
343
 
324
344
  ## Copyright
325
345
 
326
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
346
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
327
347
 
328
348
  </section>
329
349
 
@@ -342,15 +362,39 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
342
362
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-to-circular-iterator/main.svg
343
363
  [coverage-url]: https://codecov.io/github/stdlib-js/array-to-circular-iterator?branch=main
344
364
 
345
- [dependencies-image]: https://img.shields.io/david/stdlib-js/array-to-circular-iterator
365
+ <!--
366
+
367
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/array-to-circular-iterator.svg
346
368
  [dependencies-url]: https://david-dm.org/stdlib-js/array-to-circular-iterator/main
347
369
 
370
+ -->
371
+
372
+ [umd]: https://github.com/umdjs/umd
373
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
374
+
375
+ [deno-url]: https://github.com/stdlib-js/array-to-circular-iterator/tree/deno
376
+ [umd-url]: https://github.com/stdlib-js/array-to-circular-iterator/tree/umd
377
+ [esm-url]: https://github.com/stdlib-js/array-to-circular-iterator/tree/esm
378
+
379
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
380
+ [chat-url]: https://gitter.im/stdlib-js/stdlib/
381
+
348
382
  [stdlib]: https://github.com/stdlib-js/stdlib
349
383
 
350
384
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
351
385
 
352
386
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-to-circular-iterator/main/LICENSE
353
387
 
388
+ [@stdlib/array/complex64]: https://www.npmjs.com/package/@stdlib/array-complex64
389
+
390
+ <!-- <related-links> -->
391
+
392
+ [@stdlib/array/to-iterator]: https://www.npmjs.com/package/@stdlib/array-to-iterator
393
+
394
+ [@stdlib/array/to-strided-iterator]: https://www.npmjs.com/package/@stdlib/array-to-strided-iterator
395
+
396
+ <!-- </related-links> -->
397
+
354
398
  </section>
355
399
 
356
400
  <!-- /.links -->
@@ -73,7 +73,7 @@ type Binary = ( value: any, index: number ) => any;
73
73
  * @param n - iteration count
74
74
  * @returns iterator value
75
75
  */
76
- type Tertiary = ( value: any, index: number, n: number ) => any;
76
+ type Ternary = ( value: any, index: number, n: number ) => any;
77
77
 
78
78
  /**
79
79
  * Map function invoked for each iterated value.
@@ -95,7 +95,7 @@ type Quaternary = ( value: any, index: number, n: number, src: ArrayLike<any> )
95
95
  * @param src - source array-like object
96
96
  * @returns iterator value
97
97
  */
98
- type MapFunction = Nullary | Unary | Binary | Tertiary | Quaternary;
98
+ type MapFunction = Nullary | Unary | Binary | Ternary | Quaternary;
99
99
 
100
100
  /**
101
101
  * Returns an iterator which repeatedly iterates over each element in an array-like object.
package/lib/main.js CHANGED
@@ -27,6 +27,7 @@ var isCollection = require( '@stdlib/assert-is-collection' );
27
27
  var isObject = require( '@stdlib/assert-is-plain-object' );
28
28
  var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;
29
29
  var iteratorSymbol = require( '@stdlib/symbol-iterator' );
30
+ var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
30
31
 
31
32
 
32
33
  // MAIN //
@@ -68,6 +69,7 @@ function circarray2iterator( src ) {
68
69
  var iter;
69
70
  var FLG;
70
71
  var fcn;
72
+ var get;
71
73
  var i;
72
74
  if ( !isCollection( src ) ) {
73
75
  throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + src + '`.' );
@@ -131,6 +133,9 @@ function circarray2iterator( src ) {
131
133
  if ( iteratorSymbol ) {
132
134
  setReadOnly( iter, iteratorSymbol, factory );
133
135
  }
136
+ // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):
137
+ get = arraylike2object( src ).getter;
138
+
134
139
  return iter;
135
140
 
136
141
  /**
@@ -148,7 +153,7 @@ function circarray2iterator( src ) {
148
153
  };
149
154
  }
150
155
  return {
151
- 'value': fcn.call( thisArg, src[ i ], i, count, src ),
156
+ 'value': fcn.call( thisArg, get( src, i ), i, count, src ),
152
157
  'done': false
153
158
  };
154
159
  }
@@ -171,7 +176,7 @@ function circarray2iterator( src ) {
171
176
  };
172
177
  }
173
178
  return {
174
- 'value': fcn.call( thisArg, src[ i ], i, count, src ),
179
+ 'value': fcn.call( thisArg, get( src, i ), i, count, src ),
175
180
  'done': false
176
181
  };
177
182
  }
@@ -191,7 +196,7 @@ function circarray2iterator( src ) {
191
196
  };
192
197
  }
193
198
  return {
194
- 'value': src[ i ],
199
+ 'value': get( src, i ),
195
200
  'done': false
196
201
  };
197
202
  }
@@ -214,7 +219,7 @@ function circarray2iterator( src ) {
214
219
  };
215
220
  }
216
221
  return {
217
- 'value': src[ i ],
222
+ 'value': get( src, i ),
218
223
  'done': false
219
224
  };
220
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/array-to-circular-iterator",
3
- "version": "0.0.2",
3
+ "version": "0.0.6",
4
4
  "description": "Create an iterator which repeatedly iterates over the elements of 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-circular-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-has-own-property": "^0.0.x",
41
42
  "@stdlib/assert-is-collection": "^0.0.x",
42
43
  "@stdlib/assert-is-function": "^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-circular-iterator/releases) for the changelog.