
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
a named arguments parser with a consistent robust protocol for JavaScript; via `folding` argumenets in the sense of the computer language Scheme
A named arguments parser with a consistent robust protocol for JavaScript; via
folding argumenets in the sense of the computer language Scheme.
function fold_args(
args, // : array of arguments,
default_args, // : array or an object,
transformers_for_args // : array or an object )
const { fold_args } = require( 'fold-args' );
function func( ...args ) {
const nargs = fold_args( args );
console.log( nargs );
}
func( {foo:'FOO'}, {bar:'BAR'} );
> {foo:['FOO'], bar:['BAR']}
const { fold_args } = require( 'fold-args' );
function func( ...args ) {
const nargs = fold_args( args, ['foo','bar'] );
console.log( nargs );
}
// note that foo and bar are not specified.
func( {bum:'bum'} );
// foo and bar are appeared, though.
> {foo:[],bar:[],bum:['bum']}
const { fold_args } = require( 'fold-args' );
const { the_last } = require( 'fold-args' );
function func( ...args ) {
const nargs = fold_args( args, [], [{ foo: the_last }] );
console.log( nargs );
}
func( {foo:'foo'}, {foo:'FOO'} );
> {foo:'FOO'}
Each value in the arguments are processed in a same manner:
(o)=>( typeof o === 'object' ? o : {[Symbol.for(typeof o)] : o });
const o1 = {
'foo' : 1,
};
const o2 = {
'bar' : 2,
},
The processed object is
const processed = {
'foo' : [1],
'bar' : [2],
};
Relased. (Jan 8 2023)
Updated README.md.
(Jan 8 2023)
Updated README.md.
(Sun, 08 Jan 2023 17:01:38 +0900)
Thank you very much for your attention.
Atsushi Oka / I'm from Tokyo. For further information, see my github account.
FAQs
a named arguments parser with a consistent robust protocol for JavaScript; via `folding` argumenets in the sense of the computer language Scheme
The npm package fold-args receives a total of 0 weekly downloads. As such, fold-args popularity was classified as not popular.
We found that fold-args demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.