Skip to content
Draft
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
83 changes: 83 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,89 @@
}
});

/**
* Returns a modified typed array filled with a fill value.
*
* @name fill
* @memberof Uint64Array.prototype
* @type {Function}
* @param {Uint64|bigint|number} value - fill value
* @param {integer} [start=0] - starting index (inclusive)
* @param {integer} [end] - ending index (exclusive)
* @throws {TypeError} `this` must be a 64-bit unsigned integer array
* @throws {TypeError} first argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer
* @throws {TypeError} second argument must be an integer
* @throws {TypeError} third argument must be an integer
* @returns {Uint64Array} modified array
*
* @example
* var arr = new Uint64Array( 3 );
*
* arr.fill( 1, 1 );
*
* var z = arr.get( 1 );
* // returns <Uint64>[ 1n ]
*
* z = arr.get( 2 );
* // returns <Uint64>[ 1n ]
*/
setReadOnly( Uint64Array.prototype, 'fill', function fill( value, start, end ) {
var words;
var buf;
var len;
var idx;
var val;
var i;
if ( !isUint64Array( this ) ) {
throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' );
}
try {
val = new Uint64( value );
} catch ( err ) { // eslint-disable-line no-unused-vars
throw new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', value ) );
}
buf = this._buffer;
len = this._length;
if ( arguments.length > 1 ) {
if ( !isInteger( start ) ) {
throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );
}
if ( start < 0 ) {
start += len;
if ( start < 0 ) {
start = 0;
}
}
if ( arguments.length > 2 ) {
if ( !isInteger( end ) ) {
throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );
}
if ( end < 0 ) {
end += len;
if ( end < 0 ) {
end = 0;
}
}
if ( end > len ) {
end = len;
}
} else {
end = len;
}
} else {
start = 0;
end = len;
}
words = [ 0, 0 ];
toWords( val, words, 1, 0 );
for ( i = start; i < end; i++ ) {
idx = 2*i;
buf[ idx+indices.HIGH ] = words[ 0 ];
buf[ idx+indices.LOW ] = words[ 1 ];
}
return this;
});

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

Check warning on line 932 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 +992,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 995 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