alias-keys
v1.0.4
Published
A simple method for aliasing values in objects
Downloads
5
Readme
alias-keys
A simple method for aliasing values in objects
Usage
First, install the package and add it to your dependencies.
$ npm install alias-keys
Then, require the module within your project,
const { alias } = require('alias-keys');
and create an object with alias keys in an aliases
array property of the corresponding value.
let object = {
'javascript': {
fileExtension: '.js',
aliases: ['js']
},
'c-sharp': {
fileExtension: '.cs',
aliases: ['c#']
}
}
console.log(alias(object)('javascript'))
// -> { fileExtension: '.js', aliases: ['js'] }
console.log(alias(object)('js'))
// -> { fileExtension: '.js', aliases: ['js'] }