Skip to content
Open
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
127 changes: 127 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,85 @@ 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 ] );

// Get the first array element:
var u = arr.get( 0 );
// returns <Uint64>[ 1n ]

// Get the second array element:
u = arr.get( 1 );
// returns <Uint64>[ 2n ]

// Copy the last two elements to the first two elements:
arr.copyWithin( 0, 2 );

// Get the first array element:
u = arr.get( 0 );
// returns <Uint64>[ 3n ]

// Get the second array element:
u = arr.get( 1 );
// returns <Uint64>[ 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 ] );

// Get the third array element:
var u = arr.get( 2 );
// returns <Uint64>[ 3n ]

// Get the last array element:
u = arr.get( 3 );
// returns <Uint64>[ 4n ]

// Copy the first two elements to the last two elements:
arr.copyWithin( 2, 0, 2 );

// Get the third array element:
u = arr.get( 2 );
// returns <Uint64>[ 1n ]

// Get the last array element:
u = arr.get( 3 );
// returns <Uint64>[ 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 ] );

// Get the third array element:
var u = arr.get( 2 );
// returns <Uint64>[ 3n ]

// Get the last array element:
u = arr.get( 3 );
// returns <Uint64>[ 4n ]

// Copy the first two elements to the last two elements using negative indices:
arr.copyWithin( -2, -4, -2 );

// Get the third array element:
u = arr.get( 2 );
// returns <Uint64>[ 1n ]

// Get the last array element:
u = arr.get( 3 );
// returns <Uint64>[ 2n ]
```

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

#### Uint64Array.prototype.entries()
Expand Down Expand Up @@ -309,6 +388,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