Object.is for equality, more tests. Fixes #43, #42, #48
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Michel Weststrate · committed by Michel Weststrate · parent 1116ccf · Browse files · 3 files·+9 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+9 added−4 removed
- other:+9 added−4 removed
Provenance
- Commit
e29a792- Tree
d4b18e3- Author
Michel Weststrate <mweststrate@gmail.com>- Committer
Michel Weststrate <mweststrate@gmail.com>- Parent
1116ccf
3 files changed+9 added−4 removed
modified:src/immer.js+3 added-2 removed
31 unmodified lines32 return target.getOwnPropertyDescriptor(prop)33 },34 defineProperty(target, property, descriptor) {35 target.defineProperty(property, descriptor)36- return true36 },37 setPrototypeOf() {38 throw new Error("Don't even try this...")39 }22 unmodified lines62 return target[0].getOwnPropertyDescriptor(prop)63 },64 defineProperty(target, property, descriptor) {65 target[0].defineProperty(property, descriptor)67- return true66 },67 setPrototypeOf() {68 throw new Error("Don't even try this...")69 }34 unmodified lines104 105 class State {106 constructor(parent, base) {107 this.modified = false108+ this.finalized = false109 this.parent = parent110 this.base = base111 this.copy = undefined112 this.proxies = {}80 unmodified lines193 function finalize(base) {194 if (isProxy(base)) {195 const state = base[PROXY_STATE]196 if (state.modified === true) {197+ if (state.finalized === true) return state.copy198+ state.finalized = true199 if (Array.isArray(state.base)) return finalizeArray(state)200 return finalizeObject(state)201 } else return state.base202 } else if (base !== null && typeof base === "object") {85 unmodified linesmodified:changelog.md+4 added
1234567891065 unmodified lines# Changelog
### 0.7.0
* 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)
65 unmodified linesmodified:readme.md+2 added-2 removed
12 unmodified lines13 * CDN: https://unpkg.com/immer/dist/immer.umd.js or https://unpkg.com/immer/dist/es5.umd.js. Exposed global is `immer`.14 15 ---16 17+* Egghead lesson covering all of immer (7m): [Simplify creating immutable data trees with Immer](https://egghead.io/lessons/redux-simplify-creating-immutable-data-trees-with-immer)18 * Introduction blogpost: [Immer: Immutability the easy way](https://medium.com/@mweststrate/introducing-immer-immutability-the-easy-way-9d73d8f71cb3)18-* Egghead lesson: [Simplify creating immutable data trees with Immer](https://egghead.io/lessons/redux-simplify-creating-immutable-data-trees-with-immer)19 20 Immer (German for: always) is a tiny package that allows you to work with immutable state in a more convenient way.21 It is based on the [_copy-on-write_](https://en.wikipedia.org/wiki/Copy-on-write) mechanism.22 245 unmodified lines268 * Some debuggers (at least Node 6 is known) have trouble debugging when Proxies are in play. Node 8 is known to work correctly.269 270 ## How does Immer work?271 272-Read the (second part of the) [introduction blog](https://medium.com/@mweststrate/9d73d8f71cb3).272+Read the (second part of the) [introduction blog](https://medium.com/@mweststrate/introducing-immer-immutability-the-easy-way-9d73d8f71cb3).273 274 ## Performance275 276 Here is a [simple benchmark](__performance_tests__/todo.js) on the performance of Immer.23 unmodified lines