Skip to content

Commit 913cb02

Browse files
chore: update includes method place
changed its place before indexOf so file ordered alphatically
1 parent 21225c3 commit 913cb02

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

lib/node_modules/@stdlib/array/fixed-endian-factory/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,30 @@ var v = arr.get( 100 );
483483
// returns undefined
484484
```
485485

486+
<a name="method-includes"></a>
487+
488+
#### TypedArrayFE.prototype.includes( searchElement\[, fromIndex] )
489+
490+
Returns a boolean indicating whether an array includes a provided value.
491+
492+
```javascript
493+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
494+
495+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] );
496+
497+
var idx = arr.includes( 2.0 );
498+
// returns true
499+
500+
idx = arr.includes( 2.0, 2 );
501+
// returns true
502+
503+
idx = arr.includes( 2.0, -4 );
504+
// returns true
505+
506+
idx = arr.includes( 5.0 );
507+
// returns false
508+
```
509+
486510
<a name="method-index-of"></a>
487511

488512
#### TypedArrayFE.prototype.indexOf( searchElement\[, fromIndex] )
@@ -515,30 +539,6 @@ var idx = arr.indexOf( 5.0 );
515539
// returns -1
516540
```
517541

518-
<a name="method-includes"></a>
519-
520-
#### TypedArrayFE.prototype.includes( searchElement\[, fromIndex] )
521-
522-
Returns a boolean indicating whether an array includes a provided value.
523-
524-
```javascript
525-
var Float64ArrayFE = fixedEndianFactory( 'float64' );
526-
527-
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] );
528-
529-
var idx = arr.includes( 2.0 );
530-
// returns true
531-
532-
idx = arr.includes( 2.0, 2 );
533-
// returns true
534-
535-
idx = arr.includes( 2.0, -4 );
536-
// returns true
537-
538-
idx = arr.includes( 5.0 );
539-
// returns false
540-
```
541-
542542
<a name="method-map"></a>
543543

544544
#### TypedArray.prototype.map( callbackFn\[, thisArg] )

lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -635,19 +635,19 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
635635
});
636636

637637
/**
638-
* Returns the index of the first occurrence of a given element.
638+
* Returns a boolean indicating whether an array includes a provided value.
639639
*
640640
* @private
641-
* @name indexOf
641+
* @name includes
642642
* @memberof TypedArray.prototype
643643
* @type {Function}
644-
* @param {*} searchElement - element to search for
644+
* @param {*} searchElement - search element
645645
* @param {integer} [fromIndex=0] - starting index (inclusive)
646646
* @throws {TypeError} `this` must be a typed array instance
647647
* @throws {TypeError} second argument must be an integer
648-
* @returns {integer} index or -1
648+
* @returns {boolean} boolean indicating whether an array includes a provided value
649649
*/
650-
setReadOnly( TypedArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {
650+
setReadOnly( TypedArray.prototype, 'includes', function includes( searchElement, fromIndex ) {
651651
var buf;
652652
var i;
653653

@@ -670,26 +670,26 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
670670
buf = this._buffer;
671671
for ( i = fromIndex; i < this._length; i++ ) {
672672
if ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {
673-
return i;
673+
return true;
674674
}
675675
}
676-
return -1;
676+
return false;
677677
});
678678

679679
/**
680-
* Returns a boolean indicating whether an array includes a provided value.
680+
* Returns the index of the first occurrence of a given element.
681681
*
682682
* @private
683-
* @name includes
683+
* @name indexOf
684684
* @memberof TypedArray.prototype
685685
* @type {Function}
686-
* @param {*} searchElement - search element
686+
* @param {*} searchElement - element to search for
687687
* @param {integer} [fromIndex=0] - starting index (inclusive)
688688
* @throws {TypeError} `this` must be a typed array instance
689689
* @throws {TypeError} second argument must be an integer
690-
* @returns {boolean} boolean indicating whether an array includes a provided value
690+
* @returns {integer} index or -1
691691
*/
692-
setReadOnly( TypedArray.prototype, 'includes', function includes( searchElement, fromIndex ) {
692+
setReadOnly( TypedArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {
693693
var buf;
694694
var i;
695695

@@ -712,10 +712,10 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
712712
buf = this._buffer;
713713
for ( i = fromIndex; i < this._length; i++ ) {
714714
if ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {
715-
return true;
715+
return i;
716716
}
717717
}
718-
return false;
718+
return -1;
719719
});
720720

721721
/**

0 commit comments

Comments
 (0)