Gathering detailed insights and metrics for @stdlib/utils-pick-arguments
Gathering detailed insights and metrics for @stdlib/utils-pick-arguments
Create a function that invokes a provided function with specified arguments.
npm install @stdlib/utils-pick-arguments
Typescript
Module System
Min. Node Version
Node Version
NPM Version
65.9
Supply Chain
82.6
Quality
82
Maintenance
100
Vulnerability
87.6
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
2,626
Last Day
3
Last Week
13
Last Month
70
Last Year
514
Apache-2.0 License
1 Stars
46 Commits
3 Watchers
5 Branches
11 Contributors
Updated on Dec 01, 2024
Minified
Minified + Gzipped
Latest Version
0.2.2
Package Id
@stdlib/utils-pick-arguments@0.2.2
Unpacked Size
34.66 kB
Size
9.45 kB
File Count
11
NPM Version
8.19.4
Node Version
16.20.2
Published on
Jul 28, 2024
Cumulative downloads
Total Downloads
Last Day
50%
3
Compared to previous day
Last Week
8.3%
13
Compared to previous week
Last Month
34.6%
70
Compared to previous month
Last Year
-37.6%
514
Compared to previous year
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Create a function that invokes a provided function with specified arguments.
1npm install @stdlib/utils-pick-arguments
1var pickArguments = require( '@stdlib/utils-pick-arguments' );
Returns a function
that invokes a provided function with specified arguments.
1function foo( a, b ) { 2 return [ a, b ]; 3} 4 5var bar = pickArguments( foo, [ 0, 2 ] ); 6 7var out = bar( 1, 2, 3 ); 8// returns [ 1, 3 ]
To set the this
context when invoking the provided function, provide a thisArg
.
1function Foo() { 2 this.x = 1; 3 this.y = 2; 4} 5 6Foo.prototype.scale = function scale( a, b ) { 7 return [ this.x*a, this.y*b ]; 8}; 9 10var ctx = { 11 'x': 10, 12 'y': 20 13}; 14 15var foo = new Foo(); 16 17var bar = pickArguments( foo.scale, [ 0, 2 ], ctx ); 18 19var out = bar( 1, 2, 3 ); 20// returns [ 10, 60 ]
1var filledarrayBy = require( '@stdlib/array-filled-by' ); 2var add = require( '@stdlib/math-base-ops-add' ); 3var pickArguments = require( '@stdlib/utils-pick-arguments' ); 4 5function fill( i ) { 6 return i; 7} 8 9// Create a data array: 10var x = filledarrayBy( 10, 'float64', fill ); 11 12// Compute the sum of consecutive elements... 13var f; 14var i; 15for ( i = 1; i < x.length; i++ ) { 16 f = pickArguments( add, [ i-1, i ] ); 17 console.log( 'sum(x_%d, x_%d) = %d', i-1, i, f.apply( null, x ) ); 18}
@stdlib/utils-reorder-arguments
: create a function that invokes a provided function with reordered arguments.@stdlib/utils-reverse-arguments
: create a function that invokes a provided function with arguments in reverse order.This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
No vulnerabilities found.
No security vulnerabilities found.