https://github.com/socialtables/immutable-transform-memoizer
A helpful function for speeding up Immutable.js Collection transformations using a WeakMap
https://github.com/socialtables/immutable-transform-memoizer
immutable library open-source public
Last synced: 11 days ago
JSON representation
A helpful function for speeding up Immutable.js Collection transformations using a WeakMap
- Host: GitHub
- URL: https://github.com/socialtables/immutable-transform-memoizer
- Owner: socialtables
- License: other
- Created: 2018-12-05T21:31:57.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-04-13T20:15:21.000Z (about 2 years ago)
- Last Synced: 2025-05-02T12:48:29.553Z (22 days ago)
- Topics: immutable, library, open-source, public
- Language: JavaScript
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 21
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Immutable Transform Memoizer
A utility function for reusing results of transformations over Immutable.js
collections.This library is intended for use in apps that need to propagate small changes
through large Immutable Collections without wasting time and memory redoing
work on objects that have not changed. It can make frequent .toJS operations
significantly faster by avoiding re-traversal of nested Collections.## Usage
Here's an example of our primary use case - we want to convert a massive
Immutable.js Map into an array. Not an ideal pattern, but it's a pattern that
we have in one of our Reselect selectors.```javascript
import { Map } from "immutable";
import memoizeImmutableTransform from "immutable-transform-memoizer";
const memoizedToJS = memoizeImmutableTransform(value => value.toJS(), "array");
const yourMap = Map({
fizz: Map({ "beep": "boop" }),
buzz: Map({ "car": "cdr" })
});
const yourArray = memoizedToJS(yourMap);
```