Skip to content

Commit 90101f0

Browse files
authored
Apply suggestions from code review
Signed-off-by: Athan <[email protected]>
1 parent 5950cc8 commit 90101f0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var Float64ArrayFE = factory( 'float64' );
3333

3434
// MAIN //
3535

36-
bench( pkg+':at:endianness=little-endian', function benchmark( b ) {
36+
bench( pkg+'::nonnegative_indices:at:endianness=little-endian', function benchmark( b ) {
3737
var arr;
3838
var N;
3939
var v;
@@ -61,7 +61,7 @@ bench( pkg+':at:endianness=little-endian', function benchmark( b ) {
6161
b.end();
6262
});
6363

64-
bench( pkg+':at:endianness=little-endian', function benchmark( b ) {
64+
bench( pkg+'::negative_indices:at:endianness=little-endian', function benchmark( b ) {
6565
var arr;
6666
var N;
6767
var v;
@@ -89,7 +89,7 @@ bench( pkg+':at:endianness=little-endian', function benchmark( b ) {
8989
b.end();
9090
});
9191

92-
bench( pkg+':at:endianness=big-endian', function benchmark( b ) {
92+
bench( pkg+'::nonnegative_indices:at:endianness=big-endian', function benchmark( b ) {
9393
var arr;
9494
var N;
9595
var v;
@@ -117,7 +117,7 @@ bench( pkg+':at:endianness=big-endian', function benchmark( b ) {
117117
b.end();
118118
});
119119

120-
bench( pkg+':at:endianness=big-endian', function benchmark( b ) {
120+
bench( pkg+'::negative_indices:at:endianness=big-endian', function benchmark( b ) {
121121
var arr;
122122
var N;
123123
var v;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,16 +694,16 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
694694
});
695695

696696
/**
697-
* Takes an integer value and returns the data at that index.
697+
* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.
698698
*
699699
* @private
700700
* @name at
701701
* @memberof TypedArray.prototype
702702
* @type {Function}
703-
* @param {integer} idx - required index
703+
* @param {integer} idx - element index
704704
* @param {*} [thisArg] function invocation context
705705
* @throws {TypeError} `this` must be a typed array instance
706-
* @throws {TypeError} first argument must be an integer
706+
* @throws {TypeError} must provide an integer
707707
* @returns {(*|void)} array element
708708
*/
709709
setReadOnly( TypedArray.prototype, 'at', function at( idx ) {
@@ -712,13 +712,13 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
712712
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );
713713
}
714714
if ( !isInteger( idx ) ) {
715-
throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );
715+
throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );
716716
}
717717
len = this._length;
718718
if ( idx < 0 ) {
719719
idx += len;
720720
}
721-
if ( idx >= this._length || idx < 0 ) {
721+
if ( idx < 0 || idx >= len ) {
722722
return;
723723
}
724724
return this._buffer[ GETTER ]( idx * BYTES_PER_ELEMENT, this._isLE );

0 commit comments

Comments
 (0)