Socket
Socket
Sign inDemoInstall

immer

Package Overview
Dependencies
Maintainers
2
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immer - npm Package Compare versions

Comparing version 1.7.4 to 1.8.0

178

changelog.md
# Changelog
### 1.7.4
### 1.8.0 (19-Nov-2018)
* improve `Draft<T>` type for TypeScript users ([see here](https://github.com/mweststrate/immer/commit/512256bbde4ea1e2b6a75399d6ad59925752ad6b))
* remove unused function
* better test coverage
* Introduce the `isDraft` function to check if a value is a proxy created by Immer.
* Several minor code & performance improvements [#249](https://github.com/mweststrate/immer/pull/249) [#237](https://github.com/mweststrate/immer/pull/237)
* Functions are now also acceptable as primitive base state, see [#236](https://github.com/mweststrate/immer/pull/236) [#233](https://github.com/mweststrate/immer/pull/233)
* Improved test coverage [#250](https://github.com/mweststrate/immer/pull/250)
### 1.7.3
Credits for this release go to [@aleclarson](https://github.com/aleclarson), who made all these improvements!
* Use proxies only if both `Proxy` and `Reflect` global APIs exist (fixes [#226](https://github.com/mweststrate/immer/issues/226))
### 1.7.3 (24-Oct-2018)
### 1.7.2
- improve `Draft<T>` type for TypeScript users ([see here](https://github.com/mweststrate/immer/commit/512256bbde4ea1e2b6a75399d6ad59925752ad6b))
- remove unused function
- better test coverage
- Use proxies only if both `Proxy` and `Reflect` global APIs exist (fixes [#226](https://github.com/mweststrate/immer/issues/226))
* Disabled `sideEffects` module flag, it somehow breaks the Angular build, fixes [#198](https://github.com/mweststrate/immer/issues/198)
### 1.7.2 (20-Sep-2018)
### 1.7.1
- Disabled `sideEffects` module flag, it somehow breaks the Angular build, fixes [#198](https://github.com/mweststrate/immer/issues/198)
* Fixed issue in the flow type for `nothing`
### 1.7.1 (18-Sep-2018)
### 1.7.0
- Fixed issue in the flow type for `nothing`
* Introduced the [`nothing`](https://github.com/mweststrate/immer#producing-undefined-using-nothing) token to be able to produce the `undefined` value (which would otherwise be indistinguishable from not updating the draft at all).
### 1.7.0 (18-Sep-2018)
### 1.6.0
- Introduced the [`nothing`](https://github.com/mweststrate/immer#producing-undefined-using-nothing) token to be able to produce the `undefined` value (which would otherwise be indistinguishable from not updating the draft at all).
* Introduced the `original(draft)` function, that, given an object from the draft, returns the original object from the base state. This can be useful if you need to do reference equality checks, or comparisons with the base state. See [#179](https://github.com/mweststrate/immer/pull/179) by [@RichieAHB](https://github.com/RichieAHB).
* Writing or removing non-numeric properties on arrays is now strictly forbidden (Immer didn't throw before, but correct behavior wasn't guaranteed either)
### 1.6.0 (4-Sep-2018)
### 1.5.0
- Introduced the `original(draft)` function, that, given an object from the draft, returns the original object from the base state. This can be useful if you need to do reference equality checks, or comparisons with the base state. See [#179](https://github.com/mweststrate/immer/pull/179) by [@RichieAHB](https://github.com/RichieAHB).
- Writing or removing non-numeric properties on arrays is now strictly forbidden (Immer didn't throw before, but correct behavior wasn't guaranteed either)
* Added support for patches, through [#168](https://github.com/mweststrate/immer/pull/168). See the [patches](https://github.com/mweststrate/immer#patches) section for details
### 1.5.0 (25-July-2018)
### 1.4.0
- Added support for patches, through [#168](https://github.com/mweststrate/immer/pull/168). See the [patches](https://github.com/mweststrate/immer#patches) section for details
* Improved TypeScript typings; if the base state is declared as `readonly`, the `draft` object will be upcasted to a writeable version. Fixes [#97](https://github.com/mweststrate/immer/issues/97) through [#161](https://github.com/mweststrate/immer/pull/161) by [@knpwrs](https://github.com/knpwrs)
* It is now possible to use both `import produce from "immer"` and `import {produce} from "immer"`. Implements [#136](https://github.com/mweststrate/immer/issues/136)
* Added several performance tests to the repository
### 1.4.0 (25-July-2018)
### 1.3.1
- Improved TypeScript typings; if the base state is declared as `readonly`, the `draft` object will be upcasted to a writeable version. Fixes [#97](https://github.com/mweststrate/immer/issues/97) through [#161](https://github.com/mweststrate/immer/pull/161) by [@knpwrs](https://github.com/knpwrs)
- It is now possible to use both `import produce from "immer"` and `import {produce} from "immer"`. Implements [#136](https://github.com/mweststrate/immer/issues/136)
- Added several performance tests to the repository
* Fixed bug [#148](https://github.com/mweststrate/immer/issues/148) where original state was not always returned if the producer returned undefined and the original state was a primitive. By @stefanwille through [#157](https://github.com/mweststrate/immer/pull/157)
### 1.3.1 (28-May-2018)
### 1.3.0
- Fixed bug [#148](https://github.com/mweststrate/immer/issues/148) where original state was not always returned if the producer returned undefined and the original state was a primitive. By @stefanwille through [#157](https://github.com/mweststrate/immer/pull/157)
* Improved the behavior of recursive producer calls. A producer that is called from another producer is now a no-op; that is, the draft will only be finalized once the outer-most producer completes. Pro and cons of this approach are discussed in [here](https://github.com/mweststrate/immer/issues/100#issuecomment-375216607). Fixes [#100](https://github.com/mweststrate/immer/issues/100)
* Immer no longer relies on `Object.assign` to be present / polyfilled. See[#139](https://github.com/mweststrate/immer/pull/139) by @celebro
* Improved some error messages, see [#144](https://github.com/mweststrate/immer/pull/144) by @btnwtn
### 1.3.0 (4-May-2018)
### 1.2.1
- Improved the behavior of recursive producer calls. A producer that is called from another producer is now a no-op; that is, the draft will only be finalized once the outer-most producer completes. Pro and cons of this approach are discussed in [here](https://github.com/mweststrate/immer/issues/100#issuecomment-375216607). Fixes [#100](https://github.com/mweststrate/immer/issues/100)
- Immer no longer relies on `Object.assign` to be present / polyfilled. See[#139](https://github.com/mweststrate/immer/pull/139) by @celebro
- Improved some error messages, see [#144](https://github.com/mweststrate/immer/pull/144) by @btnwtn
* Improved TypeScript and Flow typings to support return a new state from a producer. Trough [#131](https://github.com/mweststrate/immer/pull/131) by [dmorosinotto](https://github.com/mweststrate/immer/issues?q=is%3Apr+author%3Admorosinotto) resp [#127](https://github.com/mweststrate/immer/pull/127) by [bugzpodder](https://github.com/mweststrate/immer/pull/127)
### 1.2.1 (26-Mar-2018)
### 1.2
- Improved TypeScript and Flow typings to support return a new state from a producer. Trough [#131](https://github.com/mweststrate/immer/pull/131) by [dmorosinotto](https://github.com/mweststrate/immer/issues?q=is%3Apr+author%3Admorosinotto) resp [#127](https://github.com/mweststrate/immer/pull/127) by [bugzpodder](https://github.com/mweststrate/immer/pull/127)
* It is now possible to pass an _initial state_ to a _curried producer_. This makes it simpler to write Redux reducers that have a default initial state. See [#121](https://github.com/mweststrate/immer/pull/121) by (@pkerschbaum)[https://github.com/pkerschbaum]. Implements [#111](https://github.com/mweststrate/immer/issues/111).
* Improved TypeScript & Flow typings. See [#109]](https://github.com/mweststrate/immer/pull/109) by [ogwh](https://github.com/ogwh).
### 1.2.0 (17-Mar-2018)
### 1.1.2
- It is now possible to pass an _initial state_ to a _curried producer_. This makes it simpler to write Redux reducers that have a default initial state. See [#121](https://github.com/mweststrate/immer/pull/121) by (@pkerschbaum)[https://github.com/pkerschbaum]. Implements [#111](https://github.com/mweststrate/immer/issues/111).
- Improved TypeScript & Flow typings. See [#109]](https://github.com/mweststrate/immer/pull/109) by [ogwh](https://github.com/ogwh).
* Fixed [#117](https://github.com/mweststrate/immer/issues/117), proxy was not finalized when returning a subset of the state
* Fixed [#116](https://github.com/mweststrate/immer/issues/116), changes to arrays that ended up with the same length were not properly detected.
### 1.1.2 (6-Mar-2018)
### 1.1.1
- Fixed [#117](https://github.com/mweststrate/immer/issues/117), proxy was not finalized when returning a subset of the state
- Fixed [#116](https://github.com/mweststrate/immer/issues/116), changes to arrays that ended up with the same length were not properly detected.
* Fixed curried reducers not return new states correctly. Fixes [#105](https://github.com/mweststrate/immer/issues/105)
### 1.1.1 (22-Feb-2018)
### 1.1.0
- Fixed curried reducers not return new states correctly. Fixes [#105](https://github.com/mweststrate/immer/issues/105)
* It is now possible to return an entirely new state from a producer as well. Immer will verify that you didn't both change the draft and returned a new state. Implements [#103](https://github.com/mweststrate/immer/issues/103)
* Improved TypeScript typings. See [#99](https://github.com/mweststrate/immer/pull/99) by [Anton Fedchenko](https://github.com/kompot)
### 1.1.0 (20-Feb-2018)
- It is now possible to return an entirely new state from a producer as well. Immer will verify that you didn't both change the draft and returned a new state. Implements [#103](https://github.com/mweststrate/immer/issues/103)
- Improved TypeScript typings. See [#99](https://github.com/mweststrate/immer/pull/99) by [Anton Fedchenko](https://github.com/kompot)
### 1.0.3 (15-Feb-2018)
* Fixed detection of production mode. Fixes [#95](https://github.com/mweststrate/immer/issues/95)
- Fixed detection of production mode. Fixes [#95](https://github.com/mweststrate/immer/issues/95)
### 1.0.2 (13-Feb-2018)
* `flow-bin` and `cpx` were accidentally dependencies instead of dev-dependencies. Fixed
- `flow-bin` and `cpx` were accidentally dependencies instead of dev-dependencies. Fixed
### 1.0.1 (2-Feb-2018)
* Fixed an issue in checking property existence. See [#86](https://github.com/mweststrate/immer/pull/88) by [iruca3](https://github.com/iruca3). Also fixes [#89](https://github.com/mweststrate/immer/issues/89)
- Fixed an issue in checking property existence. See [#86](https://github.com/mweststrate/immer/pull/88) by [iruca3](https://github.com/iruca3). Also fixes [#89](https://github.com/mweststrate/immer/issues/89)
### 1.0.0 (31-Jan-2018)
* Producer functions will now always be invoked with the draft as context (`this`). See the [readme](https://github.com/mweststrate/immer#using-this).
* Freezing the data will now be automatically (by default) be disabled in production builds. By [Gregory Assasie](https://github.com/Gregjarvez)
* Fixed Flow typings. Fixes [#80](https://github.com/mweststrate/immer/issues/80). By [Marcin Szczepanski](https://github.com/mweststrate/immer/issues?q=is%3Apr+author%3Amarcins) in [#85](https://github.com/mweststrate/immer/pull/85)
* Fixed issue where constructor type was not preserved. By [iruca3](https://github.com/iruca3) through [#81](https://github.com/mweststrate/immer/pull/81)
- Producer functions will now always be invoked with the draft as context (`this`). See the [readme](https://github.com/mweststrate/immer#using-this).
- Freezing the data will now be automatically (by default) be disabled in production builds. By [Gregory Assasie](https://github.com/Gregjarvez)
- Fixed Flow typings. Fixes [#80](https://github.com/mweststrate/immer/issues/80). By [Marcin Szczepanski](https://github.com/mweststrate/immer/issues?q=is%3Apr+author%3Amarcins) in [#85](https://github.com/mweststrate/immer/pull/85)
- Fixed issue where constructor type was not preserved. By [iruca3](https://github.com/iruca3) through [#81](https://github.com/mweststrate/immer/pull/81)
### 0.8.5
* Immer will automatically turn auto-freezing of in production. Use `setAutoFreeze` to manually control it. See [#46](https://github.com/mweststrate/immer/issues/78), [#76](https://github.com/mweststrate/immer/pull/76)
* Fixed issue where objects were unnecessary proxied, causing exceptions. See [#78](https://github.com/mweststrate/immer/issues/78)
- Immer will automatically turn auto-freezing of in production. Use `setAutoFreeze` to manually control it. See [#46](https://github.com/mweststrate/immer/issues/78), [#76](https://github.com/mweststrate/immer/pull/76)
- Fixed issue where objects were unnecessary proxied, causing exceptions. See [#78](https://github.com/mweststrate/immer/issues/78)
### 0.8.4
* Added flow typings
* Added polyfill for `Object.is`, fixes [#77](https://github.com/mweststrate/immer/issues/77)
- Added flow typings
- Added polyfill for `Object.is`, fixes [#77](https://github.com/mweststrate/immer/issues/77)
### 0.8.3
* Added 'polyfill' for `Symbol`, fixes [#75](https://github.com/mweststrate/immer/issues/75)
- Added 'polyfill' for `Symbol`, fixes [#75](https://github.com/mweststrate/immer/issues/75)
### 0.8.2
* Fixed: TS typings were no longer exposed
- Fixed: TS typings were no longer exposed
### 0.8.2
* Several general improvements: if an instances of an object are in the tree they will now be one instance in the resulting tree as well, also in the ES5 impl
* Always freeze data that is newly added to the draft
* Fixed [#75](https://github.com/mweststrate/immer/issues/75), don't use Symbols if not available.
- Several general improvements: if an instances of an object are in the tree they will now be one instance in the resulting tree as well, also in the ES5 impl
- Always freeze data that is newly added to the draft
- Fixed [#75](https://github.com/mweststrate/immer/issues/75), don't use Symbols if not available.
### 0.8.1
* Fixed [#66](https://github.com/mweststrate/immer/pull/66), assigning an already frozen object to a state threw resulting in exceptions being thrown as Immer unnecessarily tried to rewrite them.
- Fixed [#66](https://github.com/mweststrate/immer/pull/66), assigning an already frozen object to a state threw resulting in exceptions being thrown as Immer unnecessarily tried to rewrite them.
### 0.8.0
* The built is now being rolled up [#64](https://github.com/mweststrate/immer/pull/64) by [Arthur Denner](https://github.com/arthurdenner). A minified gzipped built is only 2kb!
* There are no longer separate builds available for the proxy and es5 implementation. The sources where merged to allow for more code reuse.
* The package now exposes an ES module as well.
- The built is now being rolled up [#64](https://github.com/mweststrate/immer/pull/64) by [Arthur Denner](https://github.com/arthurdenner). A minified gzipped built is only 2kb!
- There are no longer separate builds available for the proxy and es5 implementation. The sources where merged to allow for more code reuse.
- The package now exposes an ES module as well.
### 0.7.0
* Immer will now use `Object.is` instead of `===` for equality checks
- Immer will now use `Object.is` instead of `===` for equality checks
### 0.6.1
* Fixed issue where proxies inside new objects where not cleaned up. Fixes Fixes [#53](https://github.com/mweststrate/immer/issues/53)
- Fixed issue where proxies inside new objects where not cleaned up. Fixes Fixes [#53](https://github.com/mweststrate/immer/issues/53)
### 0.6.0
* The default import now bundles both the es5 and proxy implementation as a convenient default. For more optimal bundle sizes, import `immer/proxy` or `immer/es5`
- The default import now bundles both the es5 and proxy implementation as a convenient default. For more optimal bundle sizes, import `immer/proxy` or `immer/es5`
### 0.5.0
* Make sure es5.js is transpiled
- Make sure es5.js is transpiled
### 0.4.2
* Fixed generating a wrong property descriptor for the `length` property of arrays. Fixes [#50](https://github.com/mweststrate/immer/issues/50)
* Defining custom properties on drafts is no longer supported
- Fixed generating a wrong property descriptor for the `length` property of arrays. Fixes [#50](https://github.com/mweststrate/immer/issues/50)
- Defining custom properties on drafts is no longer supported
### 0.4.1
* Added UMD build
- Added UMD build
### 0.4.0
* Introduce support for [currying](https://github.com/mweststrate/immer#currying). [#37](https://github.com/mweststrate/immer/pull/37)
* Added argument checking
* The name of the immer import is now idiomatically `produce`. So the recommend import statement is: `import produce from "immer"`.
- Introduce support for [currying](https://github.com/mweststrate/immer#currying). [#37](https://github.com/mweststrate/immer/pull/37)
- Added argument checking
- The name of the immer import is now idiomatically `produce`. So the recommend import statement is: `import produce from "immer"`.
### 0.3.1
* Republished, somehow NPM still returned 0.2.2
- Republished, somehow NPM still returned 0.2.2
### 0.3.0 (8-1-2018)
* Increased performance of the proxy-based implementation by a factor 2x - 3x. [#38](https://github.com/mweststrate/immer/pull/38)
* Improved typescript typings [#40](https://github.com/mweststrate/immer/pull/40) by [Julien Cavaleiro](https://github.com/Julienng)
* Added badges, coverage and typical project shizzle. [#25](https://github.com/mweststrate/immer/pull/25) by [Gregory Assasie](https://github.com/Gregjarvez) and [#39](https://github.com/mweststrate/immer/pull/39) by [Fadi Khadra](https://github.com/fkhadra)
- Increased performance of the proxy-based implementation by a factor 2x - 3x. [#38](https://github.com/mweststrate/immer/pull/38)
- Improved typescript typings [#40](https://github.com/mweststrate/immer/pull/40) by [Julien Cavaleiro](https://github.com/Julienng)
- Added badges, coverage and typical project shizzle. [#25](https://github.com/mweststrate/immer/pull/25) by [Gregory Assasie](https://github.com/Gregjarvez) and [#39](https://github.com/mweststrate/immer/pull/39) by [Fadi Khadra](https://github.com/fkhadra)
### 0.2.2
* Fixed [#32](https://github.com/mweststrate/immer/issue/32): changes are not properly reflected in proxies when using for example `console.dir`
- Fixed [#32](https://github.com/mweststrate/immer/issue/32): changes are not properly reflected in proxies when using for example `console.dir`
### 0.2.1
* Fixed: `immer/es5.js` was not packed into the package. PR [#28](https://github.com/mweststrate/immer/pull/28) by [Nicolas Lepage](https://github.com/nlepage)
- Fixed: `immer/es5.js` was not packed into the package. PR [#28](https://github.com/mweststrate/immer/pull/28) by [Nicolas Lepage](https://github.com/nlepage)
### 0.2.0
* Immer now supports JavaScript engines without Proxies as well! Just require `immer` from `"immer/es5"`. See [#22](https://github.com/mweststrate/immer/pull/22)
- Immer now supports JavaScript engines without Proxies as well! Just require `immer` from `"immer/es5"`. See [#22](https://github.com/mweststrate/immer/pull/22)
### 0.1.2 (2-1-2018)
* Fixed issue where trailing commas could break consumers. Fixes [#21](https://github.com/mweststrate/immer/pull/21).
- Fixed issue where trailing commas could break consumers. Fixes [#21](https://github.com/mweststrate/immer/pull/21).
### 0.1.1 (2-1-2018)
* Fixed issue where TypeScript typings were not correctly exposed. Fixes [#18](https://github.com/mweststrate/immer/issue/18).
- Fixed issue where TypeScript typings were not correctly exposed. Fixes [#18](https://github.com/mweststrate/immer/issue/18).
### 0.1.0 (1-1-2018)
* Fixed `immer` function export, it is now properly exposed as the `default` export. So `import immer from "immer"`. See [#15](https://github.com/mweststrate/immer/pull/15)
* Immer now automatically freezes any state modifications made. Turn this is using `setAutoFreeze(false)` for more efficiency in production builds. See [#15](https://github.com/mweststrate/immer/pull/15)
* Added support for frozen state trees in strict mode. See [#15](https://github.com/mweststrate/immer/pull/15)
* `immer` will now warn if you accidentally return something from the _thunk_. Fixes [#] through [#16](https://github.com/mweststrate/immer/pull/16/). By [Gregory Assasie](https://github.com/Gregjarvez).
* Proxies are now automatically cleaned up. This makes it impossible to read proxies after the `immer` function has finished. This prevents users from accidentally reading stale date. [#14](https://github.com/mweststrate/immer/pull/14) by [@benbraou](https://github.com/benbraou)
- Fixed `immer` function export, it is now properly exposed as the `default` export. So `import immer from "immer"`. See [#15](https://github.com/mweststrate/immer/pull/15)
- Immer now automatically freezes any state modifications made. Turn this is using `setAutoFreeze(false)` for more efficiency in production builds. See [#15](https://github.com/mweststrate/immer/pull/15)
- Added support for frozen state trees in strict mode. See [#15](https://github.com/mweststrate/immer/pull/15)
- `immer` will now warn if you accidentally return something from the _thunk_. Fixes [#] through [#16](https://github.com/mweststrate/immer/pull/16/). By [Gregory Assasie](https://github.com/Gregjarvez).
- Proxies are now automatically cleaned up. This makes it impossible to read proxies after the `immer` function has finished. This prevents users from accidentally reading stale date. [#14](https://github.com/mweststrate/immer/pull/14) by [@benbraou](https://github.com/benbraou)
### 0.0.4 (31-12-2017)
* Added typescript typings [#11](https://github.com/mweststrate/immer/pull/11) by [@benbraou](https://github.com/benbraou)
* Fixed bug when setting properties to `undefined`. Fixes [#12](https://github.com/mweststrate/immer/issues/12) through [#13](https://github.com/mweststrate/immer/pull/13) by [@benbraou](https://github.com/benbraou)
- Added typescript typings [#11](https://github.com/mweststrate/immer/pull/11) by [@benbraou](https://github.com/benbraou)
- Fixed bug when setting properties to `undefined`. Fixes [#12](https://github.com/mweststrate/immer/issues/12) through [#13](https://github.com/mweststrate/immer/pull/13) by [@benbraou](https://github.com/benbraou)

@@ -164,1 +164,3 @@ /** Object types that should never be mapped */

export function original<T>(value: T): T | void
export function isDraft(value: any): boolean

@@ -258,4 +258,2 @@ 'use strict';

});
// always freeze completely new data
freeze(parent);
}

@@ -593,5 +591,21 @@

function hasObjectChanges(state) {
var baseKeys = Object.keys(state.base);
var keys = Object.keys(state.proxy);
return !shallowEqual(baseKeys, keys);
var base = state.base,
proxy = state.proxy;
// Search for added keys. Start at the back, because non-numeric keys
// are ordered by time of definition on the object.
var keys = Object.keys(proxy);
for (var i = keys.length; i !== 0;) {
var key = keys[--i];
// The `undefined` check is a fast path for pre-existing keys.
if (base[key] === undefined && !has(base, key)) {
return true;
}
}
// Since no keys have been added, we can compare lengths to know if an
// object has been deleted.
return keys.length !== Object.keys(base).length;
}

@@ -662,19 +676,2 @@

function shallowEqual(objA, objB) {
//From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
if (is(objA, objB)) return true;
if ((typeof objA === "undefined" ? "undefined" : _typeof(objA)) !== "object" || objA === null || (typeof objB === "undefined" ? "undefined" : _typeof(objB)) !== "object" || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return false;
for (var i = 0; i < keysA.length; i++) {
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
function createHiddenProperty(target, prop, value) {

@@ -704,6 +701,3 @@ Object.defineProperty(target, prop, {

// curried invocation
if (typeof baseState === "function") {
// prettier-ignore
if (typeof producer === "function") throw new Error("if first argument is a function (curried invocation), the second argument to produce cannot be a function");
if (typeof baseState === "function" && typeof producer !== "function") {
var initialState = producer;

@@ -713,9 +707,10 @@ var recipe = baseState;

return function () {
var args = arguments;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var currentState = args[0] === undefined && initialState !== undefined ? initialState : args[0];
var currentState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
return produce(currentState, function (draft) {
args[0] = draft; // blegh!
return recipe.apply(draft, args);
return recipe.call.apply(recipe, [draft, draft].concat(args));
});

@@ -731,4 +726,4 @@ };

// if state is a primitive, don't bother proxying at all
if ((typeof baseState === "undefined" ? "undefined" : _typeof(baseState)) !== "object" || baseState === null) {
// avoid proxying anything except plain objects and arrays
if (!isProxyable(baseState)) {
var returnValue = producer(baseState);

@@ -738,3 +733,2 @@ return returnValue === undefined ? baseState : normalizeResult(returnValue);

if (!isProxyable(baseState)) throw new Error("the first argument to an immer producer should be a primitive, plain object or array, got " + (typeof baseState === "undefined" ? "undefined" : _typeof(baseState)) + ": \"" + baseState + "\"");
return normalizeResult(getUseProxies() ? produceProxy(baseState, producer, patchListener) : produceEs5(baseState, producer, patchListener));

@@ -758,2 +752,3 @@ }

exports.original = original;
exports.isDraft = isProxy;
//# sourceMappingURL=immer.js.map

@@ -254,4 +254,2 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

});
// always freeze completely new data
freeze(parent);
}

@@ -589,5 +587,21 @@

function hasObjectChanges(state) {
var baseKeys = Object.keys(state.base);
var keys = Object.keys(state.proxy);
return !shallowEqual(baseKeys, keys);
var base = state.base,
proxy = state.proxy;
// Search for added keys. Start at the back, because non-numeric keys
// are ordered by time of definition on the object.
var keys = Object.keys(proxy);
for (var i = keys.length; i !== 0;) {
var key = keys[--i];
// The `undefined` check is a fast path for pre-existing keys.
if (base[key] === undefined && !has(base, key)) {
return true;
}
}
// Since no keys have been added, we can compare lengths to know if an
// object has been deleted.
return keys.length !== Object.keys(base).length;
}

@@ -658,19 +672,2 @@

function shallowEqual(objA, objB) {
//From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
if (is(objA, objB)) return true;
if ((typeof objA === "undefined" ? "undefined" : _typeof(objA)) !== "object" || objA === null || (typeof objB === "undefined" ? "undefined" : _typeof(objB)) !== "object" || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return false;
for (var i = 0; i < keysA.length; i++) {
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
function createHiddenProperty(target, prop, value) {

@@ -700,6 +697,3 @@ Object.defineProperty(target, prop, {

// curried invocation
if (typeof baseState === "function") {
// prettier-ignore
if (typeof producer === "function") throw new Error("if first argument is a function (curried invocation), the second argument to produce cannot be a function");
if (typeof baseState === "function" && typeof producer !== "function") {
var initialState = producer;

@@ -709,9 +703,10 @@ var recipe = baseState;

return function () {
var args = arguments;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var currentState = args[0] === undefined && initialState !== undefined ? initialState : args[0];
var currentState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
return produce(currentState, function (draft) {
args[0] = draft; // blegh!
return recipe.apply(draft, args);
return recipe.call.apply(recipe, [draft, draft].concat(args));
});

@@ -727,4 +722,4 @@ };

// if state is a primitive, don't bother proxying at all
if ((typeof baseState === "undefined" ? "undefined" : _typeof(baseState)) !== "object" || baseState === null) {
// avoid proxying anything except plain objects and arrays
if (!isProxyable(baseState)) {
var returnValue = producer(baseState);

@@ -734,3 +729,2 @@ return returnValue === undefined ? baseState : normalizeResult(returnValue);

if (!isProxyable(baseState)) throw new Error("the first argument to an immer producer should be a primitive, plain object or array, got " + (typeof baseState === "undefined" ? "undefined" : _typeof(baseState)) + ": \"" + baseState + "\"");
return normalizeResult(getUseProxies() ? produceProxy(baseState, producer, patchListener) : produceEs5(baseState, producer, patchListener));

@@ -747,4 +741,4 @@ }

export { produce, applyPatches$1 as applyPatches, nothing, setAutoFreeze, setUseProxies, original };
export { produce, applyPatches$1 as applyPatches, nothing, setAutoFreeze, setUseProxies, original, isProxy as isDraft };
export default produce;
//# sourceMappingURL=immer.module.js.map

@@ -1,2 +0,2 @@

var e,r;e=this,r=function(e){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function n(e,r,n,t,o,i){n&&(Array.isArray(o)?function(e,r,n,t,o,i){for(var a=Math.min(o.length,i.length),f=0;f<a;f++)if(e.assigned[f]&&o[f]!==i[f]){var u=r.concat(f);n.push({op:"replace",path:u,value:i[f]}),t.push({op:"replace",path:u,value:o[f]})}if(a<i.length){for(var c=a;c<i.length;c++){var s=r.concat(c);n.push({op:"add",path:s,value:i[c]})}t.push({op:"replace",path:r.concat("length"),value:o.length})}else if(a<o.length){n.push({op:"replace",path:r.concat("length"),value:i.length});for(var p=a;p<o.length;p++){var d=r.concat(p);t.push({op:"add",path:d,value:o[p]})}}}(e,r,n,t,o,i):function(e,r,n,t,o,i){v(e.assigned,function(e,a){var f=o[e],u=i[e],c=a?e in o?"replace":"add":"remove";if(f!==o||"replace"!==c){var s=r.concat(e);n.push("remove"===c?{op:c,path:s}:{op:c,path:s,value:u}),t.push("add"===c?{op:"remove",path:s}:"remove"===c?{op:"add",path:s,value:f}:{op:"replace",path:s,value:f})}})}(e,r,n,t,o,i))}var t,o,i,a="undefined"!=typeof Symbol?Symbol("immer-nothing"):(i=!0,(o="immer-nothing")in(t={})?Object.defineProperty(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[o]=i,t),f="undefined"!=typeof Symbol?Symbol("immer-proxy-state"):"__$immer_state",u="An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.";var c=!("undefined"!=typeof process&&"production"===process.env.NODE_ENV||"verifyMinified"!==function(){}.name),s="undefined"!=typeof Proxy&&"undefined"!=typeof Reflect;function p(e){return!!e&&!!e[f]}function d(e){if(!e)return!1;if("object"!==(void 0===e?"undefined":r(e)))return!1;if(Array.isArray(e))return!0;var n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}function l(e){return c&&Object.freeze(e),e}var h=Object.assign||function(e,r){for(var n in r)g(r,n)&&(e[n]=r[n]);return e};function y(e){if(Array.isArray(e))return e.slice();var r=void 0===e.__proto__?Object.create(null):{};return h(r,e)}function v(e,r){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(n,e[n]);else for(var t in e)r(t,e[t])}function g(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function m(e,r,t,o){if(p(e)){var i=e[f];if(!0===i.modified){if(!0===i.finalized)return i.copy;i.finalized=!0;var a=function(e,r,n,t,o){var i=r.base;return v(e,function(a,f){if(f!==i[a]){var u=t&&!g(r.assigned,a);e[a]=m(f,u&&n.concat(a),u&&t,o)}}),l(e)}(s?i.copy:i.copy=y(e),i,r,t,o);return n(i,r,t,o,i.base,a),a}return i.base}return function e(r){if(!d(r))return;if(Object.isFrozen(r))return;v(r,function(n,t){p(t)?r[n]=m(t):e(t)});l(r)}(e),e}function b(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var w=null,O={get:function(e,r){if(r===f)return e;if(e.modified){var n=e.copy[r];return n===e.base[r]&&d(n)?e.copy[r]=A(e,n):n}if(g(e.proxies,r))return e.proxies[r];var t=e.base[r];return!p(t)&&d(t)?e.proxies[r]=A(e,t):t},has:function(e,r){return r in x(e)},ownKeys:function(e){return Reflect.ownKeys(x(e))},set:function(e,r,n){if(e.assigned[r]=!0,!e.modified){if(r in e.base&&b(e.base[r],n)||g(e.proxies,r)&&e.proxies[r]===n)return!0;P(e)}return e.copy[r]=n,!0},deleteProperty:function(e,r){return e.assigned[r]=!1,P(e),delete e.copy[r],!0},getOwnPropertyDescriptor:function(e,r){var n=e.modified?e.copy:g(e.proxies,r)?e.proxies:e.base,t=Reflect.getOwnPropertyDescriptor(n,r);!t||Array.isArray(n)&&"length"===r||(t.configurable=!0);return t},defineProperty:function(){throw new Error("Immer does not support defining properties on draft objects.")},setPrototypeOf:function(){throw new Error("Immer does not support `setPrototypeOf()`.")}},j={};function x(e){return!0===e.modified?e.copy:e.base}function P(e){e.modified||(e.modified=!0,e.copy=y(e.base),Object.assign(e.copy,e.proxies),e.parent&&P(e.parent))}function A(e,r){if(p(r))throw new Error("Immer bug. Plz report.");var n=function(e,r){return{modified:!1,assigned:{},finalized:!1,parent:e,base:r,copy:void 0,proxies:{}}}(e,r),t=Array.isArray(r)?Proxy.revocable([n],j):Proxy.revocable(n,O);return w.push(t),t.proxy}v(O,function(e,r){j[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),j.deleteProperty=function(e,r){if(isNaN(parseInt(r)))throw new Error("Immer does not support deleting properties from arrays: "+r);return O.deleteProperty.call(this,e[0],r)},j.set=function(e,r,n){if("length"!==r&&isNaN(parseInt(r)))throw new Error("Immer does not support setting non-numeric properties on arrays: "+r);return O.set.call(this,e[0],r,n)};var E={},k=null;function z(e){return e.hasCopy?e.copy:e.base}function S(e){e.modified||(e.modified=!0,e.parent&&S(e.parent))}function _(e){e.hasCopy||(e.hasCopy=!0,e.copy=y(e.base))}function I(e,r){var n=y(r);v(r,function(e){var r;Object.defineProperty(n,""+e,E[r=""+e]||(E[r]={configurable:!0,enumerable:!0,get:function(){return function(e,r){N(e);var n=z(e)[r];return!e.finalizing&&n===e.base[r]&&d(n)?(_(e),e.copy[r]=I(e,n)):n}(this[f],r)},set:function(e){!function(e,r,n){if(N(e),e.assigned[r]=!0,!e.modified){if(b(z(e)[r],n))return;S(e),_(e)}e.copy[r]=n}(this[f],r,e)}}))});var t,o,i,a=function(e,r,n){return{modified:!1,assigned:{},hasCopy:!1,parent:e,base:n,proxy:r,copy:void 0,finished:!1,finalizing:!1,finalized:!1}}(e,n,r);return t=n,o=f,i=a,Object.defineProperty(t,o,{value:i,enumerable:!1,writable:!0}),k.push(a),n}function N(e){if(!0===e.finished)throw new Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(e.copy||e.base))}function C(e){if(e&&"object"===(void 0===e?"undefined":r(e))){var n=e[f];if(n){var t,o,i,a,u=n.proxy,c=n.base;if(Array.isArray(e)){if(R(n)){if(S(n),n.assigned.length=!0,u.length<c.length)for(var s=u.length;s<c.length;s++)n.assigned[s]=!1;else for(var p=c.length;p<u.length;p++)n.assigned[p]=!0;v(u,function(e,r){n.assigned[e]||C(r)})}}else{var d=(t=c,o=u,i=Object.keys(t),{added:(a=Object.keys(o)).filter(function(e){return-1===i.indexOf(e)}),removed:i.filter(function(e){return-1===a.indexOf(e)})}),l=d.added,h=d.removed;(l.length>0||h.length>0)&&S(n),v(l,function(e,r){n.assigned[r]=!0}),v(h,function(e,r){n.assigned[r]=!1}),v(u,function(e,r){n.assigned[e]||C(r)})}}}}function D(e){return!function(e,n){if(b(e,n))return!0;if("object"!==(void 0===e?"undefined":r(e))||null===e||"object"!==(void 0===n?"undefined":r(n))||null===n)return!1;var t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(var i=0;i<t.length;i++)if(!hasOwnProperty.call(n,t[i])||!b(e[t[i]],n[t[i]]))return!1;return!0}(Object.keys(e.base),Object.keys(e.proxy))}function R(e){var r=e.proxy;if(r.length!==e.base.length)return!0;var n=Object.getOwnPropertyDescriptor(r,r.length-1);return!(!n||n.get)}function M(e,r,n){if(p(e)){var t=r.call(e,e);return void 0===t?e:t}var o=k;k=[];var i=n&&[],a=n&&[];try{var c=I(void 0,e),s=r.call(c,c);v(k,function(e,r){r.finalizing=!0});var d=void 0;if(void 0!==s&&s!==c){if(c[f].modified)throw new Error(u);d=m(s),i&&(i.push({op:"replace",path:[],value:d}),a.push({op:"replace",path:[],value:e}))}else n&&C(c),function(){for(var e=k.length-1;e>=0;e--){var r=k[e];!1===r.modified&&(Array.isArray(r.base)?R(r)&&S(r):D(r)&&S(r))}}(),d=m(c,[],i,a);return v(k,function(e,r){r.finished=!0}),n&&n(i,a),d}finally{k=o}}function F(e,n,t){if(arguments.length<1||arguments.length>3)throw new Error("produce expects 1 to 3 arguments, got "+arguments.length);if("function"==typeof e){if("function"==typeof n)throw new Error("if first argument is a function (curried invocation), the second argument to produce cannot be a function");var o=n,i=e;return function(){var e=arguments;return F(void 0===e[0]&&void 0!==o?o:e[0],function(r){return e[0]=r,i.apply(r,e)})}}if("function"!=typeof n)throw new Error("if first argument is not a function, the second argument to produce should be a function");if(void 0!==t&&"function"!=typeof t)throw new Error("the third argument of a producer should not be set or a function");if("object"!==(void 0===e?"undefined":r(e))||null===e){var a=n(e);return void 0===a?e:K(a)}if(!d(e))throw new Error("the first argument to an immer producer should be a primitive, plain object or array, got "+(void 0===e?"undefined":r(e))+': "'+e+'"');return K(s?function(e,r,n){if(p(e)){var t=r.call(e,e);return void 0===t?e:t}var o=w;w=[];var i=n&&[],a=n&&[];try{var c=A(void 0,e),s=r.call(c,c),d=void 0;if(void 0!==s&&s!==c){if(c[f].modified)throw new Error(u);d=m(s),i&&(i.push({op:"replace",path:[],value:d}),a.push({op:"replace",path:[],value:e}))}else d=m(c,[],i,a);return v(w,function(e,r){return r.revoke()}),n&&n(i,a),d}finally{w=o}}(e,n,t):M(e,n,t))}function K(e){return e===a?void 0:e}var U=F(function(e,n){for(var t=0;t<n.length;t++){var o=n[t],i=o.path;if(0===i.length&&"replace"===o.op)e=o.value;else{for(var a=e,f=0;f<i.length-1;f++)if(!(a=a[i[f]])||"object"!==(void 0===a?"undefined":r(a)))throw new Error("Cannot apply patch, path doesn't resolve: "+i.join("/"));var u=i[i.length-1];switch(o.op){case"replace":case"add":a[u]=o.value;break;case"remove":if(Array.isArray(a)){if(u!==a.length-1)throw new Error("Remove can only remove the last key of an array, index: "+u+", length: "+a.length);a.length-=1}else delete a[u];break;default:throw new Error("Unsupported patch operation: "+o.op)}}}return e}),J=a;e.produce=F,e.default=F,e.applyPatches=U,e.nothing=J,e.setAutoFreeze=function(e){c=e},e.setUseProxies=function(e){s=e},e.original=function(e){if(e&&e[f])return e[f].base},Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.immer={});
var e,r;e=this,r=function(e){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function n(e,r,n,t,o,i){n&&(Array.isArray(o)?function(e,r,n,t,o,i){for(var a=Math.min(o.length,i.length),f=0;f<a;f++)if(e.assigned[f]&&o[f]!==i[f]){var u=r.concat(f);n.push({op:"replace",path:u,value:i[f]}),t.push({op:"replace",path:u,value:o[f]})}if(a<i.length){for(var c=a;c<i.length;c++){var s=r.concat(c);n.push({op:"add",path:s,value:i[c]})}t.push({op:"replace",path:r.concat("length"),value:o.length})}else if(a<o.length){n.push({op:"replace",path:r.concat("length"),value:i.length});for(var p=a;p<o.length;p++){var l=r.concat(p);t.push({op:"add",path:l,value:o[p]})}}}(e,r,n,t,o,i):function(e,r,n,t,o,i){h(e.assigned,function(e,a){var f=o[e],u=i[e],c=a?e in o?"replace":"add":"remove";if(f!==o||"replace"!==c){var s=r.concat(e);n.push("remove"===c?{op:c,path:s}:{op:c,path:s,value:u}),t.push("add"===c?{op:"remove",path:s}:"remove"===c?{op:"add",path:s,value:f}:{op:"replace",path:s,value:f})}})}(e,r,n,t,o,i))}var t,o,i,a="undefined"!=typeof Symbol?Symbol("immer-nothing"):(i=!0,(o="immer-nothing")in(t={})?Object.defineProperty(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[o]=i,t),f="undefined"!=typeof Symbol?Symbol("immer-proxy-state"):"__$immer_state",u="An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.";var c=!("undefined"!=typeof process&&"production"===process.env.NODE_ENV||"verifyMinified"!==function(){}.name),s="undefined"!=typeof Proxy&&"undefined"!=typeof Reflect;function p(e){return!!e&&!!e[f]}function l(e){if(!e)return!1;if("object"!==(void 0===e?"undefined":r(e)))return!1;if(Array.isArray(e))return!0;var n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}var d=Object.assign||function(e,r){for(var n in r)v(r,n)&&(e[n]=r[n]);return e};function y(e){if(Array.isArray(e))return e.slice();var r=void 0===e.__proto__?Object.create(null):{};return d(r,e)}function h(e,r){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(n,e[n]);else for(var t in e)r(t,e[t])}function v(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function g(e,r,t,o){if(p(e)){var i=e[f];if(!0===i.modified){if(!0===i.finalized)return i.copy;i.finalized=!0;var a=function(e,r,n,t,o){var i=r.base;return h(e,function(a,f){if(f!==i[a]){var u=t&&!v(r.assigned,a);e[a]=g(f,u&&n.concat(a),u&&t,o)}}),a=e,c&&Object.freeze(a),a;var a}(s?i.copy:i.copy=y(e),i,r,t,o);return n(i,r,t,o,i.base,a),a}return i.base}return function e(r){if(!l(r))return;if(Object.isFrozen(r))return;h(r,function(n,t){p(t)?r[n]=g(t):e(t)})}(e),e}function m(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var b=null,w={get:function(e,r){if(r===f)return e;if(e.modified){var n=e.copy[r];return n===e.base[r]&&l(n)?e.copy[r]=A(e,n):n}if(v(e.proxies,r))return e.proxies[r];var t=e.base[r];return!p(t)&&l(t)?e.proxies[r]=A(e,t):t},has:function(e,r){return r in x(e)},ownKeys:function(e){return Reflect.ownKeys(x(e))},set:function(e,r,n){if(e.assigned[r]=!0,!e.modified){if(r in e.base&&m(e.base[r],n)||v(e.proxies,r)&&e.proxies[r]===n)return!0;j(e)}return e.copy[r]=n,!0},deleteProperty:function(e,r){return e.assigned[r]=!1,j(e),delete e.copy[r],!0},getOwnPropertyDescriptor:function(e,r){var n=e.modified?e.copy:v(e.proxies,r)?e.proxies:e.base,t=Reflect.getOwnPropertyDescriptor(n,r);!t||Array.isArray(n)&&"length"===r||(t.configurable=!0);return t},defineProperty:function(){throw new Error("Immer does not support defining properties on draft objects.")},setPrototypeOf:function(){throw new Error("Immer does not support `setPrototypeOf()`.")}},O={};function x(e){return!0===e.modified?e.copy:e.base}function j(e){e.modified||(e.modified=!0,e.copy=y(e.base),Object.assign(e.copy,e.proxies),e.parent&&j(e.parent))}function A(e,r){if(p(r))throw new Error("Immer bug. Plz report.");var n=function(e,r){return{modified:!1,assigned:{},finalized:!1,parent:e,base:r,copy:void 0,proxies:{}}}(e,r),t=Array.isArray(r)?Proxy.revocable([n],O):Proxy.revocable(n,w);return b.push(t),t.proxy}h(w,function(e,r){O[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),O.deleteProperty=function(e,r){if(isNaN(parseInt(r)))throw new Error("Immer does not support deleting properties from arrays: "+r);return w.deleteProperty.call(this,e[0],r)},O.set=function(e,r,n){if("length"!==r&&isNaN(parseInt(r)))throw new Error("Immer does not support setting non-numeric properties on arrays: "+r);return w.set.call(this,e[0],r,n)};var P={},E=null;function z(e){return e.hasCopy?e.copy:e.base}function S(e){e.modified||(e.modified=!0,e.parent&&S(e.parent))}function _(e){e.hasCopy||(e.hasCopy=!0,e.copy=y(e.base))}function k(e,r){var n=y(r);h(r,function(e){var r;Object.defineProperty(n,""+e,P[r=""+e]||(P[r]={configurable:!0,enumerable:!0,get:function(){return function(e,r){I(e);var n=z(e)[r];return!e.finalizing&&n===e.base[r]&&l(n)?(_(e),e.copy[r]=k(e,n)):n}(this[f],r)},set:function(e){!function(e,r,n){if(I(e),e.assigned[r]=!0,!e.modified){if(m(z(e)[r],n))return;S(e),_(e)}e.copy[r]=n}(this[f],r,e)}}))});var t,o,i,a=function(e,r,n){return{modified:!1,assigned:{},hasCopy:!1,parent:e,base:n,proxy:r,copy:void 0,finished:!1,finalizing:!1,finalized:!1}}(e,n,r);return t=n,o=f,i=a,Object.defineProperty(t,o,{value:i,enumerable:!1,writable:!0}),E.push(a),n}function I(e){if(!0===e.finished)throw new Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(e.copy||e.base))}function N(e){if(e&&"object"===(void 0===e?"undefined":r(e))){var n=e[f];if(n){var t,o,i,a,u=n.proxy,c=n.base;if(Array.isArray(e)){if(D(n)){if(S(n),n.assigned.length=!0,u.length<c.length)for(var s=u.length;s<c.length;s++)n.assigned[s]=!1;else for(var p=c.length;p<u.length;p++)n.assigned[p]=!0;h(u,function(e,r){n.assigned[e]||N(r)})}}else{var l=(t=c,o=u,i=Object.keys(t),{added:(a=Object.keys(o)).filter(function(e){return-1===i.indexOf(e)}),removed:i.filter(function(e){return-1===a.indexOf(e)})}),d=l.added,y=l.removed;(d.length>0||y.length>0)&&S(n),h(d,function(e,r){n.assigned[r]=!0}),h(y,function(e,r){n.assigned[r]=!1}),h(u,function(e,r){n.assigned[e]||N(r)})}}}}function C(e){for(var r=e.base,n=e.proxy,t=Object.keys(n),o=t.length;0!==o;){var i=t[--o];if(void 0===r[i]&&!v(r,i))return!0}return t.length!==Object.keys(r).length}function D(e){var r=e.proxy;if(r.length!==e.base.length)return!0;var n=Object.getOwnPropertyDescriptor(r,r.length-1);return!(!n||n.get)}function R(e,r,n){if(p(e)){var t=r.call(e,e);return void 0===t?e:t}var o=E;E=[];var i=n&&[],a=n&&[];try{var c=k(void 0,e),s=r.call(c,c);h(E,function(e,r){r.finalizing=!0});var l=void 0;if(void 0!==s&&s!==c){if(c[f].modified)throw new Error(u);l=g(s),i&&(i.push({op:"replace",path:[],value:l}),a.push({op:"replace",path:[],value:e}))}else n&&N(c),function(){for(var e=E.length-1;e>=0;e--){var r=E[e];!1===r.modified&&(Array.isArray(r.base)?D(r)&&S(r):C(r)&&S(r))}}(),l=g(c,[],i,a);return h(E,function(e,r){r.finished=!0}),n&&n(i,a),l}finally{E=o}}function M(e,r,n){if(arguments.length<1||arguments.length>3)throw new Error("produce expects 1 to 3 arguments, got "+arguments.length);if("function"==typeof e&&"function"!=typeof r){var t=r,o=e;return function(){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return M(arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,function(e){return o.call.apply(o,[e,e].concat(r))})}}if("function"!=typeof r)throw new Error("if first argument is not a function, the second argument to produce should be a function");if(void 0!==n&&"function"!=typeof n)throw new Error("the third argument of a producer should not be set or a function");if(!l(e)){var i=r(e);return void 0===i?e:F(i)}return F(s?function(e,r,n){if(p(e)){var t=r.call(e,e);return void 0===t?e:t}var o=b;b=[];var i=n&&[],a=n&&[];try{var c=A(void 0,e),s=r.call(c,c),l=void 0;if(void 0!==s&&s!==c){if(c[f].modified)throw new Error(u);l=g(s),i&&(i.push({op:"replace",path:[],value:l}),a.push({op:"replace",path:[],value:e}))}else l=g(c,[],i,a);return h(b,function(e,r){return r.revoke()}),n&&n(i,a),l}finally{b=o}}(e,r,n):R(e,r,n))}function F(e){return e===a?void 0:e}var K=M(function(e,n){for(var t=0;t<n.length;t++){var o=n[t],i=o.path;if(0===i.length&&"replace"===o.op)e=o.value;else{for(var a=e,f=0;f<i.length-1;f++)if(!(a=a[i[f]])||"object"!==(void 0===a?"undefined":r(a)))throw new Error("Cannot apply patch, path doesn't resolve: "+i.join("/"));var u=i[i.length-1];switch(o.op){case"replace":case"add":a[u]=o.value;break;case"remove":if(Array.isArray(a)){if(u!==a.length-1)throw new Error("Remove can only remove the last key of an array, index: "+u+", length: "+a.length);a.length-=1}else delete a[u];break;default:throw new Error("Unsupported patch operation: "+o.op)}}}return e}),U=a;e.produce=M,e.default=M,e.applyPatches=K,e.nothing=U,e.setAutoFreeze=function(e){c=e},e.setUseProxies=function(e){s=e},e.original=function(e){if(e&&e[f])return e[f].base},e.isDraft=p,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.immer={});
//# sourceMappingURL=immer.umd.js.map
{
"name": "immer",
"version": "1.7.4",
"version": "1.8.0",
"description": "Create your next immutable state by mutating the current one",

@@ -5,0 +5,0 @@ "main": "dist/immer.js",

@@ -437,2 +437,16 @@ <img src="images/immer-logo.png" height="200px" align="right"/>

Just want to know if a value is a proxied instance? Use the `isDraft` function!
```js
import { isDraft } from "immer";
const baseState = { users: [{ name: "Bobby" }] };
const nextState = produce(baseState, draft => {
isDraft(draft) // => true
isDraft(draft.users) // => true
isDraft(draft.users[0]) // => true
})
isDraft(nextState) // => false
```
## Using `this`

@@ -439,0 +453,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc