https://github.com/brianneisler/mudash
Lodash wrapper providing Immutable.JS support
https://github.com/brianneisler/mudash
Last synced: about 2 months ago
JSON representation
Lodash wrapper providing Immutable.JS support
- Host: GitHub
- URL: https://github.com/brianneisler/mudash
- Owner: brianneisler
- License: mit
- Created: 2016-07-02T13:15:50.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-19T17:40:23.000Z (about 8 years ago)
- Last Synced: 2025-04-12T15:56:50.872Z (2 months ago)
- Language: JavaScript
- Homepage: http://mudash.org
- Size: 337 KB
- Stars: 108
- Watchers: 5
- Forks: 4
- Open Issues: 55
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
mudash
=============[Lodash](https://lodash.com) wrapper providing [Immutable.JS](https://facebook.github.io/immutable-js/) support
## Benefits
- All the benefits of Lodash brought to Immutable.JS
- Supports both standard mutable values and Immutable.JS data types
- Converts types based on data hinting
- Supports mixed nested data types making it easier to process values of mixed Immutable.JS/mutable data objects
- All Lodash methods have been rewritten to be fully immutable operations (for both mutable and Immutable.JS data types)
- Supports [lodash/fp](https://github.com/lodash/lodash/wiki/FP-Guide) bringing functional programming to Immutable.JS## Build Status
[](https://badge.fury.io/js/mudash)
[](https://travis-ci.org/brianneisler/mudash)
[](https://nodei.co/npm/mudash/)## Documentation
[Full API documentation](docs/API.md) - Learn about each method
## Install
```js
npm install --save mudash
```## Usage
```js
import _ from 'mudash'
import fp from 'mudash/fp'
import Immutable from 'immutable'// Immutable example
const map = Immutable.Map({ a:1, b:2 })
_.set(map, 'c.d', 3) // returns Map { "a": 1, "b": 2, "c": Map { "d": 3 } }
fp.set('c.d', 3)(map) // returns Map { "a": 1, "b": 2, "c": Map { "d": 3 } }// Mutable example
const obj = { a:1, b:2 }
_.set(obj, 'c.d', 3) // returns { "a": 1, "b": 2, "c": { "d": 3 } }
fp.set('c.d', 3)(obj) // returns { "a": 1, "b": 2, "c": { "d": 3 } }
```## Gotchas
#### Some Immutable.JS methods conflict with Lodash methods (mudash chooses Lodash)
For example, Immutable's `merge` is the equivalent of Lodash's `assign` and Lodash's `merge` is the equivalent of Immutable's `mergeDeep`. In order to reconcile this we have opted for Lodash's signature over Immutable's. Therefore, for this example, use `assign` for a shallow merge and `merge` for a deep merge.#### Lodash has methods that mutate values (mudash does not)
In a few cases Lodash mutates values. In the case of mutable values that are passed to these methods in mudash the method will no longer mutate the value. This has resulted in a slight change to the [signature of a few methods](./docs/FAQ.md#what-functions-are-different-from-lodash).