Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use _.runInContext #2

Open
jdalton opened this issue Apr 1, 2015 · 3 comments
Open

Use _.runInContext #2

jdalton opened this issue Apr 1, 2015 · 3 comments

Comments

@jdalton
Copy link

jdalton commented Apr 1, 2015

You can use:

var _ = require('lodash').runInContext();

to create a pristine lodash function that can be extended with mixins without causing potential conflicts with the lodash package.

@jonschlinkert
Copy link
Owner

I was just wondering about this and planning to look into it, thanks! how did you read my mind lol.

I'm curious, does Lo-Dash by any chance also offer a clean way avoiding potential conflicts between functions passed on imports and same-named properties on the context, for example, when both foo and foo() are passed?

@jdalton
Copy link
Author

jdalton commented Apr 1, 2015

_.mixin overwrites existing methods. You could run an _.omit over the object you provide to it:

_.mixin(_.omit(object, _.functions(_)));

@jonschlinkert
Copy link
Owner

Hmm, that's similar to the thinking behind what I was doing here, without knowing that mixin would override methods no matter what. Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants