DEV Community

Discussion on: You Might Not Need Lodash

Collapse
 
gsonderby profile image
Gert Sønderby

I admit I hesitate to call that bit lightweight, at least in terms of reading and understanding it.😀

Your point re. testing and edge cases and so forth is well seen. My example was mainly to give an alternative where a native function does not currently exist.

Thread Thread
 
antjanus profile image
Antonin J. (they/them) • Edited

Lightweight in size! Especially if you import only what you need. eg:

// import directly what you need
import clone from 'lodash/clone';

// or if you have tree shaking
import { clone } from 'lodash';

// or if you use the lodash babel plugin
import _ from 'lodash';

//and then use it!

Reading it isn't too bad but their looping is bizarre to me. It's done for memory/speed use but counting down from a number in a while loop instead of doing a for loop baffles me but I understand they have reasons for it.