Utils._ (lodash)
See original GitHub issueIn utils.js we can find this piece of code:
const _ = require('lodash').runInContext(); // Prevent anyone messing with template settings by creating a fresh copy
So we are requesting out own instance of lodash that nobody has tempered with. However, all over the codebase lodash is most of the time required directly. Even more, this special instance is not even safe because in sequelize.js we can find:
/**
* A reference to sequelize utilities. Most users will not need to use these utils directly. However, you might want to use `Sequelize.Utils._`, which is a reference to the lodash library, if you don't already have it imported in your project.
* @property Utils
*/
Sequelize.prototype.Utils = Sequelize.Utils = Utils;
So we actually export this special lodash instance (and I don’t understand why - users can easily install require lodash themselves)
Issue Analytics
- State:
- Created 7 years ago
- Comments:18 (16 by maintainers)
Top Results From Across the Web
utils-lodash - npm
Start using utils-lodash in your project by running `npm i utils-lodash`. There are no other projects in the npm registry using utils-lodash.
Read more >Lodash
A JavaScript utility library delivering consistency, modularity, performance, & extras.
Read more >Lodash Utilities - GitHub
A modern JavaScript utility library delivering modularity, performance, & extras. ... Modular Lodash builds without the hassle. ... Smaller modular Lodash builds.
Read more >Lodash Util Complete Reference - GeeksforGeeks
Lodash Util Complete Reference ... Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, ......
Read more >Lodash - Util - Tutorialspoint
Lodash - Util, Lodash has many easy to use Utility methods. This chapter discusses them in detail.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually I think I we should remove the mention of utils completely from the docs
Yeah, if we’re switching all usage of lodash templating to template strings there’s no really any reason to have a lodash reference in utils.
Originally we used run in context because a user reported problems with template strings - lodash allows you to override which characters are used in templates. But as you noticed, we’re not using it anyway…