-
-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add slice
method to array/fixed-endian-factory
#3188
base: develop
Are you sure you want to change the base?
feat: add slice
method to array/fixed-endian-factory
#3188
Conversation
Hello! Thank you for your contribution to stdlib. We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
This acknowledgment confirms that you've read the guidelines, which include:
We can't review or accept contributions without this acknowledgment. Thank you for your understanding and cooperation. We look forward to reviewing your contribution! |
kindly review this PR!! |
There was a problem hiding this 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. 🏃 💨
Coverage Report
The above coverage report was generated for the changes in this PR. |
/stdlib merge |
slice
method to array/fixed-endian-factory
…method_to_array/fixed-endian-factory
/stdlib lint-autofix |
@@ -493,6 +493,22 @@ var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); | |||
var str = arr.toString(); | |||
// returns '1,2,3' | |||
``` | |||
#### TypedArrayFE.prototype.slice() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/stdlib-js/stdlib/tree/4b1d77d2bd001d5970ce93230765a579fb41349d/lib/node_modules/%40stdlib/array/bool#booleanarrayprototypeslice-start-end- for what is excepted in terms of documentation. Additionally, this documentation should be inserted such that methods are listed in alphabetical order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing a separate benchmark file which evaluates performance as a function of array length. E.g., https://github.com/stdlib-js/stdlib/blob/4b1d77d2bd001d5970ce93230765a579fb41349d/lib/node_modules/%40stdlib/array/bool/benchmark/benchmark.slice.length.js
* @returns {TypedArray} string representation | ||
*/ | ||
|
||
setReadOnly( TypedArray.prototype, 'slice', function slice() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert this method so that methods are listed in alphabetical order.
@@ -723,6 +723,54 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli | |||
return out.join( ',' ); | |||
}); | |||
|
|||
/** | |||
* return sliced TypedArray. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code should look very similar to
* Copies a portion of a typed array to a new typed array. |
* @memberof TypedArray.prototype | ||
* @type {Function} | ||
* @throws {TypeError} `this` must be a typed array instance | ||
* @returns {TypedArray} string representation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description is incorrect.
/** | ||
* return sliced TypedArray. | ||
* | ||
* @private |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off.
if (value2 === null || nargs === 1) { | ||
value2 = this._length; | ||
} | ||
if ( nargs < 0 || nargs > 2 || !isNonNegativeInteger( value1 ) || !isNonNegativeInteger( value2 ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should accept negative integers, not just nonnegative integers.
if ( !isTypedArray( this ) ) { | ||
throw new TypeError(format('invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0]], CTOR_NAME)); | ||
} | ||
temp = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this temporary array. As in
out = new this.constructor( outlen ); |
|
||
// TESTS // | ||
|
||
tape('main export is a function', function test( t ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow stdlib spacing conventions consistently throughout this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your tests should essentially follow the same structure as https://github.com/stdlib-js/stdlib/blob/4b1d77d2bd001d5970ce93230765a579fb41349d/lib/node_modules/%40stdlib/array/bool/test/test.slice.js. For every set of tests in that package, I would expect to see similar tests in this package.
CI failures will need to be resolved before this PR can receive further review. Cheers! |
@kgryte please review PR#3269 i have made the necessary changes told by you above |
Resolves #3154 .
Description
This pull request:
Related Issues
This pull request:
slice
method toarray/fixed-endian-factory
#3154Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers