From cd11be6b71d3c93e248a78f3649ea64da07c9463 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Tue, 6 Oct 2026 00:18:27 +0530 Subject: [PATCH 1/2] fix: correct nary loop bound in mask-arguments and pick-arguments --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/utils/mask-arguments/lib/main.js | 2 +- lib/node_modules/@stdlib/utils/pick-arguments/lib/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/mask-arguments/lib/main.js b/lib/node_modules/@stdlib/utils/mask-arguments/lib/main.js index 102935b06985..70e19f1b56e8 100644 --- a/lib/node_modules/@stdlib/utils/mask-arguments/lib/main.js +++ b/lib/node_modules/@stdlib/utils/mask-arguments/lib/main.js @@ -148,7 +148,7 @@ function maskArguments( fcn, mask, thisArg ) { var i; args = []; - for ( i = 0; i < arguments.length; i++ ) { + for ( i = 0; i < idx.length; i++ ) { args.push( arguments[ idx[i] ] ); } return fcn.apply( thisArg, args ); diff --git a/lib/node_modules/@stdlib/utils/pick-arguments/lib/main.js b/lib/node_modules/@stdlib/utils/pick-arguments/lib/main.js index 2d1fdd42915a..24d6ed0e5882 100644 --- a/lib/node_modules/@stdlib/utils/pick-arguments/lib/main.js +++ b/lib/node_modules/@stdlib/utils/pick-arguments/lib/main.js @@ -148,7 +148,7 @@ function pickArguments( fcn, indices, thisArg ) { var i; args = []; - for ( i = 0; i < arguments.length; i++ ) { + for ( i = 0; i < idx.length; i++ ) { args.push( arguments[ idx[i] ] ); } return fcn.apply( thisArg, args ); From 7db3b0c06a8d172704121fa00098f3b61b2f8ed9 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Tue, 6 Oct 2026 00:35:06 +0530 Subject: [PATCH 2/2] test: added tests for nary in pick, mask arguments --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/utils/mask-arguments/test/test.js | 36 +++++++++++++++++++ .../@stdlib/utils/pick-arguments/test/test.js | 36 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/lib/node_modules/@stdlib/utils/mask-arguments/test/test.js b/lib/node_modules/@stdlib/utils/mask-arguments/test/test.js index 289dc26c3744..805caf337432 100644 --- a/lib/node_modules/@stdlib/utils/mask-arguments/test/test.js +++ b/lib/node_modules/@stdlib/utils/mask-arguments/test/test.js @@ -234,6 +234,42 @@ tape( 'the returned function invokes a function according to an argument mask (n } }); +tape( 'the returned function only forwards the masked-in arguments when called with more arguments than mask entries (nary)', function test( t ) { + var bar = maskArguments( foo, [ 1, 1, 1, 1, 1, 1 ] ); + + t.deepEqual( bar( 1, 2, 3, 4, 5, 6, 7, 8 ), [ 6, 1, 2, 3, 4, 5, 6 ], 'returns expected value' ); + t.end(); + + function foo() { + var args; + var i; + + args = [ arguments.length ]; + for ( i = 0; i < arguments.length; i++ ) { + args.push( arguments[ i ] ); + } + return args; + } +}); + +tape( 'the returned function forwards the masked-in arguments when called with fewer arguments than mask entries (nary)', function test( t ) { + var bar = maskArguments( foo, [ 1, 1, 1, 1, 1, 1 ] ); + + t.deepEqual( bar( 1, 2, 3 ), [ 6, 1, 2, 3, void 0, void 0, void 0 ], 'returns expected value' ); + t.end(); + + function foo() { + var args; + var i; + + args = [ arguments.length ]; + for ( i = 0; i < arguments.length; i++ ) { + args.push( arguments[ i ] ); + } + return args; + } +}); + tape( 'the function supports providing a `this` context', function test( t ) { var ctx; var bar; diff --git a/lib/node_modules/@stdlib/utils/pick-arguments/test/test.js b/lib/node_modules/@stdlib/utils/pick-arguments/test/test.js index 3ab8c7200222..47ac0c93b8d5 100644 --- a/lib/node_modules/@stdlib/utils/pick-arguments/test/test.js +++ b/lib/node_modules/@stdlib/utils/pick-arguments/test/test.js @@ -236,6 +236,42 @@ tape( 'the returned function invokes a function with specified arguments (nary)' } }); +tape( 'the returned function only forwards the specified number of arguments when called with more arguments than indices (nary)', function test( t ) { + var bar = pickArguments( foo, [ 0, 1, 2, 3, 4, 5 ] ); + + t.deepEqual( bar( 1, 2, 3, 4, 5, 6, 7, 8 ), [ 6, 1, 2, 3, 4, 5, 6 ], 'returns expected value' ); + t.end(); + + function foo() { + var args; + var i; + + args = [ arguments.length ]; + for ( i = 0; i < arguments.length; i++ ) { + args.push( arguments[ i ] ); + } + return args; + } +}); + +tape( 'the returned function forwards the specified number of arguments when called with fewer arguments than indices (nary)', function test( t ) { + var bar = pickArguments( foo, [ 0, 1, 2, 3, 4, 5 ] ); + + t.deepEqual( bar( 1, 2, 3 ), [ 6, 1, 2, 3, void 0, void 0, void 0 ], 'returns expected value' ); + t.end(); + + function foo() { + var args; + var i; + + args = [ arguments.length ]; + for ( i = 0; i < arguments.length; i++ ) { + args.push( arguments[ i ] ); + } + return args; + } +}); + tape( 'the function supports providing a `this` context', function test( t ) { var ctx; var bar;