File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ var getAllKeys = typeof Object.getOwnPropertySymbols === 'function' ?
19
19
/* istanbul ignore next */
20
20
function copy ( object ) {
21
21
if ( object instanceof Array ) {
22
- return object . slice ( ) ;
22
+ return assign ( object . constructor ( object . length ) , object )
23
23
} else if ( object && typeof object === 'object' ) {
24
24
var prototype = object . constructor && object . constructor . prototype
25
25
return assign ( Object . create ( prototype || null ) , object ) ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " immutability-helper" ,
3
- "version" : " 2.2.3 " ,
3
+ "version" : " 2.3.0 " ,
4
4
"description" : " mutate a copy of data without changing the original source" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -412,6 +412,16 @@ describe('update', function() {
412
412
expect ( a ) . toBe ( b )
413
413
expect ( a ) . toBe ( c )
414
414
expect ( a ) . toBe ( d )
415
- } )
415
+ } ) ;
416
+
417
+ it ( 'does not lose non integer keys of an array' , function ( ) {
418
+ var state = a = { items : [
419
+ { name : 'Superman' , strength : 1000 } ,
420
+ { name : 'Jim' , strength : 2 } ,
421
+ ] } ;
422
+ state . items . top = 0
423
+ var state2 = update ( state , { items : { 1 : { strength : { $set : 3 } } } } ) ;
424
+ expect ( state2 . items . top ) . toBe ( 0 )
425
+ } ) ;
416
426
417
427
} ) ;
You can’t perform that action at this time.
0 commit comments