Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kitten/extendable-immutable

Wrapper classes around Immutable.js that turn it inheritable
https://github.com/kitten/extendable-immutable

immutable immutablejs

Last synced: about 1 month ago
JSON representation

Wrapper classes around Immutable.js that turn it inheritable

Awesome Lists containing this project

README

        



Wrapper classes around Immutable.js that turn it inheritable







# Extendable [Immutable.js](https://github.com/facebook/immutable-js/)

## About

Ever wished that you could have OrderedMaps, Maps or Lists with extra methods,
that make your life easier? `.ofCourse()`!

- Behaves like normal [Immutable.js](https://github.com/facebook/immutable-js/) data structures
- Doesn't break [Immutable.js'](https://github.com/facebook/immutable-js/) inheritance (*.is and instanceof still pass!)

## Getting Started

Installing the latest version via npm takes just a second:

```bash
npm install --save extendable-immutable
```

Import what you need:

```js
import { OrderedMap } from 'extendable-immutable'

class Collection extends OrderedMap {
// ...
```

## Quick Intro

```js
import { OrderedMap } from 'extendable-immutable'

class Collection extends OrderedMap {
static isCollection(val) {
return val && val instanceof Collection;
}

doMagic() {
return this.map(x => x.set("magic", true));
}
}

const magic = new Collection();

magic instanceof Immutable.OrderedMap; // true
Immutable.OrderedMap.isOrderedMap(magic); // true
```