const { optionize , stick } = require( "modulopt" );
const mySoft = { hello : "World !" };
stick( optionize( mySoft, [
// a boolean option
[ "foo" , true ],
// a boolean option
[ "bar" , false ],
// a multichoice
[ "foobar" , "normal" ,
[ "surprizing" , "crazy" , "sick" , "rad" ]
],
// a multichoice
[ "someval" , 0 ,
[ 5 , 3.14 , 8.1 , Math.NAN ]
],
// half-free option (only strings accepted because the default is of type string)
[ "bye", "World !"],
// half-free option (only number accepted because the default is of type number)
[ "age", 10 ],
// free option, nothing is specified other than the option name
[ "favourite", null ]
] ),
// we stick these values for the options
{foobar:"crazy", foo: false, bar: true, hello:"world !"}
);
console.log(
"Here are the in - place options" , mySoft.options ,
"Here are the options attached on mySoft" , mySoft.modulopt
);
const mask = "0000.0010.0000";
const isanObj = {
bye : "for now !",
favourite : { animal : "dog" },
age : "ten"
} ;
stick( mySoft , mask, isanObj );
console.log( "Here are the new in - place options (via masks and object)" , mySoft.options );
stick( mySoft , { favourite : "listening to music, actually ..."} );
console.log( "Here are the the new favourite" , mySoft.options.favourite );