Lodash version
-
Which version of lodash is used in the game? 2.4.1? Are there plans to update it to the latest version?
-
nvm the version question - got it by running
console.log(_.VERSION)
- it's 2.4.1;
Upgrade question still stands - is the update to 3.8.x planned?
-
Thanks for pointing it out. Updated to 3.8.0
-
This is excellent news. Thank you!
-
New lodash allows me to retire fugly composite sort keys from
_.sortBy
callbacks in favour of_.sortByAll
, so this part is great.
However, I had some breaking changes in my code, due to the change of behaviour in_.first
.
I was basically using it in 2.4.1 as one would use_.take
in 3.8.0.
So if anyone else was using_.first
with numeric 2nd argument, replace these with_.take
calls.
-
@artch Can you please update the version again? I'm trying to use .uniqBy and getting an error ".uniqBy is not a function". Thanks
-
@reggaeguitar Maybe use _.uniq() instead?
-
lodash 4.17.11 would be great. It has many new functions.
-
It's not backward compatible though. That's a big problem.
-
Maybe the player can choose his version by something like:
Game.setLodashVersion('4.17.11');
which will reset the global context (if version changed) with the desired lodash version.
-
The problem is: game API and wrappers also rely on lodash, and API at least partially runs on the same IVM space as user code. Changing lodash version for user would likely also break those parts of the API.
-
@reggaeguitar You can distribute your own lodash version and do "global._ = ..." to initialise lodash. I did it for a while.
-
It's easy enough to ship a custom lodash version. In the past the size of a custom lodash was a problem but with 5M code limit it should be more doable now.
The local player version of lodash doesn't effect the engine. If you find somewhere it does, report a bug ... or send me a PM in slack.
-
@wtfrank Can you elaborate more please? Thanks for your response!
-
The game engine secretly sets up your global so that the variable global._ corresponds to the engine's copy of lodash.
You can put "global._ = require('lodash');" in your main.ts outside the loop, and add the latest lodash file to your source repository. This means that after a global reset, the engine-provided lodash is replaced with your own version.
-
@wtfrank The default lodash is also provided as a module named 'lodash'. To replace it you'd need to use a different name, like lodash4.