Skip to content

shinnn/get-lodash-aliases

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-lodash-aliases

NPM version Build Status Coverage Status dependencies Status devDependencies Status

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

Use npm.

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.

About

Get alias names of Lodash methods from the latest API document

Resources

License

Stars

Watchers

Forks

Packages

No packages published