Skip to content

Commit 158ea3e

Browse files
feat: add logic to main
1 parent 9db1815 commit 158ea3e

File tree

1 file changed

+41
-0
lines changed
  • lib/node_modules/@stdlib/array/fixed-endian-factory/lib

1 file changed

+41
-0
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,47 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
675675
}
676676
return -1;
677677
});
678+
/**
679+
* A boolean value which is true if the value `searchElement` is found.
680+
*
681+
* @private
682+
* @name includes
683+
* @memberof TypedArray.prototype
684+
* @type {Function}
685+
* @param {*} searchElement - element to search for
686+
* @param {integer} [fromIndex=0] - starting index (inclusive)
687+
* @throws {TypeError} `this` must be a typed array instance
688+
* @throws {TypeError} second argument must be an integer
689+
* @returns {boolean} boolean indicating that `searchElement` is found
690+
*/
691+
setReadOnly( TypedArray.prototype, 'includes', function includes( searchElement, fromIndex ) {
692+
var buf;
693+
var i;
694+
695+
if ( !isTypedArray( this ) ) {
696+
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );
697+
}
698+
if ( arguments.length > 1 ) {
699+
if ( !isInteger( fromIndex ) ) {
700+
throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );
701+
}
702+
if ( fromIndex < 0 ) {
703+
fromIndex += this._length;
704+
if ( fromIndex < 0 ) {
705+
fromIndex = 0;
706+
}
707+
}
708+
} else {
709+
fromIndex = 0;
710+
}
711+
buf = this._buffer;
712+
for ( i = fromIndex; i < this._length; i++ ) {
713+
if ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {
714+
return true;
715+
}
716+
}
717+
return false;
718+
});
678719

679720
/**
680721
* Number of array elements.

0 commit comments

Comments
 (0)