danhper / lodash-inflection

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

Suggestion: Add `import` example for ES Modules #12

Open owen-calico opened 3 years ago

owen-calico commented 3 years ago

The README example for hooking this up uses require(), which some tooling doesn't like. The following works for me using the import syntax:

import _ from "lodash"
import inflection from "lodash-inflection"
_.mixin(inflection)

You might consider adding this as alternative setup example.

Note that in typescript you'll have to @ts-ignore the import -- unless there's typescript bindings for the inflection functions somewhere, I couldn't find them on Definitively Typed. So that would be:

import _ from "lodash"
// @ts-ignore
import inflection from "lodash-inflection"
_.mixin(inflection)

Thanks!