- Introduce the
isDraft
function to check if a value is a proxy created by Immer. - Several minor code & performance improvements #249 #237
- Functions are now also acceptable as primitive base state, see #236 #233
- Improved test coverage #250
Credits for this release go to @aleclarson, who made all these improvements!
- improve
Draft<T>
type for TypeScript users (see here) - remove unused function
- better test coverage
- Use proxies only if both
Proxy
andReflect
global APIs exist (fixes #226)
- Disabled
sideEffects
module flag, it somehow breaks the Angular build, fixes #198
- Fixed issue in the flow type for
nothing
- Introduced the
nothing
token to be able to produce theundefined
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 by @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)
- Improved TypeScript typings; if the base state is declared as
readonly
, thedraft
object will be upcasted to a writeable version. Fixes #97 through #161 by @knpwrs - It is now possible to use both
import produce from "immer"
andimport {produce} from "immer"
. Implements #136 - Added several performance tests to the repository
- Fixed bug #148 where original state was not always returned if the producer returned undefined and the original state was a primitive. By @stefanwille through #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. Fixes #100
- Immer no longer relies on
Object.assign
to be present / polyfilled. See#139 by @celebro - Improved some error messages, see #144 by @btnwtn
- Improved TypeScript and Flow typings to support return a new state from a producer. Trough #131 by dmorosinotto resp #127 by bugzpodder
- 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 by (@pkerschbaum)[https://github.com/pkerschbaum]. Implements #111.
- Improved TypeScript & Flow typings. See [#109]](#109) by ogwh.
- Fixed #117, proxy was not finalized when returning a subset of the state
- Fixed #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
- 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
- Improved TypeScript typings. See #99 by Anton Fedchenko
- Fixed detection of production mode. Fixes #95
flow-bin
andcpx
were accidentally dependencies instead of dev-dependencies. Fixed
- Producer functions will now always be invoked with the draft as context (
this
). See the readme. - Freezing the data will now be automatically (by default) be disabled in production builds. By Gregory Assasie
- Fixed Flow typings. Fixes #80. By Marcin Szczepanski in #85
- Fixed issue where constructor type was not preserved. By iruca3 through #81
- Immer will automatically turn auto-freezing of in production. Use
setAutoFreeze
to manually control it. See #46, #76 - Fixed issue where objects were unnecessary proxied, causing exceptions. See #78
- Added flow typings
- Added polyfill for
Object.is
, fixes #77
- Added 'polyfill' for
Symbol
, fixes #75
- Fixed: TS typings were no longer exposed
- 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, don't use Symbols if not available.
- Fixed #66, assigning an already frozen object to a state threw resulting in exceptions being thrown as Immer unnecessarily tried to rewrite them.
- The built is now being rolled up #64 by Arthur Denner. 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.
- Immer will now use
Object.is
instead of===
for equality checks
- Fixed issue where proxies inside new objects where not cleaned up. Fixes Fixes #53
- The default import now bundles both the es5 and proxy implementation as a convenient default. For more optimal bundle sizes, import
immer/proxy
orimmer/es5
- Make sure es5.js is transpiled
- Fixed generating a wrong property descriptor for the
length
property of arrays. Fixes #50 - Defining custom properties on drafts is no longer supported
- Added UMD build
- Introduce support for currying. #37
- Added argument checking
- The name of the immer import is now idiomatically
produce
. So the recommend import statement is:import produce from "immer"
.
- Republished, somehow NPM still returned 0.2.2
- Increased performance of the proxy-based implementation by a factor 2x - 3x. #38
- Improved typescript typings #40 by Julien Cavaleiro
- Added badges, coverage and typical project shizzle. #25 by Gregory Assasie and #39 by Fadi Khadra
- Fixed #32: changes are not properly reflected in proxies when using for example
console.dir
- Fixed:
immer/es5.js
was not packed into the package. PR #28 by Nicolas Lepage
- Immer now supports JavaScript engines without Proxies as well! Just require
immer
from"immer/es5"
. See #22
- Fixed issue where trailing commas could break consumers. Fixes #21.
- Fixed issue where TypeScript typings were not correctly exposed. Fixes #18.
- Fixed
immer
function export, it is now properly exposed as thedefault
export. Soimport immer from "immer"
. See #15 - Immer now automatically freezes any state modifications made. Turn this is using
setAutoFreeze(false)
for more efficiency in production builds. See #15 - Added support for frozen state trees in strict mode. See #15
immer
will now warn if you accidentally return something from the thunk. Fixes [#] through #16. By Gregory Assasie.- 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 by @benbraou