|
20 | 20 |
|
21 | 21 | // MODULES //
|
22 | 22 |
|
| 23 | +var isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); |
23 | 24 | var isComplexLike = require( '@stdlib/assert/is-complex-like' );
|
24 | 25 | var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
|
25 | 26 | var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' );
|
26 | 27 | var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' );
|
27 | 28 | var isComplexTypedArray = require( '@stdlib/array/base/assert/is-complex-typed-array' );
|
28 | 29 | var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' );
|
29 |
| -var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); |
| 30 | +var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); |
30 | 31 | var isSameValue = require( '@stdlib/assert/is-same-value' );
|
31 | 32 | var real = require( '@stdlib/complex/float64/real' );
|
32 | 33 | var imag = require( '@stdlib/complex/float64/imag' );
|
@@ -63,30 +64,26 @@ function indexed( x, searchElement, fromIndex ) {
|
63 | 64 | * Returns the index of the first element which equals a provided search element according to the same value algorithm.
|
64 | 65 | *
|
65 | 66 | * @private
|
66 |
| -* @param {Object} x - input array object |
| 67 | +* @param {Collection} x - input array object |
67 | 68 | * @param {*} searchElement - search element
|
68 | 69 | * @param {NonNegativeInteger} fromIndex - starting index (inclusive)
|
69 | 70 | * @returns {integer} index
|
70 | 71 | *
|
71 | 72 | * @example
|
72 | 73 | * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
|
73 |
| -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); |
74 | 74 | *
|
75 |
| -* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) ); |
| 75 | +* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); |
76 | 76 | *
|
77 | 77 | * var idx = accessors( x, 2, 0 );
|
78 | 78 | * // returns 1
|
79 | 79 | */
|
80 | 80 | function accessors( x, searchElement, fromIndex ) {
|
81 |
| - var data; |
82 | 81 | var get;
|
83 | 82 | var i;
|
84 | 83 |
|
85 |
| - data = x.data; |
86 |
| - get = x.accessors[ 0 ]; |
87 |
| - |
88 |
| - for ( i = fromIndex; i < data.length; i++ ) { |
89 |
| - if ( isSameValue( searchElement, get( data, i ) ) ) { |
| 84 | + get = resolveGetter( x ); |
| 85 | + for ( i = fromIndex; i < x.length; i++ ) { |
| 86 | + if ( isSameValue( searchElement, get( x, i ) ) ) { |
90 | 87 | return i;
|
91 | 88 | }
|
92 | 89 | }
|
@@ -198,22 +195,20 @@ function boolean( x, searchElement, fromIndex ) {
|
198 | 195 | * // returns 1
|
199 | 196 | */
|
200 | 197 | function indexOfSameValue( x, searchElement, fromIndex ) {
|
201 |
| - var obj; |
202 | 198 | if ( fromIndex < 0 ) {
|
203 | 199 | fromIndex += x.length;
|
204 | 200 | if ( fromIndex < 0 ) {
|
205 | 201 | fromIndex = 0;
|
206 | 202 | }
|
207 | 203 | }
|
208 |
| - obj = arraylike2object( x ); |
209 |
| - if ( obj.accessorProtocol ) { |
| 204 | + if ( isAccessorArray( x ) ) { |
210 | 205 | if ( isComplexTypedArray( x ) ) {
|
211 | 206 | return complex( x, searchElement, fromIndex );
|
212 | 207 | }
|
213 | 208 | if ( isBooleanArray( x ) ) {
|
214 | 209 | return boolean( x, searchElement, fromIndex );
|
215 | 210 | }
|
216 |
| - return accessors( obj, searchElement, fromIndex ); |
| 211 | + return accessors( x, searchElement, fromIndex ); |
217 | 212 | }
|
218 | 213 | return indexed( x, searchElement, fromIndex );
|
219 | 214 | }
|
|
0 commit comments