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
521 changes: 521 additions & 0 deletions lib/node_modules/@stdlib/array/int64/README.md

Large diffs are not rendered by default.

87 changes: 87 additions & 0 deletions lib/node_modules/@stdlib/array/int64/benchmark/benchmark.at.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* @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 isInt64 = require( '@stdlib/assert/is-int64' );
var Int64 = require( '@stdlib/number/int64/ctor' );
var pkg = require( './../package.json' ).name;
var Int64Array = require( './../lib' );


// MAIN //

bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) {
var arr;
var N;
var u;
var i;

arr = [];
for ( i = 0; i < 10; i++ ) {
arr.push( new Int64( i ) );
}
arr = new Int64Array( arr );
N = arr.length;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
u = arr.at( i%N );
if ( typeof u !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( !isInt64( u ) ) {
b.fail( 'should return a 64-bit signed integer' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) {
var arr;
var N;
var u;
var i;

arr = [];
for ( i = 0; i < 10; i++ ) {
arr.push( new Int64( i ) );
}
arr = new Int64Array( arr );
N = arr.length;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
u = arr.at( -(i%N)-1 );
if ( typeof u !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( !isInt64( u ) ) {
b.fail( 'should return a 64-bit signed integer' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @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 zeroTo = require( '@stdlib/array/zero-to' );
var pkg = require( './../package.json' ).name;
var Int64Array = require( './../lib' );


// MAIN //

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

arr = new Int64Array( zeroTo( 10, 'generic' ) );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
iter = arr.entries();
if ( typeof iter !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
b.fail( 'should return an iterator protocol-compliant object' );
}
b.pass( 'benchmark finished' );
b.end();
});
239 changes: 239 additions & 0 deletions lib/node_modules/@stdlib/array/int64/benchmark/benchmark.from.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
/**
* @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 identity = require( '@stdlib/number/int64/base/identity' );
var bench = require( '@stdlib/bench' );
var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' );
var format = require( '@stdlib/string/format' );
var Uint32Array = require( '@stdlib/array/uint32' );
var pkg = require( './../package.json' ).name;
var Int64Array = require( './../lib' );


// VARIABLES //

var opts = {
'skip': ( ITERATOR_SYMBOL === null )
};


// MAIN //

bench( format( '%s::typed_array:from', pkg ), function benchmark( b ) {
var buf;
var arr;
var i;

buf = new Uint32Array( [ 1, 2 ] );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = Int64Array.from( buf );
if ( arr.length !== 2 ) {
b.fail( 'should have length 2' );
}
}
b.toc();
if ( !(arr instanceof Int64Array) ) {
b.fail( 'should return an Int64Array' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( format( '%s::typed_array,clbk:from', pkg ), function benchmark( b ) {
var buf;
var arr;
var i;

buf = new Uint32Array( [ 1, 2 ] );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = Int64Array.from( buf, clbk );
if ( arr.length !== 2 ) {
b.fail( 'should have length 2' );
}
}
b.toc();
if ( !(arr instanceof Int64Array) ) {
b.fail( 'should return an Int64Array' );
}
b.pass( 'benchmark finished' );
b.end();

function clbk( v ) {
return identity( v );
}
});

bench( format( '%s::array:from', pkg ), function benchmark( b ) {
var buf;
var arr;
var i;

buf = [ 1, 2 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = Int64Array.from( buf );
if ( arr.length !== 2 ) {
b.fail( 'should have length 2' );
}
}
b.toc();
if ( !(arr instanceof Int64Array) ) {
b.fail( 'should return an Int64Array' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( format( '%s::array,clbk:from', pkg ), function benchmark( b ) {
var buf;
var arr;
var i;

buf = [ 1, 2 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = Int64Array.from( buf, clbk );
if ( arr.length !== 2 ) {
b.fail( 'should have length 2' );
}
}
b.toc();
if ( !(arr instanceof Int64Array) ) {
b.fail( 'should return an Int64Array' );
}
b.pass( 'benchmark finished' );
b.end();

function clbk( v ) {
return identity( v );
}
});

bench( format( '%s::iterable:from', pkg ), opts, function benchmark( b ) {
var arr;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = Int64Array.from( createIterable() );
if ( arr.length !== 2 ) {
b.fail( 'should have length 2' );
}
}
b.toc();
if ( !(arr instanceof Int64Array) ) {
b.fail( 'should return an Int64Array' );
}
b.pass( 'benchmark finished' );
b.end();

function createIterable() {
var out;
var i;

out = {};
out[ ITERATOR_SYMBOL ] = iterator;

i = 0;

return out;

function iterator() {
return {
'next': next
};
}

function next() {
i += 1;
if ( i <= 2 ) {
return {
'value': 0,
'done': false
};
}
return {
'done': true
};
}
}
});

bench( format( '%s::iterable,clbk:from', pkg ), opts, function benchmark( b ) {
var arr;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = Int64Array.from( createIterable(), clbk );
if ( arr.length !== 2 ) {
b.fail( 'should have length 2' );
}
}
b.toc();
if ( !(arr instanceof Int64Array) ) {
b.fail( 'should return an Int64Array' );
}
b.pass( 'benchmark finished' );
b.end();

function createIterable() {
var out;
var i;

out = {};
out[ ITERATOR_SYMBOL ] = iterator;

i = 0;

return out;

function iterator() {
return {
'next': next
};
}

function next() {
i += 1;
if ( i <= 2 ) {
return {
'value': 1,
'done': false
};
}
return {
'done': true
};
}
}

function clbk( v ) {
return identity( v );
}
});
Loading
Loading