danhper / lodash-inflection

ActiveSupport::Inflector, for lodash!
MIT License
30 stars 6 forks source link

How do I include this? #3

Closed hakunin closed 8 years ago

hakunin commented 8 years ago

Hi, I am just starting with es6 and react and I know I need to do this to include lodash:

import _ from 'lodash';

..but how do I include lodash-inflection?

As of now, I get

Uncaught TypeError: _lodash2.default.pluralize is not a function
danhper commented 8 years ago

It is a normal lodash mixin, so you use need to do

import _ from 'lodash';
import _inflection from 'lodash-inflection';
_.mixin(_inflection);

to get it to work. If you use it often, you can create a module which exports lodash with the module mixed in.

hakunin commented 8 years ago

Thanks!

gnapse commented 7 years ago

Does this always has to be mixed into lodash? I'm using lodash not by importing it completely, but by individually importing each lodash function I need:

import camelCase from 'lodash/camelCase';

console.log(camelCase('hello_world'));

Is there a way to include the functions in this library in a similar fashion? Perhaps something like this:

import pluralize from 'lodash-inflection/pluralize';
danhper commented 7 years ago

This is currently not supported, but a PR would be welcome as long as it does not break backward compatibility. Thanks.

pzrq commented 6 years ago

As this issue is closed, apologies for commenting on it.

A colleague suggested I look into lodash pluralize, and Google led me here. Another colleague then suggested:

https://www.npmjs.com/package/pluralize

danhper commented 6 years ago

Both modules do basically the same thing, the only noticeable difference is probably that this one is a lodash mixin and relies on lodash.