1.0.0 • Published 9 years ago
get-lodash-aliases v1.0.0
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-aliasesAPI
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.