mutative-compat
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

mutative-compat

npm npm bundle size GitHub Workflow Status (with branch) Codecov branch

Mutative wrapper with full Immer API compatibility.

Installation

# npm
npm install mutative-compat mutative

# Yarn
yarn add mutative-compat mutative

# pnpm
pnpm add mutative-compat mutative

Optional but useful 😈:

// package.json
{
  "dependencies": {
    "immer": "npm:mutative-compat@^0.1.x",
    "mutative": "^1.0.2",
  },
  // npm
  "overrides": {
    "immer": "npm:mutative-compat@^0.1.x"
  },
  // Yarn
  "resolutions": {
    "immer": "npm:mutative-compat@^0.1.x"
  },
  // pnpm
  "pnpm": {
    "overrides": {
      "immer": "npm:mutative-compat@^0.1.x"
    }
  }
}

This way you can replace immer with mutative in some opinionated libraries like Redux Toolkit.

Differences from Immer

  • The freeze function will only freeze shallowly, the second argument deep?: boolean is omitted.
  • In nested produce calls, the inner results will never be frozen even if they're not used in the outer recipe.

For other differences (that you probably will never notice), see mutative/test/immer-non-support.test.ts

License

MIT License @ 2023-Present Xuanbo Cheng

Package Sidebar

Install

npm i mutative-compat

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

124 kB

Total Files

26

Last publish

Collaborators

  • exuanbo