Skip to content

Commit

Permalink
style: insert toReversed in alphabetic order in array/fixed-endian-fa…
Browse files Browse the repository at this point in the history
…ctory
  • Loading branch information
nate10j committed Dec 7, 2024
1 parent 328ba9d commit 0e0154c
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,38 +963,6 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
return acc;
});

/**
* Returns a new typed array containing the elements in reversed order.
*
* @private
* @name toReversed
* @memberof TypedArray.prototype
* @type {Function}
* @throws {TypeError} `this` is not a typed array
* @returns {TypedArray} reversed array
*/
setReadOnly( TypedArray.prototype, 'toReversed', function toReversed() {
var obuf;
var out;
var len;
var buf;
var i;
var v;

if ( !isTypedArray( this ) ) {
throw new TypeError( 'invalid invocation. `this` is not a typed array.' );
}
len = this._length;
out = new this.constructor( flag2byteOrder( this._isLE ), len );
buf = this._buffer;
obuf = out._buffer; // eslint-disable-line no-underscore-dangle
for ( i = 0; i < len; i++ ) {
v = buf[ GETTER ]( ( len - i - 1 ) * BYTES_PER_ELEMENT, this._isLE );
obuf[ SETTER ]( i * BYTES_PER_ELEMENT, v, this._isLE );
}
return out;
});

/**
* Sets an array element.
*
Expand Down Expand Up @@ -1121,6 +1089,38 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
return false;
});

/**
* Returns a new typed array containing the elements in reversed order.
*
* @private
* @name toReversed
* @memberof TypedArray.prototype
* @type {Function}
* @throws {TypeError} `this` is not a typed array
* @returns {TypedArray} reversed array
*/
setReadOnly( TypedArray.prototype, 'toReversed', function toReversed() {
var obuf;
var out;
var len;
var buf;
var i;
var v;

if ( !isTypedArray( this ) ) {
throw new TypeError( 'invalid invocation. `this` is not a typed array.' );
}
len = this._length;
out = new this.constructor( flag2byteOrder( this._isLE ), len );
buf = this._buffer;
obuf = out._buffer; // eslint-disable-line no-underscore-dangle
for ( i = 0; i < len; i++ ) {
v = buf[ GETTER ]( ( len - i - 1 ) * BYTES_PER_ELEMENT, this._isLE );
obuf[ SETTER ]( i * BYTES_PER_ELEMENT, v, this._isLE );
}
return out;
});

/**
* Serializes an array as a string.
*
Expand Down

0 comments on commit 0e0154c

Please sign in to comment.