Skip to content

Commit 6b35fdd

Browse files
committed
Auto-generated commit
1 parent d004ab7 commit 6b35fdd

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ v = it.next().value;
177177

178178
The invoked function is provided four arguments:
179179

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.
184184

185185
```javascript
186186
function fcn( v, i ) {
@@ -244,6 +244,7 @@ var count = ctx.count;
244244
- If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use a custom iterator.
245245
- 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.
246246
- 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]).
247248

248249
</section>
249250

@@ -374,6 +375,8 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
374375

375376
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-to-view-iterator-right/main/LICENSE
376377

378+
[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64
379+
377380
<!-- <related-links> -->
378381

379382
[@stdlib/array/from-iterator]: https://github.com/stdlib-js/array-from-iterator

docs/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type Binary = ( value: any, index: number ) => any;
5858
* @param src - source array-like object
5959
* @returns iterator value
6060
*/
61-
type Tertiary = ( value: any, index: number, src: ArrayLike<any> ) => any;
61+
type Ternary = ( value: any, index: number, src: ArrayLike<any> ) => any;
6262

6363
/**
6464
* Map function invoked for each iterated value.
@@ -68,7 +68,7 @@ type Tertiary = ( value: any, index: number, src: ArrayLike<any> ) => any;
6868
* @param src - source array-like object
6969
* @returns iterator value
7070
*/
71-
type MapFunction = Nullary | Unary | Binary | Tertiary;
71+
type MapFunction = Nullary | Unary | Binary | Ternary;
7272

7373
/**
7474
* Returns an iterator which iterates from right to left over each element in an array-like object view.

lib/main.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var isFunction = require( '@stdlib/assert-is-function' );
2525
var isCollection = require( '@stdlib/assert-is-collection' );
2626
var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2727
var iteratorSymbol = require( '@stdlib/symbol-iterator' );
28+
var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
2829

2930

3031
// MAIN //
@@ -63,6 +64,7 @@ function arrayview2iteratorRight( src ) {
6364
var FLG;
6465
var fcn;
6566
var end;
67+
var get;
6668
var i;
6769
if ( !isCollection( src ) ) {
6870
throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + src + '`.' );
@@ -137,6 +139,9 @@ function arrayview2iteratorRight( src ) {
137139
if ( iteratorSymbol ) {
138140
setReadOnly( iter, iteratorSymbol, factory );
139141
}
142+
// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):
143+
get = arraylike2object( src ).getter;
144+
140145
return iter;
141146

142147
/**
@@ -153,7 +158,7 @@ function arrayview2iteratorRight( src ) {
153158
};
154159
}
155160
return {
156-
'value': fcn.call( thisArg, src[ i ], i, end-i-1, src ),
161+
'value': fcn.call( thisArg, get( src, i ), i, end-i-1, src ),
157162
'done': false
158163
};
159164
}
@@ -172,7 +177,7 @@ function arrayview2iteratorRight( src ) {
172177
};
173178
}
174179
return {
175-
'value': src[ i ],
180+
'value': get( src, i ),
176181
'done': false
177182
};
178183
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"url": "https://github.com/stdlib-js/stdlib/issues"
3838
},
3939
"dependencies": {
40+
"@stdlib/array-base-arraylike2object": "^0.0.x",
4041
"@stdlib/assert-is-collection": "^0.0.x",
4142
"@stdlib/assert-is-function": "^0.0.x",
4243
"@stdlib/assert-is-integer": "^0.0.x",

0 commit comments

Comments
 (0)