feat: add `@stdlib/array/base/cusome-by-right`
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.
- [x] Read, understood, and followed the contributing guidelines.
@stdlib-js/reviewers
@kgryte, could you please review the PR. Alongside I have a few doubts,
- 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/cuanymain.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 We don't perform input validation in "base" implementations, so don't need to add such checks to this package. Thanks for asking!
@Planeshifter, I made code changes to resolve the comments.
I've only done a partial review, but this PR needs a more careful review before it can move forward.
@kgryte and @Planeshifter, Along with cleaning up the code, here are some notable changes I have made,
- 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!