stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

feat: add `@stdlib/array/base/cusome-by-right`

Open GittyHarsha opened this issue 1 year ago • 5 comments

Resolves #2330

Description

What is the purpose of this pull request?

This pull request:

Adds implementation for @stdlib/array/base/cusome-by-right

Related Issues

Does this pull request have any related issues?

This pull request:

  • resolves #2330

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

GittyHarsha avatar Aug 12 '24 14:08 GittyHarsha

@kgryte, could you please review the PR. Alongside I have a few doubts,

  1. In the packages present in @stdlib/array/base, the function present in main.js doesn't check for invalid input parameters. For example, in the package @stdlib/array/base/cuany main.js file, it doesn't check whether the input is a collection.

However in @stdlib/utils/some-by-right, the API checks for invalid parameters.

Should I also implement this check for @stdlib/array/base/cusome-by-right? Here are the valid input parameters requirements for the API cusomeByRight( x, n, predicate[, thisArg] ). x: array or an accessor array n: positive integer predicate: a function that returns a boolean value

GittyHarsha avatar Aug 14 '24 09:08 GittyHarsha

@GittyHarsha We don't perform input validation in "base" implementations, so don't need to add such checks to this package. Thanks for asking!

Planeshifter avatar Aug 14 '24 14:08 Planeshifter

@Planeshifter, I made code changes to resolve the comments.

GittyHarsha avatar Aug 14 '24 15:08 GittyHarsha

I've only done a partial review, but this PR needs a more careful review before it can move forward.

kgryte avatar Aug 14 '24 19:08 kgryte

@kgryte and @Planeshifter, Along with cleaning up the code, here are some notable changes I have made,

  1. Typescript assign interface member definition:

assign<T, U extends Collection | AccessorArrayLike<unknown>, V = unknown>( x: Collection<T> | AccessorArrayLike<T>, n: number, y: U, stride: number, offset: number, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): U;

Here, Unlike other similar packages in array/base #assign API, in this package the input and output array can have different primitive data types. For example: the input array can be number[] and the output array of type (boolean | null)[].

in the definition, the primitive data type for the input array is T the output array is of type U where U extends Collection | AccessoryArrayLike<unknown> and the this parameter of the predicate function is of type V

I request your comment on this Thanks!

GittyHarsha avatar Aug 17 '24 02:08 GittyHarsha