get-lodash-aliases

1.0.0 • Public • Published

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.

Package Sidebar

Install

npm i get-lodash-aliases

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • shinnn