Any way to use immutable.js with lodash?

Glen Swift picture Glen Swift · May 7, 2015 · Viewed 12.8k times · Source

I'm using immutable.js with my flux application. It is very useful and gives performance boost. But what actually makes me sad is the fact that I can't use lodash together with it. Lodash provides great API with ton of useful functions, so I wonder maybe there is a way to get them together to work for me?

Answer

Brett Hayes picture Brett Hayes · Dec 9, 2015

You could use Ramda if you want immutability and side-effect free functions.

The library provides useful functions similar to lodash but in a functional programming style that never mutates user data.

Consider this React example using the flatten function in Ramda using ES6 syntax.

import { flatten } from 'ramda';  

const users = ['Steve Jobs', ['Steve Wozniak']];
const flatUsers = flatten(users);

// returns ['Steve Jobs', 'Steve Wozniak']