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.
Lightweight in size! Especially if you import only what you need. eg:
// import directly what you needimportclonefrom'lodash/clone';// or if you have tree shakingimport{clone}from'lodash';// or if you use the lodash babel pluginimport_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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.
Lightweight in size! Especially if you import only what you need. eg:
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.