1const lib = require('./nopt-lib') 2const defaultTypeDefs = require('./type-defs') 3 4// This is the version of nopt's API that requires setting typeDefs and invalidHandler 5// on the required `nopt` object since it is a singleton. To not do a breaking change 6// an API that requires all options be passed in is located in `nopt-lib.js` and 7// exported here as lib. 8// TODO(breaking): make API only work in non-singleton mode 9 10module.exports = exports = nopt 11exports.clean = clean 12exports.typeDefs = defaultTypeDefs 13exports.lib = lib 14 15function nopt (types, shorthands, args = process.argv, slice = 2) { 16 return lib.nopt(args.slice(slice), { 17 types: types || {}, 18 shorthands: shorthands || {}, 19 typeDefs: exports.typeDefs, 20 invalidHandler: exports.invalidHandler, 21 }) 22} 23 24function clean (data, types, typeDefs = exports.typeDefs) { 25 return lib.clean(data, { 26 types: types || {}, 27 typeDefs, 28 invalidHandler: exports.invalidHandler, 29 }) 30} 31