Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ bench( format( '%s:get', pkg ), function benchmark( b ) {
var v;
var i;

arr = zeroTo( 10, 'generic' );
arr = new Uint64Array( arr );
arr = new Uint64Array( zeroTo( 10, 'generic' ) );
N = arr.length;

b.tic();
Expand Down
40 changes: 40 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,46 @@
*/
setReadOnly( Uint64Array.prototype, 'BYTES_PER_ELEMENT', Uint64Array.BYTES_PER_ELEMENT );

/**
* Copies a sequence of elements within the array to the position starting at `target`.
*
* @name copyWithin
* @memberof Uint64Array.prototype
* @type {Function}
* @param {integer} target - index at which to start copying elements
* @param {integer} start - source index at which to copy elements from
* @param {integer} [end] - source index at which to stop copying elements from
* @throws {TypeError} `this` must be a 64-bit unsigned integer array
* @returns {Uint64Array} modified array
*
* @example
* var Uint64 = require( '@stdlib/number/uint64/ctor' );
*
* var arr = new Uint64Array( 4 );
*
* // Set the array elements:
* arr.set( 1, 0 );
* arr.set( 2, 1 );
* arr.set( 3, 2 );
* arr.set( 4, 3 );
*
* // Copy the first two elements to the last two elements:
* arr.copyWithin( 2, 0, 2 );
* // arr => <Uint64Array>[ 1n, 2n, 1n, 2n ]
*/
setReadOnly( Uint64Array.prototype, 'copyWithin', function copyWithin( target, start ) {
if ( !isUint64Array( this ) ) {
throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' );
}
// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled

Check warning on line 631 in lib/node_modules/@stdlib/array/uint64/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: prefer a functional `copyWithin`...'
if ( arguments.length === 2 ) {
this._buffer.copyWithin( target*2, start*2 );
} else {
this._buffer.copyWithin( target*2, start*2, arguments[2]*2 );
}
return this;
});

/**
* Returns an iterator for iterating over array key-value pairs.
*
Expand Down Expand Up @@ -846,7 +886,7 @@
buf[ idx+indices.LOW ] = words[ 1 ];
return;
}
if ( isNonNegativeInteger( value ) || ( isBigInt( value ) && isNonNegativeInteger( Number( value ) ) ) ) {

Check warning on line 889 in lib/node_modules/@stdlib/array/uint64/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 110. Maximum allowed is 80
if ( idx >= this._length ) {
throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );
}
Expand Down Expand Up @@ -909,7 +949,7 @@
// We need to copy source values...
tmp = new Uint32Array( sbuf.length );
for ( i = 0; i < sbuf.length; i++ ) {
tmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays

Check warning on line 952 in lib/node_modules/@stdlib/array/uint64/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: handle accessor arrays'
}
sbuf = tmp;
}
Expand Down
Loading