@@ -78,9 +78,7 @@ export function uneval(value, replacer) {
7878
7979 case 'Map' :
8080 for ( const [ key , value ] of thing ) {
81- keys . push (
82- `.get(${ is_primitive ( key ) ? stringify_primitive ( key ) : '...' } )`
83- ) ;
81+ keys . push ( `.get(${ is_primitive ( key ) ? stringify_primitive ( key ) : '...' } )` ) ;
8482 walk ( value ) ;
8583 keys . pop ( ) ;
8684 }
@@ -116,21 +114,11 @@ export function uneval(value, replacer) {
116114
117115 default :
118116 if ( ! is_plain_object ( thing ) ) {
119- throw new DevalueError (
120- `Cannot stringify arbitrary non-POJOs` ,
121- keys ,
122- thing ,
123- value
124- ) ;
117+ throw new DevalueError ( `Cannot stringify arbitrary non-POJOs` , keys , thing , value ) ;
125118 }
126119
127120 if ( enumerable_symbols ( thing ) . length > 0 ) {
128- throw new DevalueError (
129- `Cannot stringify POJOs with symbolic keys` ,
130- keys ,
131- thing ,
132- value
133- ) ;
121+ throw new DevalueError ( `Cannot stringify POJOs with symbolic keys` , keys , thing , value ) ;
134122 }
135123
136124 for ( const key of Object . keys ( thing ) ) {
@@ -188,9 +176,7 @@ export function uneval(value, replacer) {
188176 return `Object(${ stringify ( thing . valueOf ( ) ) } )` ;
189177
190178 case 'RegExp' :
191- return `new RegExp(${ stringify_string ( thing . source ) } , "${
192- thing . flags
193- } ")`;
179+ return `new RegExp(${ stringify_string ( thing . source ) } , "${ thing . flags } ")` ;
194180
195181 case 'Date' :
196182 return `new Date(${ thing . getTime ( ) } )` ;
@@ -260,12 +246,10 @@ export function uneval(value, replacer) {
260246 const d = String ( thing . length ) . length ;
261247
262248 const hole_cost = thing . length + 2 ;
263- const sparse_cost = ( 25 + d ) + population * ( d + 2 ) ;
249+ const sparse_cost = 25 + d + population * ( d + 2 ) ;
264250
265251 if ( hole_cost > sparse_cost ) {
266- const entries = populated_keys
267- . map ( ( k ) => `${ k } :${ stringify ( thing [ k ] ) } ` )
268- . join ( ',' ) ;
252+ const entries = populated_keys . map ( ( k ) => `${ k } :${ stringify ( thing [ k ] ) } ` ) . join ( ',' ) ;
269253 return `Object.assign(Array(${ thing . length } ),{${ entries } })` ;
270254 }
271255
@@ -333,14 +317,10 @@ export function uneval(value, replacer) {
333317
334318 default :
335319 const keys = Object . keys ( thing ) ;
336- const obj = keys
337- . map ( ( key ) => `${ safe_key ( key ) } :${ stringify ( thing [ key ] ) } ` )
338- . join ( ',' ) ;
320+ const obj = keys . map ( ( key ) => `${ safe_key ( key ) } :${ stringify ( thing [ key ] ) } ` ) . join ( ',' ) ;
339321 const proto = Object . getPrototypeOf ( thing ) ;
340322 if ( proto === null ) {
341- return keys . length > 0
342- ? `{${ obj } ,__proto__:null}`
343- : `{__proto__:null}` ;
323+ return keys . length > 0 ? `{${ obj } ,__proto__:null}` : `{__proto__:null}` ;
344324 }
345325
346326 return `{${ obj } }` ;
@@ -415,28 +395,20 @@ export function uneval(value, replacer) {
415395 break ;
416396
417397 case 'ArrayBuffer' :
418- values . push (
419- `new Uint8Array([${ new Uint8Array ( thing ) . join ( ',' ) } ]).buffer`
420- ) ;
398+ values . push ( `new Uint8Array([${ new Uint8Array ( thing ) . join ( ',' ) } ]).buffer` ) ;
421399 break ;
422400
423401 default :
424- values . push (
425- Object . getPrototypeOf ( thing ) === null ? 'Object.create(null)' : '{}'
426- ) ;
402+ values . push ( Object . getPrototypeOf ( thing ) === null ? 'Object.create(null)' : '{}' ) ;
427403 Object . keys ( thing ) . forEach ( ( key ) => {
428- statements . push (
429- `${ name } ${ safe_prop ( key ) } =${ stringify ( thing [ key ] ) } `
430- ) ;
404+ statements . push ( `${ name } ${ safe_prop ( key ) } =${ stringify ( thing [ key ] ) } ` ) ;
431405 } ) ;
432406 }
433407 } ) ;
434408
435409 statements . push ( `return ${ str } ` ) ;
436410
437- return `(function(${ params . join ( ',' ) } ){${ statements . join (
438- ';'
439- ) } }(${ values . join ( ',' ) } ))`;
411+ return `(function(${ params . join ( ',' ) } ){${ statements . join ( ';' ) } }(${ values . join ( ',' ) } ))` ;
440412 } else {
441413 return str ;
442414 }
@@ -466,9 +438,7 @@ function escape_unsafe_chars(str) {
466438
467439/** @param {string } key */
468440function safe_key ( key ) {
469- return / ^ [ _ $ a - z A - Z ] [ _ $ a - z A - Z 0 - 9 ] * $ / . test ( key )
470- ? key
471- : escape_unsafe_chars ( JSON . stringify ( key ) ) ;
441+ return / ^ [ _ $ a - z A - Z ] [ _ $ a - z A - Z 0 - 9 ] * $ / . test ( key ) ? key : escape_unsafe_chars ( JSON . stringify ( key ) ) ;
472442}
473443
474444/** @param {string } key */
0 commit comments