Skip to content
Myr

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

3 files+9 added−4 removed

modified:src/immer.js+3 added-2 removed
31 unmodified lines
32 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 lines
62 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 lines
104105 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 lines
193 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 lines
modified:changelog.md+4 added
modified:readme.md+2 added-2 removed
12 unmodified lines
13* CDN: https://unpkg.com/immer/dist/immer.umd.js or https://unpkg.com/immer/dist/es5.umd.js. Exposed global is `immer`.1415---1617* 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)1920Immer (German for: always) is a tiny package that allows you to work with immutable state in a more convenient way.21It is based on the [_copy-on-write_](https://en.wikipedia.org/wiki/Copy-on-write) mechanism.22
245 unmodified lines
268* Some debuggers (at least Node 6 is known) have trouble debugging when Proxies are in play. Node 8 is known to work correctly.269270## How does Immer work?271272Read the (second part of the) [introduction blog](https://medium.com/@mweststrate/9d73d8f71cb3).272Read the (second part of the) [introduction blog](https://medium.com/@mweststrate/introducing-immer-immutability-the-easy-way-9d73d8f71cb3).273274## Performance275276Here is a [simple benchmark](__performance_tests__/todo.js) on the performance of Immer.
23 unmodified lines