Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map & Set support (v5) #354

Merged
merged 48 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
30db0f3
feat: `Map` drafts and patches
Apr 14, 2019
3163a7d
chore: reorganize src/proxy.js
aleclarson Apr 17, 2019
3298a77
refactor: simplify mapGetters.keys
aleclarson Apr 17, 2019
08d88b8
fix: remove "function*" syntax
aleclarson Apr 17, 2019
7bbec0a
fix: add Map getter for DRAFT_STATE, make isEnumerable more resilient
Apr 18, 2019
7001201
fix: Map.prototype.set should return a draft
Apr 18, 2019
53d0cdf
nit: ensure isEnumerable returns a boolean
aleclarson Apr 18, 2019
a674a78
nit: argument names
aleclarson Apr 18, 2019
4355b63
feat: `Set` drafts
Apr 18, 2019
dd82d89
refactor: traps for Maps and Sets
Apr 22, 2019
6255a58
docs: es6 map support
aleclarson Apr 17, 2019
930b4ab
fix: add more traps for Maps and Sets
Apr 22, 2019
5857d63
refactor: markChanged function
aleclarson Apr 22, 2019
4164f0d
nit: merge isMap and isSet checks
aleclarson Apr 22, 2019
5093fd0
refactor: makeTrapsForGetters function
aleclarson Apr 22, 2019
6501ec5
feat: add support of non-primitive keys for `Maps`
May 19, 2019
c34ff3e
docs: add a note about patch serialization for Maps
May 19, 2019
00fb26a
docs: add a migration guide for 4.0
May 19, 2019
eaea1b0
feat: `onAssign` for `Maps`
May 19, 2019
1ca49ef
feat: `onDelete` for `Maps`
May 19, 2019
8de78f2
feat: `onCopy` for `Maps`
May 19, 2019
aa24f65
feat: `onAssign` for `Sets`
May 19, 2019
e56ad54
feat: `onCopy` for `Sets`
May 19, 2019
221d601
test: remove defuseProxies helper
aleclarson May 28, 2019
b6b542d
refactor: helper functions
aleclarson May 28, 2019
eba300f
refactor: rename "source" helper to "latest"
aleclarson May 28, 2019
ddf5dbb
refactor: "get" trap for Maps
aleclarson May 28, 2019
a2c4754
nit: minor refactoring
aleclarson May 28, 2019
594d637
docs: remove warning
aleclarson May 28, 2019
1f5806c
refactor: avoid unnecessary function wrapper
aleclarson May 28, 2019
13eab80
4.0.0-beta.0
aleclarson May 29, 2019
ea9ba04
feat: add es5 support for Map/Set
runnez Oct 4, 2019
77051a9
fix patches spec running
runnez Oct 21, 2019
0de782c
fix map patches
runnez Oct 21, 2019
85656cb
Merge pull request #437 from runnez/es5-map-and-set-support
mweststrate Oct 22, 2019
ae80361
run prettier with master config before merging
mweststrate Oct 22, 2019
732fb19
re-run prettier
mweststrate Oct 22, 2019
741e941
Merge branch 'master' into v4
mweststrate Oct 23, 2019
ff25a83
fix specs
runnez Oct 25, 2019
ffd8769
fix ie11
runnez Oct 25, 2019
f90b586
avoid creating null keys in proxies
runnez Oct 28, 2019
24658bc
ensure set patch is not modified
runnez Oct 28, 2019
7d32b7c
More tests, also fixed binding of produceWithPatches
mweststrate Oct 30, 2019
82db631
Made sure maps and sets become truly immutable
mweststrate Oct 30, 2019
e819e79
Travis fix(?)
mweststrate Oct 30, 2019
7335671
Updated docs. Also fixes #445
mweststrate Oct 30, 2019
f8c65f0
Updated typings
mweststrate Oct 30, 2019
0f4fe3f
Sanity fix
mweststrate Oct 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Please provide either a [CodeSandbox demo](https://codesandbox.io/s/82zqr6n3kj)

## Environment

- **Immer version:**
- [ ] Occurs with `setUseProxies(true)`
- [ ] Occurs with `setUseProxies(false)` (ES5 only)
- **Immer version:**
- [ ] Occurs with `setUseProxies(true)`
- [ ] Occurs with `setUseProxies(false)` (ES5 only)
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ typings/

.idea
dist/
website/build
website/build
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"files": [".prettierrc", "*.json"],
"options": {
"printWidth": 200,
"tabWidth": 2
"tabWidth": 2,
"useTabs": false
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js
node_js:
- "8"
- "10"
# - "node"
# - "node"
env:
- NODE_ENV=TEST
cache:
Expand Down
1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
282 changes: 282 additions & 0 deletions __tests__/__snapshots__/base.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,285 @@ exports[`base functionality - proxy (no freeze) throws when Object.definePropert
exports[`base functionality - proxy (no freeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"Object.setPrototypeOf() cannot be used on an Immer draft"`;

exports[`base functionality - proxy (no freeze) throws when the draft is modified and another object is returned 1`] = `"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;

exports[`complex nesting map / set / object modify deep object 1`] = `
Object {
"map": Map {
"set1" => Set {
Object {
"a": 2,
},
Object {
"b": 2,
},
},
"set2" => Set {
Object {
"c": 3,
},
},
},
}
`;

exports[`complex nesting map / set / object modify deep object 2`] = `
Array [
Object {
"op": "remove",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 1,
},
},
Object {
"op": "add",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 2,
},
},
]
`;

exports[`complex nesting map / set / object modify deep object 3`] = `
Object {
"map": Map {
"set1" => Set {
Object {
"a": 2,
},
Object {
"b": 2,
},
},
"set2" => Set {
Object {
"c": 3,
},
},
},
}
`;

exports[`complex nesting map / set / object modify deep object 4`] = `
Array [
Object {
"op": "remove",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 1,
},
},
Object {
"op": "add",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 2,
},
},
]
`;

exports[`complex nesting map / set / object modify deep object 5`] = `
Object {
"map": Map {
"set1" => Set {
Object {
"a": 2,
},
Object {
"b": 2,
},
},
"set2" => Set {
Object {
"c": 3,
},
},
},
}
`;

exports[`complex nesting map / set / object modify deep object 6`] = `
Array [
Object {
"op": "remove",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 1,
},
},
Object {
"op": "add",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 2,
},
},
]
`;

exports[`complex nesting map / set / object modify deep object 7`] = `
Object {
"map": Map {
"set1" => Set {
Object {
"a": 2,
},
Object {
"b": 2,
},
},
"set2" => Set {
Object {
"c": 3,
},
},
},
}
`;

exports[`complex nesting map / set / object modify deep object 8`] = `
Array [
Object {
"op": "remove",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 1,
},
},
Object {
"op": "add",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 2,
},
},
]
`;

exports[`complex nesting map / set / object modify deep object 9`] = `
Object {
"map": Map {
"set1" => Set {
Object {
"a": 2,
},
Object {
"b": 2,
},
},
"set2" => Set {
Object {
"c": 3,
},
},
},
}
`;

exports[`complex nesting map / set / object modify deep object 10`] = `
Array [
Object {
"op": "remove",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 1,
},
},
Object {
"op": "add",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 2,
},
},
]
`;

exports[`complex nesting map / set / object modify deep object 11`] = `
Object {
"map": Map {
"set1" => Set {
Object {
"a": 2,
},
Object {
"b": 2,
},
},
"set2" => Set {
Object {
"c": 3,
},
},
},
}
`;

exports[`complex nesting map / set / object modify deep object 12`] = `
Array [
Object {
"op": "remove",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 1,
},
},
Object {
"op": "add",
"path": Array [
"map",
"set1",
0,
],
"value": Object {
"a": 2,
},
},
]
`;
Loading