@@ -58,7 +58,8 @@ class AbstractLevel extends EventEmitter {
58
58
permanence : manifest . permanence !== false ,
59
59
60
60
encodings : manifest . encodings || { } ,
61
- events : Object . assign ( { } , manifest . events , {
61
+ events : {
62
+ ...manifest . events ,
62
63
opening : true ,
63
64
open : true ,
64
65
closing : true ,
@@ -68,7 +69,7 @@ class AbstractLevel extends EventEmitter {
68
69
del : true ,
69
70
batch : true ,
70
71
clear : true
71
- } )
72
+ }
72
73
} )
73
74
74
75
// Monitor event listeners
@@ -332,8 +333,7 @@ class AbstractLevel extends EventEmitter {
332
333
333
334
// Forward encoding options to the underlying store
334
335
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 }
337
337
}
338
338
339
339
const encodedKey = keyEncoding . encode ( key )
@@ -390,7 +390,7 @@ class AbstractLevel extends EventEmitter {
390
390
391
391
// Forward encoding options
392
392
if ( options . keyEncoding !== keyFormat || options . valueEncoding !== valueFormat ) {
393
- options = Object . assign ( { } , options , { keyEncoding : keyFormat , valueEncoding : valueFormat } )
393
+ options = { ... options , keyEncoding : keyFormat , valueEncoding : valueFormat }
394
394
}
395
395
396
396
const mappedKeys = new Array ( keys . length )
@@ -454,11 +454,10 @@ class AbstractLevel extends EventEmitter {
454
454
455
455
// Forward encoding options to the underlying store
456
456
if ( options === this . #defaultOptions. key ) {
457
- // Avoid Object.assign() for default options
457
+ // Avoid cloning for default options
458
458
options = this . #defaultOptions. keyFormat
459
459
} 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 }
462
461
}
463
462
464
463
const encodedKey = keyEncoding . encode ( key )
@@ -504,11 +503,10 @@ class AbstractLevel extends EventEmitter {
504
503
505
504
// Forward encoding options to the underlying store
506
505
if ( options === this . #defaultOptions. key ) {
507
- // Avoid Object.assign() for default options
506
+ // Avoid cloning for default options
508
507
options = this . #defaultOptions. keyFormat
509
508
} 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 }
512
510
}
513
511
514
512
const mappedKeys = new Array ( keys . length )
@@ -565,12 +563,12 @@ class AbstractLevel extends EventEmitter {
565
563
const enableWriteEvent = this . #eventMonitor. write
566
564
const original = options
567
565
568
- // Avoid Object.assign() for default options
566
+ // Avoid cloning for default options
569
567
// TODO: also apply this tweak to get() and getMany()
570
568
if ( options === this . #defaultOptions. entry ) {
571
569
options = this . #defaultOptions. entryFormat
572
570
} else if ( options . keyEncoding !== keyFormat || options . valueEncoding !== valueFormat ) {
573
- options = Object . assign ( { } , options , { keyEncoding : keyFormat , valueEncoding : valueFormat } )
571
+ options = { ... options , keyEncoding : keyFormat , valueEncoding : valueFormat }
574
572
}
575
573
576
574
const encodedKey = keyEncoding . encode ( key )
@@ -580,15 +578,16 @@ class AbstractLevel extends EventEmitter {
580
578
await this . _put ( prefixedKey , encodedValue , options )
581
579
582
580
if ( enableWriteEvent ) {
583
- const op = Object . assign ( { } , original , {
581
+ const op = {
582
+ ...original ,
584
583
type : 'put' ,
585
584
key,
586
585
value,
587
586
keyEncoding,
588
587
valueEncoding,
589
588
encodedKey,
590
589
encodedValue
591
- } )
590
+ }
592
591
593
592
this . emit ( 'write' , [ op ] )
594
593
} else {
@@ -622,11 +621,11 @@ class AbstractLevel extends EventEmitter {
622
621
const enableWriteEvent = this . #eventMonitor. write
623
622
const original = options
624
623
625
- // Avoid Object.assign() for default options
624
+ // Avoid cloning for default options
626
625
if ( options === this . #defaultOptions. key ) {
627
626
options = this . #defaultOptions. keyFormat
628
627
} else if ( options . keyEncoding !== keyFormat ) {
629
- options = Object . assign ( { } , options , { keyEncoding : keyFormat } )
628
+ options = { ... options , keyEncoding : keyFormat }
630
629
}
631
630
632
631
const encodedKey = keyEncoding . encode ( key )
@@ -635,12 +634,13 @@ class AbstractLevel extends EventEmitter {
635
634
await this . _del ( prefixedKey , options )
636
635
637
636
if ( enableWriteEvent ) {
638
- const op = Object . assign ( { } , original , {
637
+ const op = {
638
+ ...original ,
639
639
type : 'del' ,
640
640
key,
641
641
keyEncoding,
642
642
encodedKey
643
- } )
643
+ }
644
644
645
645
this . emit ( 'write' , [ op ] )
646
646
} else {
@@ -694,7 +694,7 @@ class AbstractLevel extends EventEmitter {
694
694
// Clone the op so that we can freely mutate it. We can't use a class because the
695
695
// op can have userland properties that we'd have to copy, negating the performance
696
696
// benefits of a class. So use a plain object.
697
- const op = Object . assign ( { } , options , operations [ i ] )
697
+ const op = { ... options , ... operations [ i ] }
698
698
699
699
// Hook functions can modify op but not its type or sublevel, so cache those
700
700
const isPut = op . type === 'put'
@@ -753,7 +753,7 @@ class AbstractLevel extends EventEmitter {
753
753
if ( enableWriteEvent && ! siblings ) {
754
754
// Clone op before we mutate it for the private API
755
755
// TODO (future semver-major): consider sending this shape to private API too
756
- publicOperation = Object . assign ( { } , op )
756
+ publicOperation = { ... op }
757
757
publicOperation . encodedKey = encodedKey
758
758
759
759
if ( delegated ) {
0 commit comments