What is it?

Unmutable follows immutable.js’s API almost exactly, and but exports each method individually as a point-free function, in the same way as lodash/fp does. These functions are all immutable, and can be composed together easily.

Unmutable also works seamlessly on plain Javascript objects and arrays, Immutable.js Maps, Lists and Records. It can also works on your own classes if you make them unmutable-compatible.

Examples

For now, Unmutable is for use with objects and arrays, Immutable.js Maps, Lists, and Records, and unmutable-compatible classes.

Each Unmutable function returns a function that accepts the value to operate on:

Then if you want to call more functions in a chain you can use Unmutable’s pipe function, which can be used to squish a set of functions together, like this:

import get from 'unmutable/get';
import last from 'unmutable/last';
import pipe from 'unmutable/pipe';
let data = [
{name: "Bob"},
{name: "Jenny"},
{name: "Herbert!"}
];
let getLastName = pipe(
last(),
get('name')
);
let name = getLastName(data); // Herbert!
// you dont pass your data in until the very end by calling the returned function.
// this is known as point-free programming, and allows for very composable functions.

Or if you prefer to pass your data in first, use Unmutable’s pipeWith function:

Getting Started

API

Inspiration

Immutable.js has a wonderfully symmetrical and well thought out API, and it deals with data immutably.
Its a fantastic library, but its drawbacks are that it’s large in size and impossible to take only the parts of the API you want, which makes it quite unsuitable for small Javascript libraries. It also requires you use its special data types which can involve a lot of to-ing and fro-ing between normal Javascript types and Immutable.js types.

Ramdajs and Lodash/fp both allow for functions to be composed together point-free style, which is a really nice way of programming, and it naturally keeps the bundle size small as you only import what you need.
Lodash/fp’s main drawback is that its API is large, unwieldy and unpredictable. Ramdajs’ API is better planned, but it’s overall pretty esoteric and alien to programmers who are not used to fully functional languages.
And both of those libraries use currying, which unmutable deliberately avoids*.