Skip to content

Conversation

rohitashbishnoi91
Copy link

Resolves #3141

Description

What is the purpose of this pull request?

This pull request:

  • adds the find method to the array/fixed-endian-factory

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

Copy link
Contributor

@stdlib-bot stdlib-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hi there! 👋

And thank you for opening your first pull request! We will review it shortly. 🏃 💨

@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
array/fixed-endian-factory $\color{red}798/1055$
$\color{green}+75.64\%$
$\color{red}53/61$
$\color{green}+86.89\%$
$\color{red}12/23$
$\color{green}+52.17\%$
$\color{red}798/1055$
$\color{green}+75.64\%$

The above coverage report was generated for the changes in this PR.

* @throws {TypeError} `this` must be a typed array instance
* @returns {*} The value of the first element in the array that satisfies the testing function. Otherwise, undefined.
*/
setReadOnly(TypedArray.prototype, 'find', function find(predicate, thisArg) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setReadOnly(TypedArray.prototype, 'find', function find(predicate, thisArg) {
setReadOnly( TypedArray.prototype, 'find', function find( predicate, thisArg ) {

setReadOnly(TypedArray.prototype, 'find', function find(predicate, thisArg) {
var value;
var i;
if (!isTypedArray(this)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isTypedArray(this)) {
if ( !isTypedArray(this ) ) {

Comment on lines +588 to +596
throw new TypeError('invalid invocation. `this` is not a typed array instance.');
}
if (typeof predicate !== 'function') {
throw new TypeError(format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
}
for (i = 0; i < this._length; i++) {
value = this._buffer[GETTER](i * BYTES_PER_ELEMENT, this._isLE);
if (predicate.call(thisArg, value, i, this)) {
return value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new TypeError('invalid invocation. `this` is not a typed array instance.');
}
if (typeof predicate !== 'function') {
throw new TypeError(format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
}
for (i = 0; i < this._length; i++) {
value = this._buffer[GETTER](i * BYTES_PER_ELEMENT, this._isLE);
if (predicate.call(thisArg, value, i, this)) {
return value;
throw new TypeError( 'invalid invocation. `this` is not a typed array instance.' );
}
if ( typeof predicate !== 'function' ) {
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
}
for ( i = 0; i < this._length; i++ ) {
value = this._buffer[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE );
if (predicate.call( thisArg, value, i, this ) ) {
return value;

please do same for all your changes

@abhishekblue
Copy link
Contributor

Would it be okay if I take over and complete the requested changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add find method to array/fixed-endian-factory

4 participants