get-lodash-aliases
v1.0.0
Published
Get alias names of Lodash methods from the latest API document
Downloads
2
Maintainers
Readme
get-lodash-aliases
A Node module to get alias names of Lodash methods from the latest API document
const getLodashAliases = require('get-lodash-aliases');
getLodashAliases().then(originalNameAliasNameMap => {
originalNameAliasNameMap;
/* => {
head: ['first'],
forEach: ['each'],
forEachRight: ['eachRight'],
assignIn: ['extend'],
assignInWith: ['extendWith'],
toPairs: ['entries'],
toPairsIn: ['entriesIn'],
'prototype.value': [
'prototype.toJSON',
'prototype.valueOf'
]
} */
});
Installation
npm install get-lodash-aliases
API
const getLodashAliases = require('get-lodash-aliases');
getLodashAliases([options])
options: Object
(gh-get options)
Return: Promise
of Object
Lodash has some alias methods for backward compatibility. For exmaple _.first
was renamed to _.head
in v4.0.0 and at the same time re-added as an alias of _.head
.
This module fetches the latest Lodash API document via Github API, parse it and extract the combination of original method names and alias ones.
The resolved object is in the following form:
{
"originalLodashMethodName": [
"aliasLodashMethodName",
// ...
],
// ...
}
getLodashAliases().then(result => {
result.head; //=> ['first']
// This means "`_.head` has one alias: `_.first`.
result['prototype.value']; //=> ['prototype.toJSON', 'prototype.valueOf']
// This means `_.prototype.value` has two aliases: `_.prototype.toJSON` and `_.prototype.valueOf`.
});
License
Copyright (c) 2016 Shinnosuke Watanabe
Licensed under the MIT License.