Hi all,
Was it discussed if meteor would switch from underscore to lodash in the future? Or do I have the possibility to switch to using lodash?
thanks
Hi all,
Was it discussed if meteor would switch from underscore to lodash in the future? Or do I have the possibility to switch to using lodash?
thanks
for your project you can use loadash but it can come to namespace problems i think
meteor add alethes:lodash
Then, in a file on both client and server:
// Use lodash instead of underscore
_ = lodash;
I did this in a large, complex app that relies heavily on a whole range of underscore functions and everything works fine.
It might be a while until they decide to switch over because it’s going to involve an astronomical amount of QA it seems, which is understandable.
Does anyone know if there is an exhaustive list of incompatibilities somewhere?
From what I see, lodash has everything underscore has and more. And it has quite a few optimizations in functions like _.reduce
that are not in underscore.
I’m quite interested in this too! I have been using lodash for a long time now in other projects, but due to the way meteor and underscore seem so heavily dependent I haven’t tried switching over. It would be really cool to see some official support for lodash, as I think it’s generally considered the better library.
True that. I’m using a pretty out-of-date version.
I was trying to replace the built-in dependency of underscore from meteor-platform by creating a local package underscore and simply replacing underscore.js with lodash.js, however, I kept getting this error:
While preparing to build package underscore:
error: circular dependency between packages underscore and meteor
My package.js looks like this:
Package.describe({
name: "underscore",
summary: "Underscore",
version: "1.0.3"
});
Package.on_use(function(api) {
api.add_files('lodash.js');
api.export('_');
});
What could’ve gone wrong?
The reason I’m doing this is so that I can see whether it’ll work and maybe start testing it.
Hey guys, so looks like I finally nailed it. You can replace underscore with lodash (not by installing a lodash package).
I’ve created a repository with how to do it:
Please contribute or let me know of any suggestions.
Just as a pre-emptive note, if you use iron-router (which 90% of you probably do), it will break. Just read the NOTES.md on how to fix that issue.
Lazy.js is my favourite Underscore replacement; it’s not a drop in replacement like Lodash, but it is waaaay faster than either (check the benchmarks) and has all kinds of stream processing goodnes
The performance tests of Lazy.js are using lodash 2.0 which I’m sure is way slower than the new lodash 3+ where they started implementing lazy evaluation. Lazy.js seems to not be active too. J. Dalton on the other hand treats lodash as if it were like drinking water.
What about just updating to the latest Underscore? There’s a few features that aren’t available in the bundled version, and that always trips me up.
@glasser mentions that even updating underscore has caused regressions. I’d really like for people to contribute to the repo I made for any feedback to get this going. I know time is hard to come by, but something is better than nothing.
@lai lol, did you see the thread you posted? @tiandavis seemed pretty upset over there as he swung wildly at all the onlookers in the thread. creatures do that… when they fight for their last breath btw, how is this looking? seriously disadvantaged being forced to use underscore. cheers.