From e40a0233bf3c55f6320c6c519cee69d9f6bc997a Mon Sep 17 00:00:00 2001 From: headlessNode Date: Tue, 17 Mar 2026 04:59:41 +0500 Subject: [PATCH] feat: add missing typed array methods to dstructs/named-typed-tuple --- .../dstructs/named-typed-tuple/README.md | 335 ++++++++++++++++++ .../benchmark/benchmark.copy_within.js | 3 +- .../benchmark/benchmark.copy_within.length.js | 3 +- .../benchmark/benchmark.data.js | 9 +- .../benchmark/benchmark.entries.js | 3 +- .../benchmark/benchmark.every.js | 5 +- .../benchmark/benchmark.every.length.js | 3 +- .../benchmark/benchmark.field_of.js | 3 +- .../benchmark/benchmark.field_of.length.js | 3 +- .../benchmark/benchmark.fill.js | 3 +- .../benchmark/benchmark.fill.length.js | 3 +- .../benchmark/benchmark.filter.js | 5 +- .../benchmark/benchmark.filter.length.js | 3 +- .../benchmark/benchmark.find.js | 5 +- .../benchmark/benchmark.find.length.js | 3 +- .../benchmark/benchmark.find_field.js | 5 +- .../benchmark/benchmark.find_field.length.js | 3 +- .../benchmark/benchmark.find_index.js | 5 +- .../benchmark/benchmark.find_index.length.js | 3 +- .../benchmark/benchmark.find_last.js | 85 +++++ .../benchmark/benchmark.find_last.length.js | 109 ++++++ .../benchmark/benchmark.find_last_field.js | 87 +++++ .../benchmark.find_last_field.length.js | 109 ++++++ .../benchmark/benchmark.find_last_index.js | 85 +++++ .../benchmark.find_last_index.length.js | 109 ++++++ .../benchmark/benchmark.for_each.js | 5 +- .../benchmark/benchmark.for_each.length.js | 3 +- .../benchmark/benchmark.from.js | 13 +- .../benchmark/benchmark.from_object.js | 5 +- .../benchmark/benchmark.includes.js | 3 +- .../benchmark/benchmark.includes.length.js | 3 +- .../benchmark/benchmark.ind2key.js | 3 +- .../benchmark/benchmark.ind2key.length.js | 3 +- .../benchmark/benchmark.index_of.js | 3 +- .../benchmark/benchmark.index_of.length.js | 3 +- .../benchmark/benchmark.join.js | 3 +- .../benchmark/benchmark.join.length.js | 3 +- .../named-typed-tuple/benchmark/benchmark.js | 3 +- .../benchmark/benchmark.key2ind.js | 3 +- .../benchmark/benchmark.key2ind.length.js | 3 +- .../benchmark/benchmark.keys.js | 3 +- .../benchmark/benchmark.last_field_of.js | 3 +- .../benchmark.last_field_of.length.js | 3 +- .../benchmark/benchmark.last_index_of.js | 3 +- .../benchmark.last_index_of.length.js | 3 +- .../benchmark/benchmark.length.js | 3 +- .../benchmark/benchmark.map.js | 5 +- .../benchmark/benchmark.map.length.js | 3 +- .../benchmark/benchmark.of.js | 3 +- .../benchmark/benchmark.properties.js | 15 +- .../benchmark/benchmark.reduce.js | 5 +- .../benchmark/benchmark.reduce.length.js | 3 +- .../benchmark/benchmark.reduce_right.js | 5 +- .../benchmark.reduce_right.length.js | 3 +- .../benchmark/benchmark.reverse.js | 3 +- .../benchmark/benchmark.reverse.length.js | 3 +- .../benchmark/benchmark.set.js | 5 +- .../benchmark/benchmark.set.length.js | 3 +- .../benchmark/benchmark.slice.js | 3 +- .../benchmark/benchmark.slice.length.js | 3 +- .../benchmark/benchmark.some.js | 5 +- .../benchmark/benchmark.some.length.js | 3 +- .../benchmark/benchmark.sort.js | 3 +- .../benchmark/benchmark.sort.length.js | 3 +- .../benchmark/benchmark.subarray.js | 3 +- .../benchmark/benchmark.subarray.length.js | 3 +- .../benchmark/benchmark.subtuple.js | 3 +- .../benchmark/benchmark.subtuple.length.js | 3 +- .../benchmark/benchmark.to_json.js | 3 +- .../benchmark/benchmark.to_json.length.js | 3 +- .../benchmark/benchmark.to_locale_string.js | 3 +- .../benchmark.to_locale_string.length.js | 3 +- .../benchmark/benchmark.to_reversed.js | 53 +++ .../benchmark/benchmark.to_reversed.length.js | 109 ++++++ .../benchmark/benchmark.to_sorted.js | 55 +++ .../benchmark/benchmark.to_sorted.length.js | 112 ++++++ .../benchmark/benchmark.to_string.js | 3 +- .../benchmark/benchmark.to_string.length.js | 3 +- .../benchmark.tuple_instantiation.js | 25 +- .../benchmark/benchmark.values.js | 3 +- .../benchmark/benchmark.with.js | 54 +++ .../benchmark/benchmark.with.length.js | 109 ++++++ .../dstructs/named-typed-tuple/docs/repl.txt | 226 ++++++++++++ .../named-typed-tuple/docs/types/index.d.ts | 200 +++++++++++ .../dstructs/named-typed-tuple/lib/main.js | 209 +++++++++++ .../named-typed-tuple/test/test.find_last.js | 231 ++++++++++++ .../test/test.find_last_field.js | 233 ++++++++++++ .../test/test.find_last_index.js | 233 ++++++++++++ .../test/test.to_reversed.js | 176 +++++++++ .../named-typed-tuple/test/test.to_sorted.js | 231 ++++++++++++ .../named-typed-tuple/test/test.with.js | 221 ++++++++++++ 91 files changed, 3546 insertions(+), 106 deletions(-) create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last.length.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_field.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_field.length.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_index.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_index.length.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_reversed.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_reversed.length.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_sorted.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_sorted.length.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.with.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.with.length.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last_field.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last_index.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.to_reversed.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.to_sorted.js create mode 100644 lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.with.js diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/README.md b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/README.md index 96551c05649c..042e8022a715 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/README.md +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/README.md @@ -1147,6 +1147,198 @@ var n = ctx.count; // returns 3 ``` + + +#### tuple.findLast( predicate\[, thisArg] ) + +Returns the last tuple element for which a provided `predicate` function returns a truthy value. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + return ( v < 1.0 ); +} + +var v = tuple.findLast( predicate ); +// returns -1.0 +``` + +If a `predicate` function does not return a truthy value for any tuple element, the method returns `undefined`. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + return ( v < -10.0 ); +} + +var v = tuple.findLast( predicate ); +// returns undefined +``` + +A `predicate` function is provided four arguments: + +- `value`: tuple element. +- `index`: tuple index. +- `field`: tuple field name. +- `tuple`: tuple on which the method is invoked. + +To set the callback execution context, provide a `thisArg`. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + this.count += 1; + return ( v < 0.0 ); +} + +var ctx = { + 'count': 0 +}; + +var v = tuple.findLast( predicate, ctx ); +// returns -1.0 + +var n = ctx.count; +// returns 1 +``` + + + +#### tuple.findLastIndex( predicate\[, thisArg] ) + +Returns the index of the last tuple element for which a provided `predicate` function returns a truthy value. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + return ( v < 1.0 ); +} + +var idx = tuple.findLastIndex( predicate ); +// returns 2 +``` + +If a `predicate` function does not return a truthy value for any tuple element, the method returns `-1`. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + return ( v < -10.0 ); +} + +var idx = tuple.findLastIndex( predicate ); +// returns -1 +``` + +A `predicate` function is provided four arguments: + +- `value`: tuple element. +- `index`: tuple index. +- `field`: tuple field name. +- `tuple`: tuple on which the method is invoked. + +To set the callback execution context, provide a `thisArg`. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + this.count += 1; + return ( v < 0.0 ); +} + +var ctx = { + 'count': 0 +}; + +var idx = tuple.findLastIndex( predicate, ctx ); +// returns 2 + +var n = ctx.count; +// returns 1 +``` + + + +#### tuple.findLastField( predicate\[, thisArg] ) + +Returns the field of the last tuple element for which a provided `predicate` function returns a truthy value. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + return ( v < 1.0 ); +} + +var field = tuple.findLastField( predicate ); +// returns 'z' +``` + +If a `predicate` function does not return a truthy value for any tuple element, the method returns `undefined`. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + return ( v < -10.0 ); +} + +var field = tuple.findLastField( predicate ); +// returns undefined +``` + +A `predicate` function is provided four arguments: + +- `value`: tuple element. +- `index`: tuple index. +- `field`: tuple field name. +- `tuple`: tuple on which the method is invoked. + +To set the callback execution context, provide a `thisArg`. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + +function predicate( v ) { + this.count += 1; + return ( v < 0.0 ); +} + +var ctx = { + 'count': 0 +}; + +var field = tuple.findLastField( predicate, ctx ); +// returns 'z' + +var n = ctx.count; +// returns 1 +``` + #### tuple.forEach( fcn\[, thisArg] ) @@ -1644,6 +1836,39 @@ x = tuple.x; Invoking this method does **not** affect tuple field assignments. + + +#### tuple.toReversed() + +Returns a new tuple with elements in reversed order. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 2.0, 0.0, -3.0 ] ); + +var x = tuple[ 0 ]; +// returns 2.0 + +x = tuple.x; +// returns 2.0 + +// Reverse the tuple: +var out = tuple.toReversed(); + +var fields = out.orderedFields; +// returns [ 'z', 'y', 'x' ] + +var z = out[ 0 ]; +// returns -3.0 + +// Tuple field assignments do NOT change: +x = out.x; +// returns 2.0 +``` + +Unlike [`reverse`](#method-reverse), this method does **not** mutate the host tuple. + #### tuple.set( arr\[, offset] ) @@ -1930,6 +2155,76 @@ The comparison function is provided two tuple elements, `a` and `b`, per invocat Invoking this method does **not** affect tuple field assignments. + + +#### tuple.toSorted( \[compareFunction] ) + +Returns a new tuple with elements sorted in ascending order. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 2.0, -3.0, 0.0 ] ); + +var x = tuple[ 0 ]; +// returns 2.0 + +x = tuple.x; +// returns 2.0 + +// Sort the tuple (in ascending order): +var out = tuple.toSorted(); + +var fields = out.orderedFields; +// returns [ 'y', 'z', 'x' ] + +var y = out[ 0 ]; +// returns -3.0 + +// Tuple field assignments do NOT change: +x = out.x; +// returns 2.0 +``` + +By default, the method sorts tuple elements in ascending order. To impose a custom order, provide a `compareFunction`. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 2.0, -3.0, 0.0 ] ); + +var x = tuple[ 0 ]; +// returns 2.0 + +x = tuple.x; +// returns 2.0 + +function descending( a, b ) { + return b - a; +} + +// Sort the tuple (in descending order): +var out = tuple.toSorted( descending ); + +var fields = out.orderedFields; +// returns [ 'x', 'z', 'y' ] + +var z = out[ 1 ]; +// returns 0.0 + +// Tuple field assignments do NOT change: +var y = out.y; +// returns -3.0 +``` + +The comparison function is provided two tuple elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: + +- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). +- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). +- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. + +Unlike [`sort`](#method-sort), this method does **not** mutate the host tuple. + #### tuple.subarray( \[begin\[, end]] ) @@ -2185,6 +2480,46 @@ var bool = it.next().done; // returns true ``` + + +#### tuple.with( index, value ) + +Returns a new tuple with the element at the specified `index` replaced with a provided `value`. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 2.0, 3.0 ] ); + +var out = tuple.with( 1, 99.0 ); + +var v = out[ 0 ]; +// returns 1.0 + +v = out[ 1 ]; +// returns 99.0 + +v = out[ 2 ]; +// returns 3.0 + +// The original tuple is not mutated: +v = tuple[ 1 ]; +// returns 2.0 +``` + +When an `index` is negative, the index is resolved relative to the last tuple element. + +```javascript +var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + +var tuple = factory( [ 1.0, 2.0, 3.0 ] ); + +var out = tuple.with( -1, 99.0 ); + +var v = out[ 2 ]; +// returns 99.0 +``` + diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.copy_within.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.copy_within.js index 1165527d14c6..e521e51034c0 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.copy_within.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.copy_within.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':copyWithin', function benchmark( b ) { +bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { var Point; var p; var i; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.copy_within.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.copy_within.length.js index 8b12ad62bf1a..68f5036bec4a 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.copy_within.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.copy_within.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); + bench( format( '%s:copyWithin:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.data.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.data.js index 9694cdca3547..bab26d2050aa 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.data.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.data.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+'::tuple,get,index', function benchmark( b ) { +bench( format( '%s::tuple,get,index', pkg ), function benchmark( b ) { var Point; var N; var p; @@ -54,7 +55,7 @@ bench( pkg+'::tuple,get,index', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,get,property_name', function benchmark( b ) { +bench( format( '%s::tuple,get,property_name', pkg ), function benchmark( b ) { var fields; var Point; var N; @@ -83,7 +84,7 @@ bench( pkg+'::tuple,get,property_name', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,set,index', function benchmark( b ) { +bench( format( '%s::tuple,set,index', pkg ), function benchmark( b ) { var Point; var N; var p; @@ -109,7 +110,7 @@ bench( pkg+'::tuple,set,index', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,set,property_name', function benchmark( b ) { +bench( format( '%s::tuple,set,property_name', pkg ), function benchmark( b ) { var fields; var Point; var N; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.entries.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.entries.js index 1e33f6caf392..c9ba1a6594b2 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.entries.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.entries.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':entries', function benchmark( b ) { +bench( format( '%s:entries', pkg ), function benchmark( b ) { var Point; var iter; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.every.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.every.js index 98230f7819c5..b3663854927b 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.every.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.every.js @@ -22,13 +22,14 @@ var bench = require( '@stdlib/bench' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':every', function benchmark( b ) { +bench( format( '%s:every', pkg ), function benchmark( b ) { var Point; var bool; var p; @@ -56,7 +57,7 @@ bench( pkg+':every', function benchmark( b ) { } }); -bench( pkg+'::this_context:every', function benchmark( b ) { +bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { var Point; var bool; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.every.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.every.length.js index 749c46849e30..d36fe828e87c 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.every.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.every.length.js @@ -23,6 +23,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -109,7 +110,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); + bench( format( '%s:every:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.field_of.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.field_of.js index 30d42b5d1f36..9940f8638aef 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.field_of.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.field_of.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':fieldOf', function benchmark( b ) { +bench( format( '%s:fieldOf', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.field_of.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.field_of.length.js index 4afdf2397b47..6e7215baa0fd 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.field_of.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.field_of.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':fieldOf:len='+len, f ); + bench( format( '%s:fieldOf:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.fill.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.fill.js index 309c5e656f94..efd772eaacfc 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.fill.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.fill.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':fill', function benchmark( b ) { +bench( format( '%s:fill', pkg ), function benchmark( b ) { var Point; var p; var i; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.fill.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.fill.length.js index 92bbde41dafd..e2ef234a4102 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.fill.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.fill.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -96,7 +97,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); + bench( format( '%s:fill:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.filter.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.filter.js index 4985cc3877c7..803169cd8543 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.filter.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.filter.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':filter', function benchmark( b ) { +bench( format( '%s:filter', pkg ), function benchmark( b ) { var Point; var out; var p; @@ -55,7 +56,7 @@ bench( pkg+':filter', function benchmark( b ) { } }); -bench( pkg+'::this_context:filter', function benchmark( b ) { +bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.filter.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.filter.length.js index 8e3b4f2afb59..0cab30763266 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.filter.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.filter.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -108,7 +109,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); + bench( format( '%s:filter:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find.js index e10e10e6eda3..5af6e09a273c 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':find', function benchmark( b ) { +bench( format( '%s:find', pkg ), function benchmark( b ) { var Point; var out; var p; @@ -56,7 +57,7 @@ bench( pkg+':find', function benchmark( b ) { } }); -bench( pkg+'::this_context:find', function benchmark( b ) { +bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find.length.js index 9f4070274d31..dd5fac6ad580 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -108,7 +109,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); + bench( format( '%s:find:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_field.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_field.js index 885f4a799c66..621c02cd15e3 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_field.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_field.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':findField', function benchmark( b ) { +bench( format( '%s:findField', pkg ), function benchmark( b ) { var Point; var out; var p; @@ -56,7 +57,7 @@ bench( pkg+':findField', function benchmark( b ) { } }); -bench( pkg+'::this_context:findField', function benchmark( b ) { +bench( format( '%s::this_context:findField', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_field.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_field.length.js index c6a6703eb2e7..56d2402329bb 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_field.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_field.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -108,7 +109,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':findField:len='+len, f ); + bench( format( '%s:findField:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_index.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_index.js index aab9c496cd5d..eda1d4e0c8eb 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_index.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_index.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':findIndex', function benchmark( b ) { +bench( format( '%s:findIndex', pkg ), function benchmark( b ) { var Point; var out; var p; @@ -56,7 +57,7 @@ bench( pkg+':findIndex', function benchmark( b ) { } }); -bench( pkg+'::this_context:findIndex', function benchmark( b ) { +bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_index.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_index.length.js index 5639c9ea09d9..b59c1200b2bf 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_index.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_index.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -108,7 +109,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); + bench( format( '%s:findIndex:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last.js new file mode 100644 index 000000000000..91d2fdf7e600 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last.js @@ -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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:findLast', pkg ), function benchmark( b ) { + var Point; + var out; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1.0, -1.0 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.findLast( predicate ); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 0; + } +}); + +bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { + var Point; + var out; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1.0, -1.0 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.findLast( predicate, {} ); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 0; + } +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last.length.js new file mode 100644 index 000000000000..5f569f3c802c --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last.length.js @@ -0,0 +1,109 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - tuple length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var fields; + var Point; + var p; + var i; + + fields = []; + for ( i = 0; i < len+1; i++ ) { + fields.push( '_'+i.toString() ); + } + Point = namedtypedtuple( fields ); + p = new Point(); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.findLast( predicate ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 1; + } + } +} + + +// 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:findLast:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_field.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_field.js new file mode 100644 index 000000000000..27d167829bfc --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_field.js @@ -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 pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:findLastField', pkg ), function benchmark( b ) { + var Point; + var out; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point(); + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.findLastField( predicate ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 1; + } +}); + +bench( format( '%s::this_context:findLastField', pkg ), function benchmark( b ) { + var Point; + var out; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point(); + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.findLastField( predicate, {} ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 1; + } +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_field.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_field.length.js new file mode 100644 index 000000000000..7e09f7feaf5e --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_field.length.js @@ -0,0 +1,109 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - tuple length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var fields; + var Point; + var p; + var i; + + fields = []; + for ( i = 0; i < len+1; i++ ) { + fields.push( '_'+i.toString() ); + } + Point = namedtypedtuple( fields ); + p = new Point(); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.findLastField( predicate ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 1; + } + } +} + + +// 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:findLastField:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_index.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_index.js new file mode 100644 index 000000000000..04eb48705379 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_index.js @@ -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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { + var Point; + var idx; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1.0, -1.0 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = p.findLastIndex( predicate ); + if ( idx !== 0 ) { + b.fail( 'should return 0' ); + } + } + b.toc(); + if ( idx !== 0 ) { + b.fail( 'should return 0' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 0; + } +}); + +bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { + var Point; + var idx; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1.0, -1.0 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = p.findLastIndex( predicate, {} ); + if ( idx !== 0 ) { + b.fail( 'should return 0' ); + } + } + b.toc(); + if ( idx !== 0 ) { + b.fail( 'should return 0' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 0; + } +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_index.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_index.length.js new file mode 100644 index 000000000000..565c73f34bc4 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.find_last_index.length.js @@ -0,0 +1,109 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - tuple length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var fields; + var Point; + var p; + var i; + + fields = []; + for ( i = 0; i < len+1; i++ ) { + fields.push( '_'+i.toString() ); + } + Point = namedtypedtuple( fields ); + p = new Point(); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = p.findLastIndex( predicate ); + if ( idx !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( idx !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return v > 1; + } + } +} + + +// 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:findLastIndex:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.for_each.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.for_each.js index bd7f89bb69ce..100061f9041b 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.for_each.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.for_each.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':forEach', function benchmark( b ) { +bench( format( '%s:forEach', pkg ), function benchmark( b ) { var count; var Point; var N; @@ -59,7 +60,7 @@ bench( pkg+':forEach', function benchmark( b ) { } }); -bench( pkg+'::this_context:forEach', function benchmark( b ) { +bench( format( '%s::this_context:forEach', pkg ), function benchmark( b ) { var count; var Point; var N; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.for_each.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.for_each.length.js index 27d681abd692..2fca88a1f16b 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.for_each.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.for_each.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -107,7 +108,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); + bench( format( '%s:forEach:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.from.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.from.js index 0f208dcd7741..940a915a6a72 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.from.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.from.js @@ -23,6 +23,7 @@ var bench = require( '@stdlib/bench' ); var Float32Array = require( '@stdlib/array/float32' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -36,7 +37,7 @@ var opts = { // MAIN // -bench( pkg+'::typed_array:from', function benchmark( b ) { +bench( format( '%s::typed_array:from', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -60,7 +61,7 @@ bench( pkg+'::typed_array:from', function benchmark( b ) { b.end(); }); -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { +bench( format( '%s::typed_array,clbk:from', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -88,7 +89,7 @@ bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { } }); -bench( pkg+'::array:from', function benchmark( b ) { +bench( format( '%s::array:from', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -112,7 +113,7 @@ bench( pkg+'::array:from', function benchmark( b ) { b.end(); }); -bench( pkg+'::array,clbk:from', function benchmark( b ) { +bench( format( '%s::array,clbk:from', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -140,7 +141,7 @@ bench( pkg+'::array,clbk:from', function benchmark( b ) { } }); -bench( pkg+'::iterable:from', opts, function benchmark( b ) { +bench( format( '%s::iterable:from', pkg ), opts, function benchmark( b ) { var Point; var p; var i; @@ -193,7 +194,7 @@ bench( pkg+'::iterable:from', opts, function benchmark( b ) { } }); -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { +bench( format( '%s::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { var Point; var p; var i; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.from_object.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.from_object.js index 12fccf3b5139..fad034f1bc6d 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.from_object.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.from_object.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':fromObject', function benchmark( b ) { +bench( format( '%s:fromObject', pkg ), function benchmark( b ) { var Point; var obj; var p; @@ -54,7 +55,7 @@ bench( pkg+':fromObject', function benchmark( b ) { b.end(); }); -bench( pkg+'::clbk:fromObject', function benchmark( b ) { +bench( format( '%s::clbk:fromObject', pkg ), function benchmark( b ) { var Point; var obj; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.includes.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.includes.js index a89bb91279e6..12aaa75815ad 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.includes.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.includes.js @@ -22,13 +22,14 @@ var bench = require( '@stdlib/bench' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':includes', function benchmark( b ) { +bench( format( '%s:includes', pkg ), function benchmark( b ) { var Point; var bool; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.includes.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.includes.length.js index f921e31fc919..a999aafbfc97 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.includes.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.includes.length.js @@ -23,6 +23,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -98,7 +99,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); + bench( format( '%s:includes:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.ind2key.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.ind2key.js index b444b030810b..92187ef5ecb0 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.ind2key.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.ind2key.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':ind2key', function benchmark( b ) { +bench( format( '%s:ind2key', pkg ), function benchmark( b ) { var Point; var out; var N; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.ind2key.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.ind2key.length.js index 93a30af1c0a0..614f1dc6bc3e 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.ind2key.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.ind2key.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -99,7 +100,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':ind2key:len='+len, f ); + bench( format( '%s:ind2key:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.index_of.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.index_of.js index b2af340a276d..0c05ccb8ce65 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.index_of.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.index_of.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':indexOf', function benchmark( b ) { +bench( format( '%s:indexOf', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.index_of.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.index_of.length.js index 8a21a7c9eb6b..38f24f19536d 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.index_of.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.index_of.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); + bench( format( '%s:indexOf:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.join.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.join.js index aeb2dd75ab15..a451da47686f 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.join.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.join.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':join', function benchmark( b ) { +bench( format( '%s:join', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.join.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.join.length.js index b6ea7bca8544..45d84db89d6f 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.join.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.join.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -98,7 +99,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); + bench( format( '%s:join:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.js index f38c9ed581a3..09ed079cd3cb 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -47,7 +48,7 @@ bench( pkg, function benchmark( b ) { b.end(); }); -bench( pkg+'::options', function benchmark( b ) { +bench( format( '%s::options', pkg ), function benchmark( b ) { var Point; var i; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.key2ind.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.key2ind.js index 20bd0d0cc494..aab67872e8d0 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.key2ind.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.key2ind.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':key2ind', function benchmark( b ) { +bench( format( '%s:key2ind', pkg ), function benchmark( b ) { var fields; var Point; var out; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.key2ind.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.key2ind.length.js index 570f3cf43803..d551eb227cb6 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.key2ind.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.key2ind.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -101,7 +102,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':key2ind:len='+len, f ); + bench( format( '%s:key2ind:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.keys.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.keys.js index cac6091ad7b2..09e6a19179c0 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.keys.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.keys.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':keys', function benchmark( b ) { +bench( format( '%s:keys', pkg ), function benchmark( b ) { var Point; var iter; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_field_of.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_field_of.js index 2df416454b39..a6474cb3592e 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_field_of.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_field_of.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':lastFieldOf', function benchmark( b ) { +bench( format( '%s:lastFieldOf', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_field_of.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_field_of.length.js index 8037af10381a..8a8421c0db85 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_field_of.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_field_of.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':lastFieldOf:len='+len, f ); + bench( format( '%s:lastFieldOf:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_index_of.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_index_of.js index e4a4299fd112..28091443089c 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_index_of.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_index_of.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':lastIndexOf', function benchmark( b ) { +bench( format( '%s:lastIndexOf', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_index_of.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_index_of.length.js index 447830934339..959c52b44cf8 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_index_of.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.last_index_of.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); + bench( format( '%s:lastIndexOf:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.length.js index cd921929b416..5f670acff0f2 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -95,7 +96,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':len='+len, f ); + bench( format( '%s:len=', pkg )+len, f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.map.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.map.js index 80f40d5af28c..a14f93236a67 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.map.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.map.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':map', function benchmark( b ) { +bench( format( '%s:map', pkg ), function benchmark( b ) { var Point; var out; var p; @@ -55,7 +56,7 @@ bench( pkg+':map', function benchmark( b ) { } }); -bench( pkg+'::this_context:map', function benchmark( b ) { +bench( format( '%s::this_context:map', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.map.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.map.length.js index 9d4bb3073de7..3a38c4c88b8f 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.map.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.map.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -108,7 +109,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); + bench( format( '%s:map:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.of.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.of.js index 8cfb23b17769..5010c66b502d 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.of.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.of.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtyple = require( './../lib' ); // MAIN // -bench( pkg+':of', function benchmark( b ) { +bench( format( '%s:of', pkg ), function benchmark( b ) { var Point; var p; var i; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.properties.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.properties.js index 91b71fcd8f5d..836d0a38e578 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.properties.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.properties.js @@ -25,13 +25,14 @@ var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isArray = require( '@stdlib/assert/is-array' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+'::tuple,get:buffer', function benchmark( b ) { +bench( format( '%s::tuple,get:buffer', pkg ), function benchmark( b ) { var Point; var p; var v; @@ -56,7 +57,7 @@ bench( pkg+'::tuple,get:buffer', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,get:byteLength', function benchmark( b ) { +bench( format( '%s::tuple,get:byteLength', pkg ), function benchmark( b ) { var Point; var p; var v; @@ -81,7 +82,7 @@ bench( pkg+'::tuple,get:byteLength', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,get:byteOffset', function benchmark( b ) { +bench( format( '%s::tuple,get:byteOffset', pkg ), function benchmark( b ) { var Point; var p; var v; @@ -106,7 +107,7 @@ bench( pkg+'::tuple,get:byteOffset', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,get:length', function benchmark( b ) { +bench( format( '%s::tuple,get:length', pkg ), function benchmark( b ) { var Point; var p; var v; @@ -131,7 +132,7 @@ bench( pkg+'::tuple,get:length', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,get:name', function benchmark( b ) { +bench( format( '%s::tuple,get:name', pkg ), function benchmark( b ) { var Point; var p; var v; @@ -156,7 +157,7 @@ bench( pkg+'::tuple,get:name', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,get:fields', function benchmark( b ) { +bench( format( '%s::tuple,get:fields', pkg ), function benchmark( b ) { var Point; var p; var v; @@ -180,7 +181,7 @@ bench( pkg+'::tuple,get:fields', function benchmark( b ) { b.end(); }); -bench( pkg+'::tuple,get:orderedFields', function benchmark( b ) { +bench( format( '%s::tuple,get:orderedFields', pkg ), function benchmark( b ) { var Point; var p; var v; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce.js index 23cf8a05bb4e..91a2405f8e28 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':reduce', function benchmark( b ) { +bench( format( '%s:reduce', pkg ), function benchmark( b ) { var Point; var out; var p; @@ -55,7 +56,7 @@ bench( pkg+':reduce', function benchmark( b ) { } }); -bench( pkg+'::initial_value:reduce', function benchmark( b ) { +bench( format( '%s::initial_value:reduce', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce.length.js index 504614d8c661..5af03a3f9d09 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -109,7 +110,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); + bench( format( '%s:reduce:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce_right.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce_right.js index 7bc784b48d81..51291d89ad4a 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce_right.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce_right.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':reduceRight', function benchmark( b ) { +bench( format( '%s:reduceRight', pkg ), function benchmark( b ) { var Point; var out; var p; @@ -55,7 +56,7 @@ bench( pkg+':reduceRight', function benchmark( b ) { } }); -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { +bench( format( '%s::initial_value:reduceRight', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce_right.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce_right.length.js index e8cd43d5bf56..d472219afc59 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce_right.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reduce_right.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -109,7 +110,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); + bench( format( '%s:reduceRight:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reverse.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reverse.js index ad4df1e29279..b1ac6531b2c9 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reverse.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reverse.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':reverse', function benchmark( b ) { +bench( format( '%s:reverse', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reverse.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reverse.length.js index 339b1444d349..f351e38d75c0 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reverse.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.reverse.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); + bench( format( '%s:reverse:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.set.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.set.js index 3a7af4417a7b..c664b02e6113 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.set.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.set.js @@ -22,13 +22,14 @@ var bench = require( '@stdlib/bench' ); var Float32Array = require( '@stdlib/array/float32' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+'::array:set', function benchmark( b ) { +bench( format( '%s::array:set', pkg ), function benchmark( b ) { var values; var Point; var buf; @@ -64,7 +65,7 @@ bench( pkg+'::array:set', function benchmark( b ) { b.end(); }); -bench( pkg+'::typed_array:set', function benchmark( b ) { +bench( format( '%s::typed_array:set', pkg ), function benchmark( b ) { var values; var Point; var buf; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.set.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.set.length.js index 83133b5dfeb0..261ebd727258 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.set.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.set.length.js @@ -23,6 +23,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); var randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -112,7 +113,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); + bench( format( '%s:set:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.slice.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.slice.js index 2799aecf5a44..4a76bd05be3a 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.slice.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.slice.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':slice', function benchmark( b ) { +bench( format( '%s:slice', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.slice.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.slice.length.js index 71b30ebd6e59..e2516e11c7c1 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.slice.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.slice.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); + bench( format( '%s:slice:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.some.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.some.js index dd3db64ba343..eff6e5a320f8 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.some.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.some.js @@ -22,13 +22,14 @@ var bench = require( '@stdlib/bench' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':some', function benchmark( b ) { +bench( format( '%s:some', pkg ), function benchmark( b ) { var Point; var bool; var p; @@ -56,7 +57,7 @@ bench( pkg+':some', function benchmark( b ) { } }); -bench( pkg+'::this_context:some', function benchmark( b ) { +bench( format( '%s::this_context:some', pkg ), function benchmark( b ) { var Point; var bool; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.some.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.some.length.js index f171497a5c00..91d31e4978f1 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.some.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.some.length.js @@ -23,6 +23,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -109,7 +110,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); + bench( format( '%s:some:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.sort.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.sort.js index 80c2ca42a6e0..66ff3f851994 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.sort.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.sort.js @@ -22,13 +22,14 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':sort', function benchmark( b ) { +bench( format( '%s:sort', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.sort.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.sort.length.js index 90a7515c8b1c..9ced5396d7d2 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.sort.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.sort.length.js @@ -23,6 +23,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); var randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -104,7 +105,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); + bench( format( '%s:sort:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subarray.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subarray.js index 6c82c130131f..bbc64fce31d1 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subarray.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subarray.js @@ -22,13 +22,14 @@ var bench = require( '@stdlib/bench' ); var isTypedArray = require( '@stdlib/assert/is-typed-array' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':subarray', function benchmark( b ) { +bench( format( '%s:subarray', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subarray.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subarray.length.js index 6f916a8788f7..dd6f46d2b07a 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subarray.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subarray.length.js @@ -23,6 +23,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); var isTypedArray = require( '@stdlib/assert/is-typed-array' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -98,7 +99,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); + bench( format( '%s:subarray:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subtuple.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subtuple.js index 75ddf190b59f..eb3407cf477e 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subtuple.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subtuple.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':subtuple', function benchmark( b ) { +bench( format( '%s:subtuple', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subtuple.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subtuple.length.js index 2750214e9dde..d15db8747a50 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subtuple.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.subtuple.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':subtuple:len='+len, f ); + bench( format( '%s:subtuple:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_json.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_json.js index ec524e14fc68..ee4fa65ed43f 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_json.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_json.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':toJSON', function benchmark( b ) { +bench( format( '%s:toJSON', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_json.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_json.length.js index 515f509b7a54..3b91ba8eecb7 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_json.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_json.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':toJSON:len='+len, f ); + bench( format( '%s:toJSON:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_locale_string.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_locale_string.js index c7e09475d96e..b03b197206fd 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_locale_string.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_locale_string.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':toLocaleString', function benchmark( b ) { +bench( format( '%s:toLocaleString', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_locale_string.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_locale_string.length.js index 1c7ba0e27dc6..dc7f1a086593 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_locale_string.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_locale_string.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); + bench( format( '%s:toLocaleString:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_reversed.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_reversed.js new file mode 100644 index 000000000000..ecf8a9570b67 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_reversed.js @@ -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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:toReversed', pkg ), function benchmark( b ) { + var Point; + var out; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1.0, -1.0 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.toReversed(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + } + b.toc(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_reversed.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_reversed.length.js new file mode 100644 index 000000000000..1fbc46ab6b01 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_reversed.length.js @@ -0,0 +1,109 @@ +/** +* @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 randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - tuple length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var fields; + var Point; + var data; + var p; + var i; + + fields = []; + data = []; + for ( i = 0; i < len+1; i++ ) { + fields.push( '_'+i.toString() ); + data.push( randu() ); + } + Point = namedtypedtuple( fields ); + p = new Point( data ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.toReversed(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + } + b.toc(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + 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:toReversed:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_sorted.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_sorted.js new file mode 100644 index 000000000000..ad5710d40bc0 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_sorted.js @@ -0,0 +1,55 @@ +/** +* @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 randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:toSorted', pkg ), function benchmark( b ) { + var Point; + var out; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ randu(), randu() ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + p[ 0 ] = randu(); + out = p.toSorted(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + } + b.toc(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_sorted.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_sorted.length.js new file mode 100644 index 000000000000..d4fc1519bf02 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_sorted.length.js @@ -0,0 +1,112 @@ +/** +* @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 randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - tuple length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var fields; + var Point; + var data; + var N; + var p; + var i; + + fields = []; + data = []; + for ( i = 0; i < len+1; i++ ) { + fields.push( '_'+i.toString() ); + data.push( randu() ); + } + Point = namedtypedtuple( fields ); + p = new Point( data ); + N = p.length; + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + p[ i%N ] = randu(); + out = p.toSorted(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + } + b.toc(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + 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 = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:toSorted:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_string.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_string.js index e7c32f531668..aacfcb47cf54 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_string.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_string.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':toString', function benchmark( b ) { +bench( format( '%s:toString', pkg ), function benchmark( b ) { var Point; var out; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_string.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_string.length.js index f00369c05d09..d8e557b3c57b 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_string.length.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.to_string.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -97,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); + bench( format( '%s:toString:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.tuple_instantiation.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.tuple_instantiation.js index ef04f23749b2..d2935089dec9 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.tuple_instantiation.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.tuple_instantiation.js @@ -24,6 +24,7 @@ var bench = require( '@stdlib/bench' ); var ArrayBuffer = require( '@stdlib/array/buffer' ); var Float32Array = require( '@stdlib/array/float32' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); @@ -37,7 +38,7 @@ var opts = { // MAIN // -bench( pkg+'::instantiation,new', function benchmark( b ) { +bench( format( '%s::instantiation,new', pkg ), function benchmark( b ) { var Point; var p; var i; @@ -59,7 +60,7 @@ bench( pkg+'::instantiation,new', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,no_new', function benchmark( b ) { +bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { var point; var p; var i; @@ -81,7 +82,7 @@ bench( pkg+'::instantiation,no_new', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { +bench( format( '%s::instantiation,typed_array', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -105,7 +106,7 @@ bench( pkg+'::instantiation,typed_array', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,typed_array,dtype', function benchmark( b ) { +bench( format( '%s::instantiation,typed_array,dtype', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -129,7 +130,7 @@ bench( pkg+'::instantiation,typed_array,dtype', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,array', function benchmark( b ) { +bench( format( '%s::instantiation,array', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -153,7 +154,7 @@ bench( pkg+'::instantiation,array', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,array,dtype', function benchmark( b ) { +bench( format( '%s::instantiation,array,dtype', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -177,7 +178,7 @@ bench( pkg+'::instantiation,array,dtype', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { +bench( format( '%s::instantiation,iterable', pkg ), opts, function benchmark( b ) { var Point; var p; var i; @@ -229,7 +230,7 @@ bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { } }); -bench( pkg+'::instantiation,iterable,dtype', opts, function benchmark( b ) { +bench( format( '%s::instantiation,iterable,dtype', pkg ), opts, function benchmark( b ) { var Point; var p; var i; @@ -281,7 +282,7 @@ bench( pkg+'::instantiation,iterable,dtype', opts, function benchmark( b ) { } }); -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { +bench( format( '%s::instantiation,arraybuffer', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -305,7 +306,7 @@ bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,arraybuffer,dtype', function benchmark( b ) { +bench( format( '%s::instantiation,arraybuffer,dtype', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -329,7 +330,7 @@ bench( pkg+'::instantiation,arraybuffer,dtype', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { +bench( format( '%s::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { var Point; var buf; var p; @@ -353,7 +354,7 @@ bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { b.end(); }); -bench( pkg+'::instantiation,arraybuffer,byte_offset,dtype', function benchmark( b ) { +bench( format( '%s::instantiation,arraybuffer,byte_offset,dtype', pkg ), function benchmark( b ) { var Point; var buf; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.values.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.values.js index 44d55c545838..2e1809e99a9c 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.values.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.values.js @@ -21,13 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var namedtypedtuple = require( './../lib' ); // MAIN // -bench( pkg+':values', function benchmark( b ) { +bench( format( '%s:values', pkg ), function benchmark( b ) { var Point; var iter; var p; diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.with.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.with.js new file mode 100644 index 000000000000..c772bbf021eb --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.with.js @@ -0,0 +1,54 @@ +/** +* @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 randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:with', pkg ), function benchmark( b ) { + var Point; + var out; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ randu(), randu() ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.with( 0, randu() ); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + } + b.toc(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.with.length.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.with.length.js new file mode 100644 index 000000000000..2d1ef95c80b0 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/benchmark/benchmark.with.length.js @@ -0,0 +1,109 @@ +/** +* @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 randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var namedtypedtuple = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - tuple length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var fields; + var Point; + var data; + var p; + var i; + + fields = []; + data = []; + for ( i = 0; i < len+1; i++ ) { + fields.push( '_'+i.toString() ); + data.push( randu() ); + } + Point = namedtypedtuple( fields ); + p = new Point( data ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = p.with( 0, randu() ); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + } + b.toc(); + if ( typeof out.subtuple !== 'function' ) { + b.fail( 'should return a tuple' ); + } + 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:with:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/docs/repl.txt b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/docs/repl.txt index c99f34eabc90..4074ff56b7b1 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/docs/repl.txt +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/docs/repl.txt @@ -708,6 +708,120 @@ tuple.findIndex( predicate[, thisArg] ) 2 +tuple.findLast( predicate[, thisArg] ) + Returns the last tuple element for which a provided predicate function + returns a truthy value. + + The method iterates from right to left. + + A predicate function is provided the following arguments: + + - value: tuple element. + - index: tuple index. + - field: tuple field name. + - tuple: tuple on which the method is invoked. + + If a predicate function never returns a truthy value, the method returns + `undefined`. + + Parameters + ---------- + predicate: Function + Predicate function which tests tuple elements. + + thisArg: Any (optional) + Callback execution context. + + Returns + ------- + value: number | undefined + Tuple element. + + Examples + -------- + > var factory = {{alias}}( [ 'x', 'y', 'z' ] ); + > var p = factory( [ 1.0, 0.0, -1.0 ] ); + > function predicate( v ) { return ( v < 1.0 ); }; + > var v = p.findLast( predicate ) + -1.0 + + +tuple.findLastIndex( predicate[, thisArg] ) + Returns the index of the last tuple element for which a provided predicate + function returns a truthy value. + + The method iterates from right to left. + + A predicate function is provided the following arguments: + + - value: tuple element. + - index: tuple index. + - field: tuple field name. + - tuple: tuple on which the method is invoked. + + If a predicate function never returns a truthy value, the method returns + `-1`. + + Parameters + ---------- + predicate: Function + Predicate function which tests tuple elements. + + thisArg: Any (optional) + Callback execution context. + + Returns + ------- + idx: integer + Tuple index. + + Examples + -------- + > var factory = {{alias}}( [ 'x', 'y', 'z' ] ); + > var p = factory( [ 1.0, 0.0, -1.0 ] ); + > function predicate( v ) { return ( v < 1.0 ); }; + > var idx = p.findLastIndex( predicate ) + 2 + + +tuple.findLastField( predicate[, thisArg] ) + Returns the field of the last tuple element for which a provided predicate + function returns a truthy value. + + The method iterates from right to left. + + A predicate function is provided the following arguments: + + - value: tuple element. + - index: tuple index. + - field: tuple field name. + - tuple: tuple on which the method is invoked. + + If a predicate function never returns a truthy value, the method returns + `undefined`. + + Parameters + ---------- + predicate: Function + Predicate function which tests tuple elements. + + thisArg: Any (optional) + Callback execution context. + + Returns + ------- + field: string | undefined + Tuple field name. + + Examples + -------- + > var factory = {{alias}}( [ 'x', 'y', 'z' ] ); + > var p = factory( [ 1.0, 0.0, -1.0 ] ); + > function predicate( v ) { return ( v < 1.0 ); }; + > var field = p.findLastField( predicate ) + 'z' + + tuple.forEach( fcn[, thisArg] ) Invokes a callback for each tuple element. @@ -1109,6 +1223,29 @@ tuple.reverse() 1.0 +tuple.toReversed() + Returns a new tuple with elements in reversed order. + + Unlike `reverse`, this method does *not* mutate the host tuple. + + Returns + ------- + out: TypedArray + A new reversed tuple. + + Examples + -------- + > var factory = {{alias}}( [ 'x', 'y', 'z' ] ); + > var p = factory( [ 1.0, 0.0, -1.0 ] ); + > var out = p.toReversed(); + > out[ 0 ] + -1.0 + > out.x + 1.0 + > p[ 0 ] + 1.0 + + tuple.set( arr[, offset] ) Sets tuple elements. @@ -1267,6 +1404,60 @@ tuple.sort( [compareFunction] ) 1.0 +tuple.toSorted( [compareFunction] ) + Returns a new tuple with elements sorted in ascending order. + + Sorting a tuple does *not* affect field assignments. Accessing a tuple field + before and after sorting will always return the same tuple element. However, + this behavior is generally not true when accessing tuple elements according + to tuple index. In summary, sorting affects index order but not field + assignments. + + The comparison function is provided two tuple elements per invocation: `a` + and `b`. + + The comparison function return value determines the sort order as follows: + + - If the comparison function returns a value less than zero, then the method + sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). + + - If the comparison function returns a value greater than zero, then the + method sorts `a` to an index higher than `b` (i.e., `b` should come *before* + `a`). + + - If the comparison function returns zero, then the relative order of `a` + and `b` should remain unchanged. + + Unlike `sort`, this method does *not* mutate the host tuple. + + Parameters + ---------- + compareFunction: Function (optional) + Function which specifies the sort order. The default sort order is + ascending order. + + Returns + ------- + out: TypedArray + A new sorted tuple. + + Examples + -------- + > var factory = {{alias}}( [ 'x', 'y', 'z', 'w', 'v' ] ); + > var p = factory( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] ); + > var out = p.toSorted(); + > out.orderedFields + [ 'v', 'y', 'z', 'x', 'w' ] + > out[ 0 ] + -2.0 + > out[ 1 ] + -1.0 + > out.y + -1.0 + > p[ 0 ] + 1.0 + + tuple.subarray( [begin[, end]] ) Creates a new typed array over the same underlying ArrayBuffer and with the same underlying data type as the host tuple. @@ -1422,6 +1613,41 @@ tuple.values() > it.next().done true + +tuple.with( index, value ) + Returns a new tuple with the element at the specified index replaced with a + provided value. + + If provided a negative index, the index is resolved relative to the last + tuple element. + + Unlike setting a value by index, this method does *not* mutate the host + tuple. + + Parameters + ---------- + index: integer + Element index. If less than zero, the index is resolved relative to the + last tuple element. + + value: number + New value. + + Returns + ------- + out: TypedArray + A new tuple. + + Examples + -------- + > var factory = {{alias}}( [ 'x', 'y', 'z' ] ); + > var p = factory( [ 1.0, 2.0, 3.0 ] ); + > var out = p.with( 1, 99.0 ); + > out[ 1 ] + 99.0 + > p[ 1 ] + 2.0 + See Also -------- diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/docs/types/index.d.ts b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/docs/types/index.d.ts index e21d65340f1a..76d84300b113 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/docs/types/index.d.ts @@ -674,6 +674,83 @@ interface Tuple { */ findIndex( predicate: PredicateFunction, thisArg?: any ): number | undefined; + /** + * Returns the last tuple element for which a provided `predicate` function returns a truthy value. + * + * ## Notes + * + * - The method iterates from right to left. + * + * @param predicate - predicate function which tests tuple elements + * @param thisArg - callback execution context + * @returns tuple element + * + * @example + * var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + * + * var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + * + * function predicate( v ) { + * return ( v < 1.0 ); + * } + * + * var v = tuple.findLast( predicate ); + * // returns -1.0 + */ + findLast( predicate: PredicateFunction, thisArg?: any ): number | undefined; + + /** + * Returns the index of the last tuple element for which a provided `predicate` function returns a truthy value. + * + * ## Notes + * + * - The method iterates from right to left. + * - If the predicate function never returns a truthy value, the method returns `-1`. + * + * @param predicate - predicate function which tests tuple elements + * @param thisArg - callback execution context + * @returns tuple index + * + * @example + * var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + * + * var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + * + * function predicate( v ) { + * return ( v < 1.0 ); + * } + * + * var idx = tuple.findLastIndex( predicate ); + * // returns 2 + */ + findLastIndex( predicate: PredicateFunction, thisArg?: any ): number; + + /** + * Returns the field of the last tuple element for which a provided `predicate` function returns a truthy value. + * + * ## Notes + * + * - The method iterates from right to left. + * - If the predicate function never returns a truthy value, the method returns `undefined`. + * + * @param predicate - predicate function which tests tuple elements + * @param thisArg - callback execution context + * @returns tuple field name + * + * @example + * var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + * + * var tuple = factory( [ 1.0, 0.0, -1.0 ] ); + * + * function predicate( v ) { + * return ( v < 1.0 ); + * } + * + * var field = tuple.findLastField( predicate ); + * // returns 'z' + */ + findLastField( predicate: PredicateFunction, thisArg?: any ): string | undefined; + /** * Invokes a callback for each tuple element. * @@ -980,6 +1057,41 @@ interface Tuple { */ reverse(): Tuple; + /** + * Returns a new tuple with elements in reversed order. + * + * ## Notes + * + * - Unlike `reverse`, this method does **not** mutate the host tuple. + * + * @returns new reversed tuple + * + * @example + * var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + * + * var tuple = factory( [ 2.0, 0.0, -3.0 ] ); + * + * var x = tuple[ 0 ]; + * // returns 2.0 + * + * x = tuple.x; + * // returns 2.0 + * + * // Reverse the tuple: + * var out = tuple.toReversed(); + * + * var fields = out.orderedFields; + * // returns [ 'z', 'y', 'x' ] + * + * var z = out[ 0 ]; + * // returns -3.0 + * + * // Tuple field assignments do NOT change: + * x = out.x; + * // returns 2.0 + */ + toReversed(): Tuple; + /** * Sets tuple elements. * @@ -1149,6 +1261,71 @@ interface Tuple { */ sort( compareFunction?: CompareFunction ): Tuple; + /** + * Returns a new tuple with elements sorted in ascending order. + * + * ## Notes + * + * - By default, the method sorts tuple elements in ascending order. To impose a custom order, provide a `compareFunction`. + * - Unlike `sort`, this method does **not** mutate the host tuple. + * + * @param compareFunction - function which specifies the sort order; the default sort order is ascending order + * @returns new sorted tuple + * + * @example + * var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + * + * var tuple = factory( [ 2.0, -3.0, 0.0 ] ); + * + * var x = tuple[ 0 ]; + * // returns 2.0 + * + * x = tuple.x; + * // returns 2.0 + * + * // Sort the tuple (in ascending order): + * var out = tuple.toSorted(); + * + * var fields = out.orderedFields; + * // returns [ 'y', 'z', 'x' ] + * + * var y = out[ 0 ]; + * // returns -3.0 + * + * // Tuple field assignments do NOT change: + * x = out.x; + * // returns 2.0 + * + * @example + * var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + * + * var tuple = factory( [ 2.0, -3.0, 0.0 ] ); + * + * var x = tuple[ 0 ]; + * // returns 2.0 + * + * x = tuple.x; + * // returns 2.0 + * + * function descending( a, b ) { + * return b - a; + * } + * + * // Sort the tuple (in descending order): + * var out = tuple.toSorted( descending ); + * + * var fields = out.orderedFields; + * // returns [ 'x', 'z', 'y' ] + * + * var z = out[ 1 ]; + * // returns 0.0 + * + * // Tuple field assignments do NOT change: + * var y = out.y; + * // returns -3.0 + */ + toSorted( compareFunction?: CompareFunction ): Tuple; + /** * Creates a new typed array over the same underlying ArrayBuffer and with the same underlying data type as the host tuple. * @@ -1303,6 +1480,29 @@ interface Tuple { * // returns true */ values(): Iterator; + + /** + * Returns a new tuple with the element at the specified index replaced with a provided value. + * + * @param index - element index; if less than zero, the index is resolved relative to the last tuple element + * @param value - new value + * @returns new tuple + * + * @example + * var factory = namedtypedtuple( [ 'x', 'y', 'z' ] ); + * + * var tuple = factory( [ 1.0, 2.0, 3.0 ] ); + * + * var out = tuple.with( 1, 99.0 ); + * + * var v = out[ 1 ]; + * // returns 99.0 + * + * // The original tuple is not mutated: + * v = tuple[ 1 ]; + * // returns 2.0 + */ + with( index: number, value: number ): Tuple; } /** diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/lib/main.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/lib/main.js index f454d5ecf975..bf8227314db0 100644 --- a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/lib/main.js +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/lib/main.js @@ -191,6 +191,9 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi setNonEnumerableProperty( tuple, 'find', find ); setNonEnumerableProperty( tuple, 'findIndex', findIndex ); setNonEnumerableProperty( tuple, 'findField', findField ); + setNonEnumerableProperty( tuple, 'findLast', findLast ); + setNonEnumerableProperty( tuple, 'findLastField', findLastField ); + setNonEnumerableProperty( tuple, 'findLastIndex', findLastIndex ); setNonEnumerableProperty( tuple, 'forEach', forEach ); setNonEnumerableProperty( tuple, 'ind2key', ind2key ); setNonEnumerableProperty( tuple, 'key2ind', key2ind ); @@ -206,7 +209,10 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi setNonEnumerableProperty( tuple, 'subtuple', subtuple ); setNonEnumerableProperty( tuple, 'toJSON', toJSON ); setNonEnumerableProperty( tuple, 'toLocaleString', toLocaleString ); + setNonEnumerableProperty( tuple, 'toReversed', toReversed ); + setNonEnumerableProperty( tuple, 'toSorted', toSorted ); setNonEnumerableProperty( tuple, 'toString', toString ); + setNonEnumerableProperty( tuple, 'with', copyWith ); return tuple; @@ -548,6 +554,119 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi } } + /** + * Returns the last tuple element for which a provided predicate function returns a truthy value. + * + * @private + * @memberof tuple + * @param {Function} predicate - predicate function + * @param {*} [thisArg] - execution context + * @throws {TypeError} `this` must be the host tuple + * @throws {TypeError} first argument must be a function + * @returns {(number|void)} tuple element + */ + function findLast( predicate, thisArg ) { + var bool; + var i; + if ( this !== tuple ) { // eslint-disable-line no-invalid-this + throw new TypeError( 'invalid invocation. `this` is not host tuple.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + for ( i = nfields - 1; i >= 0; i-- ) { + bool = predicate.call( thisArg, tuple[ i ], i, fields[ indices[i] ], tuple ); + if ( bool ) { + return tuple[ i ]; + } + } + } + + /** + * Returns the index of the last tuple element for which a provided predicate function returns a truthy value. + * + * ## Notes + * + * - The method iterates from right to left. + * - If the predicate function never returns a truthy value, the function returns `-1`. + * + * @private + * @memberof tuple + * @param {Function} predicate - predicate function + * @param {*} [thisArg] - execution context + * @throws {TypeError} `this` must be the host tuple + * @throws {TypeError} first argument must be a function + * @returns {integer} tuple index or `-1` + */ + /** + * Returns the field of the last tuple element for which a provided predicate function returns a truthy value. + * + * ## Notes + * + * - The method iterates from right to left. + * - If the predicate function never returns a truthy value, the function returns `undefined`. + * + * @private + * @memberof tuple + * @param {Function} predicate - predicate function + * @param {*} [thisArg] - execution context + * @throws {TypeError} `this` must be the host tuple + * @throws {TypeError} first argument must be a function + * @returns {(string|void)} tuple field name or `undefined` + */ + function findLastField( predicate, thisArg ) { + var bool; + var f; + var i; + if ( this !== tuple ) { // eslint-disable-line no-invalid-this + throw new TypeError( 'invalid invocation. `this` is not host tuple.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + for ( i = nfields - 1; i >= 0; i-- ) { + f = fields[ indices[ i ] ]; + bool = predicate.call( thisArg, tuple[ i ], i, f, tuple ); + if ( bool ) { + return f; + } + } + } + + /** + * Returns the index of the last tuple element for which a provided predicate function returns a truthy value. + * + * ## Notes + * + * - The method iterates from right to left. + * - If the predicate function never returns a truthy value, the function returns `-1`. + * + * @private + * @memberof tuple + * @param {Function} predicate - predicate function + * @param {*} [thisArg] - execution context + * @throws {TypeError} `this` must be the host tuple + * @throws {TypeError} first argument must be a function + * @returns {integer} tuple index or `-1` + */ + function findLastIndex( predicate, thisArg ) { + var bool; + var i; + if ( this !== tuple ) { // eslint-disable-line no-invalid-this + throw new TypeError( 'invalid invocation. `this` is not host tuple.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + for ( i = nfields - 1; i >= 0; i-- ) { + bool = predicate.call( thisArg, tuple[ i ], i, fields[ indices[i] ], tuple ); + if ( bool ) { + return i; + } + } + return -1; + } + /** * Returns the index of the first tuple element for which a provided predicate function returns a truthy value. * @@ -1226,6 +1345,65 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi return out; } + /** + * Returns a new tuple with elements in reversed order. + * + * ## Notes + * + * - Unlike `reverse`, this method does **not** mutate the host tuple. + * + * @private + * @memberof tuple + * @throws {TypeError} `this` must be the host tuple + * @returns {TypedArray} new reversed tuple + */ + function toReversed() { + var out; + if ( this !== tuple ) { // eslint-disable-line no-invalid-this + throw new TypeError( 'invalid invocation. `this` is not host tuple.' ); + } + out = namedtypedtuple( tuple, dtype ); + out.reverse(); + return out; + } + + /** + * Returns a new tuple with elements sorted in ascending order. + * + * ## Notes + * + * - The comparison function is provided two tuple elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: + * + * - If the comparison function returns a value **less** than zero, then the function sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). + * - If the comparison function returns a value **greater** than zero, then the function sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). + * - If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. + * + * - Unlike `sort`, this method does **not** mutate the host tuple. + * + * @private + * @memberof tuple + * @param {Function} [compareFunction] - function which specifies the sort order + * @throws {TypeError} `this` must be the host tuple + * @throws {TypeError} first argument must be a function + * @returns {TypedArray} new sorted tuple + */ + function toSorted( compareFunction ) { + var out; + if ( this !== tuple ) { // eslint-disable-line no-invalid-this + throw new TypeError( 'invalid invocation. `this` is not host tuple.' ); + } + out = namedtypedtuple( tuple, dtype ); + if ( arguments.length ) { + if ( !isFunction( compareFunction ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFunction ) ); + } + out.sort( compareFunction ); + } else { + out.sort(); + } + return out; + } + /** * Serializes a tuple as a string. * @@ -1252,6 +1430,37 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi out += ')'; return out; } + + /** + * Returns a new tuple with the element at the specified index replaced with a provided value. + * + * @private + * @memberof tuple + * @param {integer} index - element index + * @param {number} value - new value + * @throws {TypeError} `this` must be the host tuple + * @throws {TypeError} first argument must be an integer + * @throws {RangeError} index argument must be in bounds + * @returns {TypedArray} new tuple + */ + function copyWith( index, value ) { + var out; + if ( this !== tuple ) { // eslint-disable-line no-invalid-this + throw new TypeError( 'invalid invocation. `this` is not host tuple.' ); + } + if ( !isInteger( index ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); + } + if ( index < 0 ) { + index = nfields + index; + } + if ( index < 0 || index >= nfields ) { + throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', index ) ); + } + out = namedtypedtuple( tuple, dtype ); + out[ index ] = value; + return out; + } } /** diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last.js new file mode 100644 index 000000000000..af3b965141ae --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last.js @@ -0,0 +1,231 @@ +/** +* @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 tape = require( 'tape' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var namedtypedtuple = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof namedtypedtuple, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a tuple has a `findLast` method', function test( t ) { + var Point; + var p; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point(); + + t.strictEqual( hasProp( p, 'findLast' ), true, 'returns expected value' ); + t.strictEqual( isFunction( p.findLast ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a tuple instance', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.findLast.call( value, fcn ); + }; + } + + function fcn( v ) { + return v > 0; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.findLast( value ); + }; + } +}); + +tape( 'the method returns the last element which passes a test', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 3.0, 1.0, 2.0 ] ); + out = p.findLast( predicate ); + + t.strictEqual( out, 2.0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return v > 1; + } +}); + +tape( 'the method returns `undefined` if no element passes a test', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 3.0, 1.0, 2.0 ] ); + out = p.findLast( predicate ); + + t.strictEqual( out, void 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return v > 10; + } +}); + +tape( 'the method iterates from right to left', function test( t ) { + var indices; + var values; + var Point; + var p; + + indices = []; + values = []; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + p.findLast( predicate ); + + t.deepEqual( values, [ 3, 2, 1 ], 'returns expected value' ); + t.deepEqual( indices, [ 2, 1, 0 ], 'returns expected value' ); + t.end(); + + function predicate( v, i ) { + values.push( v ); + indices.push( i ); + return false; + } +}); + +tape( 'the method provides four arguments to the predicate function', function test( t ) { + var fieldNames; + var indices; + var values; + var tuples; + var Point; + var p; + + indices = []; + values = []; + fieldNames = []; + tuples = []; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + p.findLast( fcn ); + + t.deepEqual( values, [ 3, 2, 1 ], 'returns expected value' ); + t.deepEqual( indices, [ 2, 1, 0 ], 'returns expected value' ); + t.deepEqual( fieldNames, [ 'z', 'y', 'x' ], 'returns expected value' ); + t.strictEqual( tuples[ 0 ], p, 'returns expected value' ); + t.strictEqual( tuples[ 1 ], p, 'returns expected value' ); + t.strictEqual( tuples[ 2 ], p, 'returns expected value' ); + + t.end(); + + function fcn( v, i, fieldName, tuple ) { + values.push( v ); + indices.push( i ); + fieldNames.push( fieldName ); + tuples.push( tuple ); + return false; + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var Point; + var ctx; + var p; + + ctx = { + 'count': 0 + }; + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + p.findLast( fcn, ctx ); + + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function fcn() { + this.count += 1; // eslint-disable-line no-invalid-this + return false; + } +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last_field.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last_field.js new file mode 100644 index 000000000000..6b10dfbe4502 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last_field.js @@ -0,0 +1,233 @@ +/** +* @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 tape = require( 'tape' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var namedtypedtuple = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof namedtypedtuple, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a tuple has a `findLastField` method', function test( t ) { + var Point; + var p; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point(); + + t.strictEqual( hasProp( p, 'findLastField' ), true, 'returns expected value' ); + t.strictEqual( isFunction( p.findLastField ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a tuple instance', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.findLastField.call( value, fcn ); + }; + } + + function fcn( v ) { + return v > 0; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.findLastField( value ); + }; + } +}); + +tape( 'the method returns the field of the last element which passes a test', function test( t ) { + var Point; + var field; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 3.0, 1.0, 2.0 ] ); + field = p.findLastField( predicate ); + + t.strictEqual( field, 'z', 'returns expected value' ); + t.end(); + + function predicate( v ) { + return v > 1; + } +}); + +tape( 'the method returns `undefined` if no element passes a test', function test( t ) { + var Point; + var field; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 3.0, 1.0, 2.0 ] ); + field = p.findLastField( predicate ); + + t.strictEqual( field, void 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return v > 10; + } +}); + +tape( 'the method iterates from right to left', function test( t ) { + var indices; + var values; + var Point; + var field; + var p; + + indices = []; + values = []; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + field = p.findLastField( predicate ); + + t.deepEqual( values, [ 3, 2, 1 ], 'returns expected value' ); + t.deepEqual( indices, [ 2, 1, 0 ], 'returns expected value' ); + t.strictEqual( field, void 0, 'returns expected value' ); + t.end(); + + function predicate( v, i ) { + values.push( v ); + indices.push( i ); + return false; + } +}); + +tape( 'the method provides four arguments to the predicate function', function test( t ) { + var fieldNames; + var indices; + var values; + var tuples; + var Point; + var p; + + indices = []; + values = []; + fieldNames = []; + tuples = []; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + p.findLastField( fcn ); + + t.deepEqual( values, [ 3, 2, 1 ], 'returns expected value' ); + t.deepEqual( indices, [ 2, 1, 0 ], 'returns expected value' ); + t.deepEqual( fieldNames, [ 'z', 'y', 'x' ], 'returns expected value' ); + t.strictEqual( tuples[ 0 ], p, 'returns expected value' ); + t.strictEqual( tuples[ 1 ], p, 'returns expected value' ); + t.strictEqual( tuples[ 2 ], p, 'returns expected value' ); + + t.end(); + + function fcn( v, i, fieldName, tuple ) { + values.push( v ); + indices.push( i ); + fieldNames.push( fieldName ); + tuples.push( tuple ); + return false; + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var Point; + var ctx; + var p; + + ctx = { + 'count': 0 + }; + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + p.findLastField( fcn, ctx ); + + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function fcn() { + this.count += 1; // eslint-disable-line no-invalid-this + return false; + } +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last_index.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last_index.js new file mode 100644 index 000000000000..f5f7cd8bb99a --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.find_last_index.js @@ -0,0 +1,233 @@ +/** +* @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 tape = require( 'tape' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var namedtypedtuple = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof namedtypedtuple, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a tuple has a `findLastIndex` method', function test( t ) { + var Point; + var p; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point(); + + t.strictEqual( hasProp( p, 'findLastIndex' ), true, 'returns expected value' ); + t.strictEqual( isFunction( p.findLastIndex ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a tuple instance', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.findLastIndex.call( value, fcn ); + }; + } + + function fcn( v ) { + return v > 0; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.findLastIndex( value ); + }; + } +}); + +tape( 'the method returns the index of the last element which passes a test', function test( t ) { + var Point; + var idx; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 3.0, 1.0, 2.0 ] ); + idx = p.findLastIndex( predicate ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return v > 1; + } +}); + +tape( 'the method returns `-1` if no element passes a test', function test( t ) { + var Point; + var idx; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 3.0, 1.0, 2.0 ] ); + idx = p.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return v > 10; + } +}); + +tape( 'the method iterates from right to left', function test( t ) { + var indices; + var values; + var Point; + var idx; + var p; + + indices = []; + values = []; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + idx = p.findLastIndex( predicate ); + + t.deepEqual( values, [ 3, 2, 1 ], 'returns expected value' ); + t.deepEqual( indices, [ 2, 1, 0 ], 'returns expected value' ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v, i ) { + values.push( v ); + indices.push( i ); + return false; + } +}); + +tape( 'the method provides four arguments to the predicate function', function test( t ) { + var fieldNames; + var indices; + var values; + var tuples; + var Point; + var p; + + indices = []; + values = []; + fieldNames = []; + tuples = []; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + p.findLastIndex( fcn ); + + t.deepEqual( values, [ 3, 2, 1 ], 'returns expected value' ); + t.deepEqual( indices, [ 2, 1, 0 ], 'returns expected value' ); + t.deepEqual( fieldNames, [ 'z', 'y', 'x' ], 'returns expected value' ); + t.strictEqual( tuples[ 0 ], p, 'returns expected value' ); + t.strictEqual( tuples[ 1 ], p, 'returns expected value' ); + t.strictEqual( tuples[ 2 ], p, 'returns expected value' ); + + t.end(); + + function fcn( v, i, fieldName, tuple ) { + values.push( v ); + indices.push( i ); + fieldNames.push( fieldName ); + tuples.push( tuple ); + return false; + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var Point; + var ctx; + var p; + + ctx = { + 'count': 0 + }; + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1, 2, 3 ] ); + p.findLastIndex( fcn, ctx ); + + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function fcn() { + this.count += 1; // eslint-disable-line no-invalid-this + return false; + } +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.to_reversed.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.to_reversed.js new file mode 100644 index 000000000000..94a5aa6268b9 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.to_reversed.js @@ -0,0 +1,176 @@ +/** +* @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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var namedtypedtuple = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof namedtypedtuple, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a tuple has a `toReversed` method', function test( t ) { + var Point; + var p; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point(); + + t.strictEqual( hasOwnProp( p, 'toReversed' ), true, 'returns expected value' ); + t.strictEqual( isFunction( p.toReversed ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a tuple instance', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.toReversed.call( value ); + }; + } +}); + +tape( 'the method returns a new tuple with elements in reversed order', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.toReversed(); + + t.notEqual( out, p, 'returns expected value' ); + t.strictEqual( out[ 0 ], 3.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 1.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not mutate the host tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.toReversed(); + + t.strictEqual( p[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( p[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( p[ 2 ], 3.0, 'returns expected value' ); + t.notEqual( out, p, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a named typed tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.toReversed(); + + t.strictEqual( hasOwnProp( out, 'fields' ), true, 'returns expected value' ); + t.deepEqual( out.fields, [ 'x', 'y', 'z' ], 'returns expected value' ); + t.strictEqual( typeof out.subtuple, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the method preserves field-value associations', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.toReversed(); + + t.strictEqual( out.x, 1.0, 'returns expected value' ); + t.strictEqual( out.y, 2.0, 'returns expected value' ); + t.strictEqual( out.z, 3.0, 'returns expected value' ); + t.deepEqual( out.orderedFields, [ 'z', 'y', 'x' ], 'returns expected value' ); + t.end(); +}); + +tape( 'the method preserves the same data type as the host tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ], 'int32' ); + out = p.toReversed(); + + t.strictEqual( out[ 0 ], 3, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2, 'returns expected value' ); + t.strictEqual( out[ 2 ], 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned tuple has the `orderedFields` property reflecting the reversed order', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z', 'w', 'v' ] ); + p = new Point( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] ); + out = p.toReversed(); + + t.strictEqual( out[ 0 ], -2.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); + t.strictEqual( out[ 3 ], -1.0, 'returns expected value' ); + t.strictEqual( out[ 4 ], 1.0, 'returns expected value' ); + t.deepEqual( out.orderedFields, [ 'v', 'w', 'z', 'y', 'x' ], 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.to_sorted.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.to_sorted.js new file mode 100644 index 000000000000..2ff4be5125a5 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.to_sorted.js @@ -0,0 +1,231 @@ +/** +* @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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var namedtypedtuple = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof namedtypedtuple, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a tuple has a `toSorted` method', function test( t ) { + var Point; + var p; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point(); + + t.strictEqual( hasOwnProp( p, 'toSorted' ), true, 'returns expected value' ); + t.strictEqual( isFunction( p.toSorted ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a tuple instance', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.toSorted.call( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.toSorted( value ); + }; + } +}); + +tape( 'the method returns a new tuple sorted in ascending order', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 2.0, -3.0, 0.0 ] ); + out = p.toSorted(); + + t.notEqual( out, p, 'returns expected value' ); + t.strictEqual( out[ 0 ], -3.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 2.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not mutate the host tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 2.0, -3.0, 0.0 ] ); + out = p.toSorted(); + + t.strictEqual( p[ 0 ], 2.0, 'returns expected value' ); + t.strictEqual( p[ 1 ], -3.0, 'returns expected value' ); + t.strictEqual( p[ 2 ], 0.0, 'returns expected value' ); + t.notEqual( out, p, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a named typed tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 2.0, -3.0, 0.0 ] ); + out = p.toSorted(); + + t.strictEqual( hasOwnProp( out, 'fields' ), true, 'returns expected value' ); + t.deepEqual( out.fields, [ 'x', 'y', 'z' ], 'returns expected value' ); + t.strictEqual( typeof out.subtuple, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports a custom comparison function', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 2.0, -3.0, 0.0 ] ); + + out = p.toSorted( descending ); + + t.strictEqual( out[ 0 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], -3.0, 'returns expected value' ); + t.end(); + + function descending( a, b ) { + return b - a; + } +}); + +tape( 'the method preserves the same data type as the host tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 2.0, -3.0, 0.0 ], 'int32' ); + out = p.toSorted(); + + t.strictEqual( out[ 0 ], -3, 'returns expected value' ); + t.strictEqual( out[ 1 ], 0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned tuple has the `orderedFields` property reflecting the sorted order', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z', 'w', 'v' ] ); + p = new Point( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] ); + out = p.toSorted(); + + t.strictEqual( out[ 0 ], -2.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], -1.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); + t.strictEqual( out[ 3 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 4 ], 2.0, 'returns expected value' ); + t.deepEqual( out.orderedFields, [ 'v', 'y', 'z', 'x', 'w' ], 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new tuple sorted in ascending order (cyclic)', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 3.0, 1.0, 2.0 ] ); + out = p.toSorted(); + + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3.0, 'returns expected value' ); + t.strictEqual( out.x, 3.0, 'returns expected value' ); + t.strictEqual( out.y, 1.0, 'returns expected value' ); + t.strictEqual( out.z, 2.0, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.with.js b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.with.js new file mode 100644 index 000000000000..0e1b106ec015 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/named-typed-tuple/test/test.with.js @@ -0,0 +1,221 @@ +/** +* @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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var namedtypedtuple = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof namedtypedtuple, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a tuple has a `with` method', function test( t ) { + var Point; + var p; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point(); + + t.strictEqual( hasOwnProp( p, 'with' ), true, 'returns expected value' ); + t.strictEqual( isFunction( p.with ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a tuple instance', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.with.call( value, 0, 1.0 ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { + var values; + var Point; + var p; + var i; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return p.with( value, 1.0 ); + }; + } +}); + +tape( 'the method throws a range error if the index is out of bounds', function test( t ) { + var Point; + var p; + + Point = namedtypedtuple( [ 'x', 'y' ] ); + p = new Point( [ 1, 2 ] ); + + t.throws( function badValue() { + return p.with( 5, 1.0 ); + }, RangeError, 'throws an error' ); + t.throws( function badValue() { + return p.with( -5, 1.0 ); + }, RangeError, 'throws an error' ); + t.end(); +}); + +tape( 'the method returns a new tuple with the element at the specified index replaced', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.with( 1, 99.0 ); + + t.notEqual( out, p, 'returns expected value' ); + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 99.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not mutate the host tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.with( 1, 99.0 ); + + t.strictEqual( p[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( p[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( p[ 2 ], 3.0, 'returns expected value' ); + t.notEqual( out, p, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a named typed tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.with( 1, 99.0 ); + + t.strictEqual( hasOwnProp( out, 'fields' ), true, 'returns expected value' ); + t.deepEqual( out.fields, [ 'x', 'y', 'z' ], 'returns expected value' ); + t.strictEqual( typeof out.subtuple, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports negative indices', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.with( -1, 99.0 ); + + t.strictEqual( out[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2.0, 'returns expected value' ); + t.strictEqual( out[ 2 ], 99.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method preserves the same data type as the host tuple', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ], 'int32' ); + out = p.with( 0, 99 ); + + t.strictEqual( out[ 0 ], 99, 'returns expected value' ); + t.strictEqual( out[ 1 ], 2, 'returns expected value' ); + t.strictEqual( out[ 2 ], 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned tuple reflects the updated value via field accessors', function test( t ) { + var Point; + var out; + var p; + + Point = namedtypedtuple( [ 'x', 'y', 'z' ] ); + p = new Point( [ 1.0, 2.0, 3.0 ] ); + out = p.with( 1, 99.0 ); + + t.strictEqual( out.x, 1.0, 'returns expected value' ); + t.strictEqual( out.y, 99.0, 'returns expected value' ); + t.strictEqual( out.z, 3.0, 'returns expected value' ); + t.end(); +});