aka-opts
v0.0.3
Published
reduce an options object with alias keys
Downloads
14
Maintainers
Readme
aka-opts
Dealias an options
object. Tiny sugar topping that allows you to accept an options
object full of aliases from your module users with aka-opts
reducing that internally.
Get it!
npm install --save aka-opts
Usage
var dealias = require('aka-opts')
var opts = { frd: 36, zoo: 99, z: 9 }
var conf = { fraud: [ 'f', 'frd' ], zoo: [ 'z' ] }
opts = dealias(opts, conf)
console.log(opts)
// -> { fraud: 36, zoo: 99 }
API
dealias(options, conf)
Dealias options
according to the mappings provided by conf
which should look like:
{
originalKey: [ 'aliasKeyA', 'aliasKeyB' ]
}
Aliases are considered if options
does not have the original key. dealias
uses the first alias value it finds on options
for the original key. dealias
does not mutate options
. All alias properties are stripped off of the return object.