3 ms·
Performance aside, also consider Ramda.js Although Ramda has forEach, I augment it with a version of each(func, data) where data can be an array or map, and fu
by jgord 8y ago
Performance aside, also consider Ramda.js
Although Ramda has forEach, I augment it with a version of each(func, data) where data can be an array or map, and func(val, key) where key is the key of the map item, or the index of the item in the array.
I feel this abuse of notation makes for more readable / smaller / uniform code [ having no explicit for loops ]. Also takes less conceptual space.
- jrs95 8y ago+1 for Ramda -- I've been using it for around 2 years now and once you get comfortable with how to compose it's various functions (and some of your own) it's super powerful. Might not be the best choice if your team is allergic to FP though, some people have a difficult time wrapping their head around it (or just getting used to the syntax). I've gone out of my way to document everything thoroughly knowing people who are mostly unfamiliar with FP will be looking at it though, and that's kept everyone happy.
- Rick-Butler 8y agoLodash is fairly ubiquitous, you can sneak in some lodash fp into projects. Dalton even has it aliased for ramda. The artity for certain functions might be different I didn’t check. https://github.com/lodash/lodash/commit/6b2645b3106b0ed9ebec2fc2f81a372462c6ff0d https://github.com/lodash/lodash/commit/6b2645b3106b0ed9ebec...