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
36 changes: 36 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,42 @@ The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the
- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished.
- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.

<a name="method-fill"></a>

#### Uint64Array.prototype.fill( value\[, start\[, end]] )

Returns a modified typed array filled with a fill value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Returns a modified typed array filled with a fill value.
Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`.

Let's use the description used in array/float64, rather than the less descriptive description in, e.g., array/complex128. Also applies to the other places in the docs where the method is described.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to submit a small clean-up PR updating the corresponding descriptions in the complex and bool array packages, if applicable.


```javascript
var Uint64 = require( '@stdlib/number/uint64/ctor' );

var arr = new Uint64Array( 3 );

// Set all elements to the same value:
arr.fill( new Uint64( 1 ) );
// arr => <Uint64Array>[ 1n, 1n, 1n ]

// Fill all elements starting from the second element:
arr.fill( new Uint64( 2 ), 1 );
// arr => <Uint64Array>[ 1n, 2n, 2n ]

// Fill all elements from first element until the second-to-last element:
arr.fill( new Uint64( 3 ), 0, 2 );
// arr => <Uint64Array>[ 3n, 3n, 2n ]
```

When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element.

```javascript
var Uint64 = require( '@stdlib/number/uint64/ctor' );

var arr = new Uint64Array( 3 );

// Set all array elements, except the last element, to the same value:
arr.fill( new Uint64( 1 ), 0, -1 );
// arr => <Uint64Array>[ 1n, 1n, 0n ]
```

<a name="method-get"></a>

#### Uint64Array.prototype.get( i )
Expand Down
59 changes: 59 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var format = require( '@stdlib/string/format' );
var isUint64Array = require( '@stdlib/assert/is-uint64array' );
var Uint64 = require( '@stdlib/number/uint64/ctor' );
var pkg = require( './../package.json' ).name;
var Uint64Array = require( './../lib' );


// MAIN //

bench( format( '%s:fill', pkg ), function benchmark( b ) {
var values;
var arr;
var out;
var i;

values = [
new Uint64( 1 ),
new Uint64( 2 ),
new Uint64( 3 )
];
arr = new Uint64Array( 5 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = arr.fill( values[ i%values.length ] );
if ( typeof out !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( !isUint64Array( out ) ) {
b.fail( 'should return a Uint64Array' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var format = require( '@stdlib/string/format' );
var isUint64Array = require( '@stdlib/assert/is-uint64array' );
var pow = require( '@stdlib/math/base/special/pow' );
var Uint64 = require( '@stdlib/number/uint64/ctor' );
var pkg = require( './../package.json' ).name;
var Uint64Array = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var arr = new Uint64Array( len );
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var values;
var out;
var i;

values = [
new Uint64( 1 ),
new Uint64( 2 ),
new Uint64( 3 )
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = arr.fill( values[ i%values.length ] );
if ( typeof out !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( !isUint64Array( out ) ) {
b.fail( 'should return a Uint64Array' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( format( '%s:fill:len=%d', pkg, len ), f );
}
}

main();
28 changes: 28 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,34 @@
true


{{alias}}.prototype.fill( value[, start[, end]] )
Returns a modified typed array filled with a fill value.

Parameters
----------
value: Uint64
Fill value.

start: integer (optional)
Start index. If less than zero, the start index is resolved relative to
the last array element. Default: 0.

end: integer (optional)
End index (non-inclusive). If less than zero, the end index is resolved
relative to the last array element. Default: out.length.

Returns
-------
out: Uint64Array
Modified array.

Examples
--------
> var arr = new {{alias}}( 3 );
> arr.fill( 1 )
<Uint64Array>[ 1n, 1n, 1n ]


{{alias}}.prototype.get( i )
Returns an array element located at integer position (index) `i`.

Expand Down
17 changes: 17 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import ArrayBuffer = require( '@stdlib/array/buffer' );

// Define a union type representing both iterable and non-iterable iterators:
type Iterator = Iter | IterableIterator;

Check failure on line 31 in lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

'Iterator' is defined but never used

// Define a type representing a value from which a 64-bit unsigned integer can be derived:
type Uint = Uint64 | bigint | number;
Expand All @@ -36,7 +36,7 @@
/**
* Locale-specific configuration options.
*/
interface LocaleOptions<T = unknown> {

Check failure on line 39 in lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

'LocaleOptions' is defined but never used
/**
* Configuration property.
*/
Expand Down Expand Up @@ -118,7 +118,7 @@
* @param arr - array on which the method was called
* @returns boolean indicating whether an element in an array passes a test
*/
type Predicate<U> = NullaryPredicate<U> | UnaryPredicate<U> | BinaryPredicate<U> | TernaryPredicate<U>;

Check failure on line 121 in lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

'Predicate' is defined but never used

/**
* Callback invoked for each element in an array.
Expand Down Expand Up @@ -162,7 +162,7 @@
* @param arr - array on which the method was called
* @returns undefined
*/
type Callback<U> = NullaryCallback<U> | UnaryCallback<U> | BinaryCallback<U> | TernaryCallback<U>;

Check failure on line 165 in lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

'Callback' is defined but never used

/**
* Callback invoked for each element in an array.
Expand Down Expand Up @@ -206,7 +206,7 @@
* @param arr - array on which the method was called
* @returns transformed value
*/
type MapFcn<U> = NullaryMapFcn<U> | UnaryMapFcn<U> | BinaryMapFcn<U> | TernaryMapFcn<U>;

Check failure on line 209 in lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

'MapFcn' is defined but never used

/**
* Reducer function invoked for each element in an array.
Expand Down Expand Up @@ -260,7 +260,7 @@
* @param arr - array on which the method was called
* @returns accumulated result
*/
type Reducer<U> = NullaryReducer<U> | UnaryReducer<U> | BinaryReducer<U> | TernaryReducer<U> | QuaternaryReducer<U>;

Check failure on line 263 in lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

'Reducer' is defined but never used

/**
* Comparator function.
Expand All @@ -269,7 +269,7 @@
* @param b - second value for comparison
* @returns number indicating comparison result
*/
type CompareFcn = ( a: Uint64, b: Uint64 ) => number;

Check failure on line 272 in lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

'CompareFcn' is defined but never used

/**
* Class for creating a 64-bit unsigned integer array.
Expand Down Expand Up @@ -454,6 +454,23 @@
*/
entries(): TypedIterator<[number, Uint64]>;

/**
* Returns a modified typed array filled with a fill value.
*
* @param value - fill value
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns modified typed array
*
* @example
* var arr = new Uint64Array( 3 );
* // returns <Uint64Array>[ 0n , 0n, 0n ]
*
* arr = arr.fill( 1, 1 );
* // returns <Uint64Array>[ 0n, 1n, 1n ]
*/
fill( value: Uint, start?: number, end?: number ): Uint64Array;

/**
* Returns an array element.
*
Expand Down
80 changes: 80 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,86 @@
}
});

/**
* 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 );
* // returns <Uint64Array>[ 0n , 0n, 0n ]
*
* arr = arr.fill( 1, 1 );
* // returns <Uint64Array>[ 0n, 1n, 1n ]
*/
setReadOnly( Uint64Array.prototype, 'fill', function fill( value, start, end ) {
var words;
var buf;
var len;
var idx;
var i;
if ( !isUint64Array( this ) ) {
throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' );
}
if ( !isUint64( value ) ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DivitJain26 Do you want to use the new scalar2uint64 utility you recently added here?

try {
value = 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( value, 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 @@ -839,7 +919,7 @@
buf[ idx+indices.LOW ] = words[ 1 ];
return;
}
if ( isNonNegativeInteger( value ) || ( isBigInt( value ) && isNonNegativeInteger( Number( value ) ) ) ) {

Check warning on line 922 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
Loading
Loading