@@ -58,7 +58,8 @@ class AbstractLevel extends EventEmitter {
5858 permanence : manifest . permanence !== false ,
5959
6060 encodings : manifest . encodings || { } ,
61- events : Object . assign ( { } , manifest . events , {
61+ events : {
62+ ...manifest . events ,
6263 opening : true ,
6364 open : true ,
6465 closing : true ,
@@ -68,7 +69,7 @@ class AbstractLevel extends EventEmitter {
6869 del : true ,
6970 batch : true ,
7071 clear : true
71- } )
72+ }
7273 } )
7374
7475 // Monitor event listeners
@@ -332,8 +333,7 @@ class AbstractLevel extends EventEmitter {
332333
333334 // Forward encoding options to the underlying store
334335 if ( options . keyEncoding !== keyFormat || options . valueEncoding !== valueFormat ) {
335- // Avoid spread operator because of https://bugs.chromium.org/p/chromium/issues/detail?id=1204540
336- options = Object . assign ( { } , options , { keyEncoding : keyFormat , valueEncoding : valueFormat } )
336+ options = { ...options , keyEncoding : keyFormat , valueEncoding : valueFormat }
337337 }
338338
339339 const encodedKey = keyEncoding . encode ( key )
@@ -390,7 +390,7 @@ class AbstractLevel extends EventEmitter {
390390
391391 // Forward encoding options
392392 if ( options . keyEncoding !== keyFormat || options . valueEncoding !== valueFormat ) {
393- options = Object . assign ( { } , options , { keyEncoding : keyFormat , valueEncoding : valueFormat } )
393+ options = { ... options , keyEncoding : keyFormat , valueEncoding : valueFormat }
394394 }
395395
396396 const mappedKeys = new Array ( keys . length )
@@ -454,11 +454,10 @@ class AbstractLevel extends EventEmitter {
454454
455455 // Forward encoding options to the underlying store
456456 if ( options === this . #defaultOptions. key ) {
457- // Avoid Object.assign() for default options
457+ // Avoid cloning for default options
458458 options = this . #defaultOptions. keyFormat
459459 } else if ( options . keyEncoding !== keyFormat ) {
460- // Avoid spread operator because of https://bugs.chromium.org/p/chromium/issues/detail?id=1204540
461- options = Object . assign ( { } , options , { keyEncoding : keyFormat } )
460+ options = { ...options , keyEncoding : keyFormat }
462461 }
463462
464463 const encodedKey = keyEncoding . encode ( key )
@@ -504,11 +503,10 @@ class AbstractLevel extends EventEmitter {
504503
505504 // Forward encoding options to the underlying store
506505 if ( options === this . #defaultOptions. key ) {
507- // Avoid Object.assign() for default options
506+ // Avoid cloning for default options
508507 options = this . #defaultOptions. keyFormat
509508 } else if ( options . keyEncoding !== keyFormat ) {
510- // Avoid spread operator because of https://bugs.chromium.org/p/chromium/issues/detail?id=1204540
511- options = Object . assign ( { } , options , { keyEncoding : keyFormat } )
509+ options = { ...options , keyEncoding : keyFormat }
512510 }
513511
514512 const mappedKeys = new Array ( keys . length )
@@ -565,12 +563,12 @@ class AbstractLevel extends EventEmitter {
565563 const enableWriteEvent = this . #eventMonitor. write
566564 const original = options
567565
568- // Avoid Object.assign() for default options
566+ // Avoid cloning for default options
569567 // TODO: also apply this tweak to get() and getMany()
570568 if ( options === this . #defaultOptions. entry ) {
571569 options = this . #defaultOptions. entryFormat
572570 } else if ( options . keyEncoding !== keyFormat || options . valueEncoding !== valueFormat ) {
573- options = Object . assign ( { } , options , { keyEncoding : keyFormat , valueEncoding : valueFormat } )
571+ options = { ... options , keyEncoding : keyFormat , valueEncoding : valueFormat }
574572 }
575573
576574 const encodedKey = keyEncoding . encode ( key )
@@ -580,15 +578,16 @@ class AbstractLevel extends EventEmitter {
580578 await this . _put ( prefixedKey , encodedValue , options )
581579
582580 if ( enableWriteEvent ) {
583- const op = Object . assign ( { } , original , {
581+ const op = {
582+ ...original ,
584583 type : 'put' ,
585584 key,
586585 value,
587586 keyEncoding,
588587 valueEncoding,
589588 encodedKey,
590589 encodedValue
591- } )
590+ }
592591
593592 this . emit ( 'write' , [ op ] )
594593 } else {
@@ -622,11 +621,11 @@ class AbstractLevel extends EventEmitter {
622621 const enableWriteEvent = this . #eventMonitor. write
623622 const original = options
624623
625- // Avoid Object.assign() for default options
624+ // Avoid cloning for default options
626625 if ( options === this . #defaultOptions. key ) {
627626 options = this . #defaultOptions. keyFormat
628627 } else if ( options . keyEncoding !== keyFormat ) {
629- options = Object . assign ( { } , options , { keyEncoding : keyFormat } )
628+ options = { ... options , keyEncoding : keyFormat }
630629 }
631630
632631 const encodedKey = keyEncoding . encode ( key )
@@ -635,12 +634,13 @@ class AbstractLevel extends EventEmitter {
635634 await this . _del ( prefixedKey , options )
636635
637636 if ( enableWriteEvent ) {
638- const op = Object . assign ( { } , original , {
637+ const op = {
638+ ...original ,
639639 type : 'del' ,
640640 key,
641641 keyEncoding,
642642 encodedKey
643- } )
643+ }
644644
645645 this . emit ( 'write' , [ op ] )
646646 } else {
@@ -694,7 +694,7 @@ class AbstractLevel extends EventEmitter {
694694 // Clone the op so that we can freely mutate it. We can't use a class because the
695695 // op can have userland properties that we'd have to copy, negating the performance
696696 // benefits of a class. So use a plain object.
697- const op = Object . assign ( { } , options , operations [ i ] )
697+ const op = { ... options , ... operations [ i ] }
698698
699699 // Hook functions can modify op but not its type or sublevel, so cache those
700700 const isPut = op . type === 'put'
@@ -753,7 +753,7 @@ class AbstractLevel extends EventEmitter {
753753 if ( enableWriteEvent && ! siblings ) {
754754 // Clone op before we mutate it for the private API
755755 // TODO (future semver-major): consider sending this shape to private API too
756- publicOperation = Object . assign ( { } , op )
756+ publicOperation = { ... op }
757757 publicOperation . encodedKey = encodedKey
758758
759759 if ( delegated ) {
0 commit comments