chore: Merge branch 'master' of github.com:immerjs/immer
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 · parents 0730231, 31684f2 · Browse files · 12 files·+144 added−128 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
12 files+144 added−128 removed
- tests:+129 added−121 removed
- other:+15 added−7 removed
Provenance
- Commit
6c62eec- Tree
2435d0a- Author
Michel Weststrate <mweststrate@gmail.com>- Committer
Michel Weststrate <mweststrate@gmail.com>- Parent 1
0730231- Parent 2
31684f2
12 files changed+144 added−128 removed
modified:__tests__/__prod_snapshots__/base.js.snap+32 added-48 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3 exports[`base functionality - es5 (autofreeze) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`;4 5-exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;5+exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;6 7-exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;7+exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;8 9 exports[`base functionality - es5 (autofreeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;10 11 exports[`base functionality - es5 (autofreeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;5 unmodified lines17 exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 3`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;18 19 exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;20 21-exports[`base functionality - es5 (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;21+exports[`base functionality - es5 (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;22 23-exports[`base functionality - es5 (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;23+exports[`base functionality - es5 (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;24 25-exports[`base functionality - es5 (autofreeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;26-25 exports[`base functionality - es5 (autofreeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;26 27 exports[`base functionality - es5 (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`;28 31-exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;29+exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;30 33-exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;31+exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;32 33 exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;34 35 exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;5 unmodified lines41 exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 3`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;42 43 exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;44 47-exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;45+exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;46 49-exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;47+exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;48 51-exports[`base functionality - es5 (autofreeze)(patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;52-49 exports[`base functionality - es5 (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;50 51 exports[`base functionality - es5 (no freeze) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`;52 57-exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;53+exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;54 59-exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;55+exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;56 57 exports[`base functionality - es5 (no freeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;58 59 exports[`base functionality - es5 (no freeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;5 unmodified lines65 exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 3`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;66 67 exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;68 73-exports[`base functionality - es5 (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;69+exports[`base functionality - es5 (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;70 75-exports[`base functionality - es5 (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;71+exports[`base functionality - es5 (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;72 77-exports[`base functionality - es5 (no freeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;78-73 exports[`base functionality - es5 (no freeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;74 75 exports[`base functionality - es5 (patch listener) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`;76 83-exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;77+exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;78 85-exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;79+exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;80 81 exports[`base functionality - es5 (patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;82 83 exports[`base functionality - es5 (patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;5 unmodified lines89 exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 3`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;90 91 exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;92 99-exports[`base functionality - es5 (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;93+exports[`base functionality - es5 (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;94 101-exports[`base functionality - es5 (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;95+exports[`base functionality - es5 (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;96 103-exports[`base functionality - es5 (patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;104-97 exports[`base functionality - es5 (patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;98 99 exports[`base functionality - proxy (autofreeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;100 109-exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;101+exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;102 111-exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;103+exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;104 105 exports[`base functionality - proxy (autofreeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;106 107 exports[`base functionality - proxy (autofreeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;13 unmodified lines121 exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;122 123 exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;124 133-exports[`base functionality - proxy (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;125+exports[`base functionality - proxy (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;126 135-exports[`base functionality - proxy (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;127+exports[`base functionality - proxy (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;128 137-exports[`base functionality - proxy (autofreeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;138-129 exports[`base functionality - proxy (autofreeze) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`;130 131 exports[`base functionality - proxy (autofreeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] minified error nr: 12. Find the full error at: https://bit.ly/3cXEKWf"`;132 133 exports[`base functionality - proxy (autofreeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;134 135 exports[`base functionality - proxy (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;136 147-exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;137+exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;138 149-exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;139+exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;140 141 exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;142 143 exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;13 unmodified lines157 exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;158 159 exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;160 171-exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;161+exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;162 173-exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;163+exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;164 175-exports[`base functionality - proxy (autofreeze)(patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;176-165 exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`;166 167 exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] minified error nr: 12. Find the full error at: https://bit.ly/3cXEKWf"`;168 169 exports[`base functionality - proxy (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;170 171 exports[`base functionality - proxy (no freeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;172 185-exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;173+exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;174 187-exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;175+exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;176 177 exports[`base functionality - proxy (no freeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;178 179 exports[`base functionality - proxy (no freeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;13 unmodified lines193 exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;194 195 exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;196 209-exports[`base functionality - proxy (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;197+exports[`base functionality - proxy (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;198 211-exports[`base functionality - proxy (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;199+exports[`base functionality - proxy (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;200 213-exports[`base functionality - proxy (no freeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;214-201 exports[`base functionality - proxy (no freeze) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`;202 203 exports[`base functionality - proxy (no freeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] minified error nr: 12. Find the full error at: https://bit.ly/3cXEKWf"`;204 205 exports[`base functionality - proxy (no freeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;206 207 exports[`base functionality - proxy (patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;208 223-exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;209+exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;210 225-exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;211+exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;212 213 exports[`base functionality - proxy (patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;214 215 exports[`base functionality - proxy (patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;13 unmodified lines229 exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;230 231 exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;232 247-exports[`base functionality - proxy (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;233+exports[`base functionality - proxy (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;234 249-exports[`base functionality - proxy (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;235+exports[`base functionality - proxy (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;236 251-exports[`base functionality - proxy (patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;252-237 exports[`base functionality - proxy (patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`;238 239 exports[`base functionality - proxy (patch listener) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] minified error nr: 12. Find the full error at: https://bit.ly/3cXEKWf"`;240 377 unmodified linesmodified:__tests__/__prod_snapshots__/patch.js.snap+3 added-3 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3-exports[`applyPatches throws when \`op\` is not "add", "replace", nor "remove" 1`] = `"[Immer] minified error nr: 17 copy. Find the full error at: https://bit.ly/3cXEKWf"`;3+exports[`applyPatches throws when \`op\` is not "add", "replace", nor "remove" 1`] = `"[Immer] minified error nr: 17 'copy'. Find the full error at: https://bit.ly/3cXEKWf"`;4 5-exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] minified error nr: 15 a/b. Find the full error at: https://bit.ly/3cXEKWf"`;5+exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] minified error nr: 15 'a/b'. Find the full error at: https://bit.ly/3cXEKWf"`;6 7-exports[`applyPatches throws when \`path\` cannot be resolved 2`] = `"[Immer] minified error nr: 15 a/b/c. Find the full error at: https://bit.ly/3cXEKWf"`;7+exports[`applyPatches throws when \`path\` cannot be resolved 2`] = `"[Immer] minified error nr: 15 'a/b/c'. Find the full error at: https://bit.ly/3cXEKWf"`;modified:__tests__/__prod_snapshots__/plugins.js.snap+5 added-5 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3-exports[`ES5 plugins should throw if no proxies are available error when using ES5 1`] = `"[Immer] minified error nr: 19 ES5. Find the full error at: https://bit.ly/3cXEKWf"`;3+exports[`ES5 plugins should throw if no proxies are available error when using ES5 1`] = `"[Immer] minified error nr: 18 'ES5'. Find the full error at: https://bit.ly/3cXEKWf"`;4 5-exports[`error when using Maps 1`] = `"[Immer] minified error nr: 19 MapSet. Find the full error at: https://bit.ly/3cXEKWf"`;5+exports[`error when using Maps 1`] = `"[Immer] minified error nr: 18 'MapSet'. Find the full error at: https://bit.ly/3cXEKWf"`;6 7-exports[`error when using patches - 1 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;7+exports[`error when using patches - 1 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`;8 9-exports[`error when using patches - 2 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;9+exports[`error when using patches - 2 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`;10 11-exports[`error when using patches - 3 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;11+exports[`error when using patches - 3 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`;modified:__tests__/base.js+56 added-51 removed
14 unmodified lines15 jest.setTimeout(1000)16 17 enableAllPlugins()18 19+const isProd = process.env.NODE_ENV === "production"20+21 test("immer should have no dependencies", () => {22 expect(require("../package.json").dependencies).toBeUndefined()23 })24 1121 unmodified lines1146 expect(nextState.aProp).toBe(undefined)1147 })1148 1149 // NOTE: ES5 drafts only protect existing properties when revoked.1150+ if (!isProd)1148- it("revokes the draft once produce returns", () => {1149- const expectRevoked = (fn, shouldThrow = true) => {1150- if (shouldThrow) expect(fn).toThrowErrorMatchingSnapshot()1151- else expect(fn).not.toThrow()1152- }1151+ it("revokes the draft once produce returns", () => {1152+ const expectRevoked = (fn, shouldThrow = true) => {1153+ if (shouldThrow) expect(fn).toThrowErrorMatchingSnapshot()1154+ else expect(fn).not.toThrow()1155+ }1156 1154- // Test object drafts:1155- let draft1156- produce({a: 1, b: 1}, s => {1157- draft = s1158- delete s.b1159- })1157+ // Test object drafts:1158+ let draft1159+ produce({a: 1, b: 1}, s => {1160+ draft = s1161+ delete s.b1162+ })1163 1161- // Access known property on object draft.1162- expectRevoked(() => {1163- draft.a1164- })1164+ // Access known property on object draft.1165+ expectRevoked(() => {1166+ draft.a1167+ })1168 1166- // Assign known property on object draft.1167- expectRevoked(() => {1168- draft.a = true1169- })1169+ // Assign known property on object draft.1170+ expectRevoked(() => {1171+ draft.a = true1172+ })1173 1171- // Access unknown property on object draft.1172- expectRevoked(() => {1173- draft.z1174- }, useProxies)1174+ // Access unknown property on object draft.1175+ expectRevoked(() => {1176+ draft.z1177+ }, useProxies)1178 1176- // Assign unknown property on object draft.1177- expectRevoked(() => {1178- draft.z = true1179- }, useProxies)1179+ // Assign unknown property on object draft.1180+ expectRevoked(() => {1181+ draft.z = true1182+ }, useProxies)1183 1181- // Test array drafts:1182- produce([1, 2], s => {1183- draft = s1184- s.pop()1185- })1184+ // Test array drafts:1185+ produce([1, 2], s => {1186+ draft = s1187+ s.pop()1188+ })1189 1187- // Access known index of an array draft.1188- expectRevoked(() => {1189- draft[0]1190- })1190+ // Access known index of an array draft.1191+ expectRevoked(() => {1192+ draft[0]1193+ })1194 1192- // Assign known index of an array draft.1193- expectRevoked(() => {1194- draft[0] = true1195- })1195+ // Assign known index of an array draft.1196+ expectRevoked(() => {1197+ draft[0] = true1198+ })1199 1197- // Access unknown index of an array draft.1198- expectRevoked(() => {1199- draft[1]1200- }, useProxies)1200+ // Access unknown index of an array draft.1201+ expectRevoked(() => {1202+ draft[1]1203+ }, useProxies)1204 1202- // Assign unknown index of an array draft.1203- expectRevoked(() => {1204- draft[1] = true1205- }, useProxies)1206- })1205+ // Assign unknown index of an array draft.1206+ expectRevoked(() => {1207+ draft[1] = true1208+ }, useProxies)1209+ })1210 1211 it("can access a child draft that was created before the draft was modified", () => {1212 produce({a: {}}, s => {1213 const before = s.a485 unmodified lines1699 throw "failed"1700 },1701 e => {1702 expect(e).toBe(err)1700- expect(() => draft.a).toThrowErrorMatchingSnapshot()1703+ if (!isProd) expect(() => draft.a).toThrowErrorMatchingSnapshot()1704 }1705 )1706 })1707 712 unmodified lines2420 produce(value, draft => {2421 draft.foo = true2422 })2423 ).toThrowError(2424+ isProd2425+ ? "[Immer] minified error nr: 21"2421- "produce can only be called on things that are draftable"2426+ : "produce can only be called on things that are draftable"2427 )2428 })2429 } else {2430 it("does not create a draft", () => {27 unmodified linesmodified:__tests__/current.js+7 added-1 removed
12 unmodified lines13 14 runTests("proxy", true)15 runTests("es5", false)16 17+const isProd = process.env.NODE_ENV === "production"18+19 function runTests(name, useProxies) {20 describe("current - " + name, () => {21 beforeAll(() => {22 setAutoFreeze(true)2 unmodified lines25 26 it("must be called on draft", () => {27 expect(() => {28 current({})27- }).toThrowError("[Immer] 'current' expects a draft, got: [object Object]")29+ }).toThrowError(30+ isProd31+ ? "[Immer] minified error nr: 22 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"32+ : "[Immer] 'current' expects a draft, got: [object Object]"33+ )34 })35 36 it("can handle simple arrays", () => {37 const base = [{x: 1}]175 unmodified linesmodified:__tests__/manual.js+12 added-9 removed
8 unmodified lines910111213141516171823 unmodified lines4243444546444547484947484950515253505152535455565758596085 unmodified lines8 unmodified lines} from "../src/immer"
enableAllPlugins()
const isProd = process.env.NODE_ENV === "production"
runTests("proxy", true)runTests("es5", false)
function runTests(name, useProxies) {23 unmodified lines expect(result).toEqual([{index: 0}, {index: 1}, {index: 2}]) expect(state).toEqual([{}, {}, {}]) })
if (!isProd) it("cannot modify after finish", () => { const state = {a: 1} it("cannot modify after finish", () => { const state = {a: 1}
const draft = createDraft(state) draft.a = 2 expect(finishDraft(draft)).toEqual({a: 2}) expect(() => { draft.a = 3 }).toThrowErrorMatchingSnapshot() }) const draft = createDraft(state) draft.a = 2 expect(finishDraft(draft)).toEqual({a: 2}) expect(() => { draft.a = 3 }).toThrowErrorMatchingSnapshot() })
it("should support patches drafts", () => { const state = {a: 1}
85 unmodified linesmodified:__tests__/original.js+14 added-4 removed
1 unmodified line2 import produce, {original, setUseProxies, enableAllPlugins} from "../src/immer"3 4 enableAllPlugins()5 6+const isProd = process.env.NODE_ENV === "production"7+8 describe("original", () => {9 const baseState = {10 a: [],11 b: {}29 unmodified lines41 produce(baseState, draftState => {42 draftState.c = {}43 draftState.d = 344 expect(() => original(draftState.c)).toThrowErrorMatchingInlineSnapshot(45+ isProd46+ ? `"[Immer] minified error nr: 23 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"`43- `"[Immer] 'original' expects a draft, got: [object Object]"`47+ : `"[Immer] 'original' expects a draft, got: [object Object]"`48 )49 expect(() => original(draftState.d)).toThrowErrorMatchingInlineSnapshot(50+ isProd51+ ? `"[Immer] minified error nr: 23 '3'. Find the full error at: https://bit.ly/3cXEKWf"`46- `"[Immer] 'original' expects a draft, got: 3"`52+ : `"[Immer] 'original' expects a draft, got: 3"`53 )54 })55 })56 57 it("should return undefined for an object that is not proxied", () => {58 expect(() => original({})).toThrowErrorMatchingInlineSnapshot(59+ isProd60+ ? `"[Immer] minified error nr: 23 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"`53- `"[Immer] 'original' expects a draft, got: [object Object]"`61+ : `"[Immer] 'original' expects a draft, got: [object Object]"`62 )63 expect(() => original(3)).toThrowErrorMatchingInlineSnapshot(64+ isProd65+ ? `"[Immer] minified error nr: 23 '3'. Find the full error at: https://bit.ly/3cXEKWf"`56- `"[Immer] 'original' expects a draft, got: 3"`66+ : `"[Immer] 'original' expects a draft, got: 3"`67 )68 })69 })modified:src/utils/errors.ts+1 added-1 removed
51 unmodified lines52 throw new Error(`[Immer] ${msg}`)53 }54 throw new Error(55 `[Immer] minified error nr: ${error}${56- args.length ? " " + args.join(",") : ""56+ args.length ? " " + args.map(s => `'${s}'`).join(",") : ""57 }. Find the full error at: https://bit.ly/3cXEKWf`58 )59 }modified:.travis.yml+5 added-4 removed
1 language: node_js2 node_js:3- - "10.18.1"4- # - "node"3+ # - "10.18.1"4+ - "node"5 env:6 - NODE_ENV=TEST7 cache:8 yarn: true2 unmodified lines11 before_script:12 - yarn global add if-node-version13 script:14 - yarn build || travis_terminate 115- - if-node-version 10 || { yarn test && travis_terminate 0; }16- - yarn coveralls15+ - yarn test || travis_terminate 116+ - yarn coveralls || travis_terminate 017 jobs:18 include:19 - stage: deploy20 if: branch == master && !fork21 script:22+ - yarn test || travis_terminate 123 - NODE_ENV= yarn build || travis_terminate 124 - yarn semantic-releaseadded:ignoreObseleteSnapshots.js+6 added
1+module.exports = function(results) {2+ // don't count obselete snapshot as a failure, but just check if there are no failing tests3+ // console.dir(results)4+ results.success = results.testResults.every(r => r.numFailingTests === 0)5+ return results6+}modified:jest.config.build.js+2 added-1 removed
12 unmodified lines13 },14 preset: "ts-jest/presets/js-with-ts",15 testEnvironment: "node",16 testMatch: ["**/__tests__/**/*.[jt]s?(x)"],17- snapshotResolver: "<rootDir>/jest.config.build.snapshots.js"17+ snapshotResolver: "<rootDir>/jest.config.build.snapshots.js",18+ testResultsProcessor: "<rootDir>/ignoreObseleteSnapshots.js"19 }modified:readme.md+1 added-1 removed
8 unmodified lines9 Winner of the "Breakthrough of the year" [React open source award](https://osawards.com/react/) and "Most impactful contribution" [JavaScript open source award](https://osawards.com/javascript/) in 201910 11 ## Contribute using one-click online setup12 13-You can use Gitpod(a free online VS Code like IDE) for contributing online. With a single click it will launch a workspace and automatically:13+You can use Gitpod (a free online VS Code like IDE) for contributing online. With a single click it will launch a workspace and automatically:14 15 - clone the immer repo.16 - install the dependencies.17 - run `yarn run start`.16 unmodified lines