File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,10 @@ export function stringify(value, reducers) {
31
31
32
32
/** @type {Array<{ key: string, fn: (value: any) => any }> } */
33
33
const custom = [ ] ;
34
- for ( const key in reducers ) {
35
- custom . push ( { key, fn : reducers [ key ] } ) ;
34
+ if ( reducers ) {
35
+ for ( const key of Object . getOwnPropertyNames ( reducers ) ) {
36
+ custom . push ( { key, fn : reducers [ key ] } ) ;
37
+ }
36
38
}
37
39
38
40
/** @type {string[] } */
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ const fixtures = {
167
167
json : '[["Uint8Array","AQID"]]'
168
168
} ,
169
169
{
170
- name : " ArrayBuffer" ,
170
+ name : ' ArrayBuffer' ,
171
171
value : new Uint8Array ( [ 1 , 2 , 3 ] ) . buffer ,
172
172
js : 'new Uint8Array([1,2,3]).buffer' ,
173
173
json : '[["ArrayBuffer","AQID"]]'
@@ -429,9 +429,10 @@ const fixtures = {
429
429
return `new Custom(${ uneval ( value . value ) } )` ;
430
430
}
431
431
} ,
432
- reducers : {
432
+ // test for https://github.com/Rich-Harris/devalue/pull/80
433
+ reducers : Object . assign ( Object . create ( { polluted : true } ) , {
433
434
Custom : ( x ) => x instanceof Custom && x . value
434
- } ,
435
+ } ) ,
435
436
revivers : {
436
437
Custom : ( x ) => new Custom ( x )
437
438
} ,
You can’t perform that action at this time.
0 commit comments