JSPM

immutable-transform-memoizer

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q25503F
  • License Apache-2.0

A utility for reusing objects from Immutable.js transformations - such as .toJS

Package Exports

  • immutable-transform-memoizer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (immutable-transform-memoizer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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.

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);