Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/utils/mask-arguments/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
36 changes: 36 additions & 0 deletions lib/node_modules/@stdlib/utils/mask-arguments/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/utils/pick-arguments/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
36 changes: 36 additions & 0 deletions lib/node_modules/@stdlib/utils/pick-arguments/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading