Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b6e7972
chore: clean up get method benchmark
DivitJain26 Aug 5, 2026
dc46aca
feat: add method copywithin
DivitJain26 Aug 5, 2026
f7af12e
test: add test for copywithin
DivitJain26 Aug 10, 2026
8b86e23
bench: add benchmark for copywithin
DivitJain26 Aug 10, 2026
99d6449
docs: add type definition for copywithin
DivitJain26 Aug 10, 2026
707235f
docs: add repl text for copywithin
DivitJain26 Aug 10, 2026
6f6be3b
docs: add readme for copywithin
DivitJain26 Aug 10, 2026
07045e0
fix: fix repl file lint error
DivitJain26 Aug 11, 2026
ff6f588
chore: update exmaples
DivitJain26 Aug 14, 2026
59a7ce6
bench: improve benchmarks
DivitJain26 Sep 24, 2026
1307908
chore: clean up unsed imports
DivitJain26 Oct 28, 2026
b0d702e
test: use iEqualUint64Array
DivitJain26 Oct 28, 2026
e7488bc
docs: improve definition and doc test examples
DivitJain26 Oct 29, 2026
694f904
Merge branch 'develop' into feat/add-uint64array-copywithin
DivitJain26 Oct 29, 2026
fb02569
feat: add implementation for every
DivitJain26 Aug 10, 2026
d9f3d71
test: add tests for every
DivitJain26 Aug 11, 2026
c9e1566
bench: add benchmarks for every method
DivitJain26 Aug 11, 2026
89244bc
docs: add type definition for every method
DivitJain26 Aug 11, 2026
c6383bc
docs: add repl text for every method
DivitJain26 Aug 11, 2026
e4269cc
docs: add readme for every method
DivitJain26 Aug 11, 2026
a9bc82c
refactor: use isPrimitive
DivitJain26 Aug 13, 2026
7bdbde7
chore: update exmaples
DivitJain26 Aug 14, 2026
fb5689f
bench: improve benchmarks
DivitJain26 Sep 24, 2026
a5cd512
chore: clean up
DivitJain26 Oct 28, 2026
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
82 changes: 82 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,40 @@ u = arr.at( -100 );
// returns undefined
```

<a name="method-copy-within"></a>

#### Uint64Array.prototype.copyWithin( target, start\[, end] )

Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`.

```javascript
var arr = new Uint64Array( [ 1, 2, 3, 4 ] );

// Copy the last two elements to the first two elements:
arr.copyWithin( 0, 2 );
// arr => <Uint64Array>[ 3n, 4n, 3n, 4n ]
```

By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument.

```javascript
var arr = new Uint64Array( [ 1, 2, 3, 4 ] );

// Copy the first two elements to the last two elements:
arr.copyWithin( 2, 0, 2 );
// arr => <Uint64Array>[ 1n, 2n, 1n, 2n ]
```

When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example:

```javascript
var arr = new Uint64Array( [ 1, 2, 3, 4 ] );

// Copy the first two elements to the last two elements using negative indices:
arr.copyWithin( -2, -4, -2 );
// arr => <Uint64Array>[ 1n, 2n, 1n, 2n ]
```

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

#### Uint64Array.prototype.entries()
Expand Down Expand Up @@ -309,6 +343,54 @@ 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-every"></a>

#### Uint64Array.prototype.every( predicate\[, thisArg] )

Returns a boolean indicating whether all elements pass a test.

```javascript
var isEven = require( '@stdlib/assert/is-even' ).isPrimitive;
var Number = require( '@stdlib/number/ctor' );

function predicate( v ) {
return ( isEven( Number( v ) ) );
}

var arr = new Uint64Array( [ 2, 4, 6 ] );

// Check whether all elements pass a test:
var bool = arr.every( predicate );
// returns true
```

The `predicate` function is provided three arguments:

- **value**: current array element.
- **index**: current array element index.
- **arr**: the array on which this method was called.

To set the function execution context, provide a `thisArg`.

```javascript
function predicate( v, i ) {
this.count += 1;
return ( i >= 0 );
}

var arr = new Uint64Array( [ 2, 4, 6 ] );

var context = {
'count': 0
};

var bool = arr.every( predicate, context );
// returns true

var count = context.count;
// returns 3
```

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

#### Uint64Array.prototype.get( i )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @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 isUint64Array = require( '@stdlib/assert/is-uint64array' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var Uint64Array = require( './../lib' );


// MAIN //

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

arr = new Uint64Array( 10 );

// Benchmark worst case scenario (i.e., copying all but one element to an overlapping region)...
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = arr.copyWithin( 1, 0 );
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,96 @@
/**
* @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 pow = require( '@stdlib/math/base/special/pow' );
var isUint64Array = require( '@stdlib/assert/is-uint64array' );
var format = require( '@stdlib/string/format' );
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 out;
var i;

// Benchmark worst case scenario (i.e., copying all but one element to an overlapping region)...
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = arr.copyWithin( 1, 0 );
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:copyWithin:len=%d', pkg, len ), f );
}
}

main();
85 changes: 85 additions & 0 deletions lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* @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 isUint64 = require( '@stdlib/assert/is-uint64' );
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var Uint64Array = require( './../lib' );


// MAIN //

bench( format( '%s:every', pkg ), function benchmark( b ) {
var bool;
var arr;
var i;

arr = new Uint64Array( 10 );

// Benchmark worst case scenario (i.e., the predicate passes for every element, so the method cannot exit early)...
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = arr.every( predicate );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();

function predicate( v ) {
return isUint64( v );
}
});

bench( format( '%s::this_context:every', pkg ), function benchmark( b ) {
var bool;
var arr;
var i;

arr = new Uint64Array( 10 );

// Benchmark worst case scenario (i.e., the predicate passes for every element, so the method cannot exit early)...
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = arr.every( predicate, {} );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();

function predicate( v ) {
return isUint64( v );
}
});
Loading
Loading