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) {
3131
3232 /** @type {Array<{ key: string, fn: (value: any) => any }> } */
3333 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+ }
3638 }
3739
3840 /** @type {string[] } */
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ const fixtures = {
167167 json : '[["Uint8Array","AQID"]]'
168168 } ,
169169 {
170- name : " ArrayBuffer" ,
170+ name : ' ArrayBuffer' ,
171171 value : new Uint8Array ( [ 1 , 2 , 3 ] ) . buffer ,
172172 js : 'new Uint8Array([1,2,3]).buffer' ,
173173 json : '[["ArrayBuffer","AQID"]]'
@@ -429,9 +429,10 @@ const fixtures = {
429429 return `new Custom(${ uneval ( value . value ) } )` ;
430430 }
431431 } ,
432- reducers : {
432+ // test for https://github.com/Rich-Harris/devalue/pull/80
433+ reducers : Object . assign ( Object . create ( { polluted : true } ) , {
433434 Custom : ( x ) => x instanceof Custom && x . value
434- } ,
435+ } ) ,
435436 revivers : {
436437 Custom : ( x ) => new Custom ( x )
437438 } ,
You can’t perform that action at this time.
0 commit comments