Skip to content

Commit 2c46945

Browse files
committed
-> v3.1.0
1 parent 2f8898b commit 2c46945

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# devalue changelog
22

3+
## 3.1.0
4+
5+
- Include `path` in error object if value is unserializable
6+
37
## 3.0.1
48

59
- Prevent duplicate parameter names ([#33](https://github.com/Rich-Harris/devalue/pull/33))

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,24 @@ obj.self = obj;
3737
devalue(obj); // '(function(a){a.a=1;a.b=2;a.c=3;a.self=a;return a}({}))'
3838
```
3939

40-
If `devalue` encounters a function or a non-POJO, it will throw an error.
40+
## Error handling
41+
42+
If `devalue` encounters a function or a non-POJO, it will throw an error. You can find where in the input data the offending value lives by inspecting `error.path`:
43+
44+
```js
45+
try {
46+
const map = new Map();
47+
map.set('key', function invalid() {});
48+
49+
devalue({
50+
object: {
51+
array: [map]
52+
}
53+
})
54+
} catch (e) {
55+
console.log(e.path); // '.object.array[0].get("key")'
56+
}
57+
```
4158

4259
## XSS mitigation
4360

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "devalue",
33
"description": "Gets the job done when JSON.stringify can't",
4-
"version": "3.0.1",
4+
"version": "3.1.0",
55
"repository": "Rich-Harris/devalue",
66
"exports": {
77
".": {

0 commit comments

Comments
 (0)