Wrap a function to modify its options object argument to be merged with default options and wrapped in an objPop instance with type checking.
This module exports one function:
Returns the wrapper function, based on your function origFunc
and default options dfOpt
.
metaOpt
is an optional options object that supports these keys:
-
optArgIdx
: Which argument toorigFunc
will be the options object. Defaults to0
, i.e. first argument. -
mergeOpt
: The options merging function to be used. If false-y, the default (merge-options
) will be used. -
validate
: The validator function to be used. If false-y, the default (typechecks-pmb/must-be
) will be used. -
leftoversMsg
: Error message in case some keys from the (copy of the) options object have not been popped. Set tofalse
to skip this check. Defaults to something like'Unsupported leftover option(s)'
. -
popOpt
: Custom options to pass along toobjpop
. -
promising
: Boolean, whetherorigFunc
is expected to return a Promise or then-able. Can also be (and defaults to)null
, in which case the function result is treated as a promise if it has a.then
method. This determines whether the
:TODO:
- Needs more/better tests and docs.
ISC