2
2
if ( typeof exports === 'object' && typeof module === 'object' )
3
3
module . exports = factory ( ) ;
4
4
else if ( typeof define === 'function' && define . amd )
5
- define ( factory ) ;
5
+ define ( [ ] , factory ) ;
6
6
else if ( typeof exports === 'object' )
7
7
exports [ "Nuclear" ] = factory ( ) ;
8
8
else
@@ -220,7 +220,21 @@ return /******/ (function(modules) { // webpackBootstrap
220
220
}
221
221
222
222
function wrapIndex ( iter , index ) {
223
- return index >= 0 ? ( + index ) : ensureSize ( iter ) + ( + index ) ;
223
+ // This implements "is array index" which the ECMAString spec defines as:
224
+ // A String property name P is an array index if and only if
225
+ // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
226
+ // to 2^32−1.
227
+ // However note that we're currently calling ToNumber() instead of ToUint32()
228
+ // which should be improved in the future, as floating point numbers should
229
+ // not be accepted as an array index.
230
+ if ( typeof index !== 'number' ) {
231
+ var numIndex = + index ;
232
+ if ( '' + numIndex !== index ) {
233
+ return NaN ;
234
+ }
235
+ index = numIndex ;
236
+ }
237
+ return index < 0 ? ensureSize ( iter ) + index : index ;
224
238
}
225
239
226
240
function returnTrue ( ) {
@@ -890,7 +904,7 @@ return /******/ (function(modules) { // webpackBootstrap
890
904
var src_Math__imul =
891
905
typeof Math . imul === 'function' && Math . imul ( 0xffffffff , 2 ) === - 2 ?
892
906
Math . imul :
893
- function src_Math__imul ( a , b ) {
907
+ function imul ( a , b ) {
894
908
a = a | 0 ; // int
895
909
b = b | 0 ; // int
896
910
var c = a & 0xffff ;
@@ -1441,6 +1455,15 @@ return /******/ (function(modules) { // webpackBootstrap
1441
1455
function sliceFactory ( iterable , begin , end , useKeys ) {
1442
1456
var originalSize = iterable . size ;
1443
1457
1458
+ // Sanitize begin & end using this shorthand for ToInt32(argument)
1459
+ // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
1460
+ if ( begin !== undefined ) {
1461
+ begin = begin | 0 ;
1462
+ }
1463
+ if ( end !== undefined ) {
1464
+ end = end | 0 ;
1465
+ }
1466
+
1444
1467
if ( wholeSlice ( begin , end , originalSize ) ) {
1445
1468
return iterable ;
1446
1469
}
@@ -1467,7 +1490,9 @@ return /******/ (function(modules) { // webpackBootstrap
1467
1490
1468
1491
var sliceSeq = makeSequence ( iterable ) ;
1469
1492
1470
- sliceSeq . size = sliceSize ;
1493
+ // If iterable.size is undefined, the size of the realized sliceSeq is
1494
+ // unknown at this point unless the number of items to slice is 0
1495
+ sliceSeq . size = sliceSize === 0 ? sliceSize : iterable . size && sliceSize || undefined ;
1471
1496
1472
1497
if ( ! useKeys && isSeq ( iterable ) && sliceSize >= 0 ) {
1473
1498
sliceSeq . get = function ( index , notSetValue ) {
@@ -1916,7 +1941,7 @@ return /******/ (function(modules) { // webpackBootstrap
1916
1941
1917
1942
function src_Map__Map ( value ) {
1918
1943
return value === null || value === undefined ? emptyMap ( ) :
1919
- isMap ( value ) ? value :
1944
+ isMap ( value ) && ! isOrdered ( value ) ? value :
1920
1945
emptyMap ( ) . withMutations ( function ( map ) {
1921
1946
var iter = KeyedIterable ( value ) ;
1922
1947
assertNotInfinite ( iter . size ) ;
@@ -2763,12 +2788,12 @@ return /******/ (function(modules) { // webpackBootstrap
2763
2788
2764
2789
List . prototype . get = function ( index , notSetValue ) {
2765
2790
index = wrapIndex ( this , index ) ;
2766
- if ( index < 0 || index >= this . size ) {
2767
- return notSetValue ;
2791
+ if ( index >= 0 && index < this . size ) {
2792
+ index += this . _origin ;
2793
+ var node = listNodeFor ( this , index ) ;
2794
+ return node && node . array [ index & MASK ] ;
2768
2795
}
2769
- index += this . _origin ;
2770
- var node = listNodeFor ( this , index ) ;
2771
- return node && node . array [ index & MASK ] ;
2796
+ return notSetValue ;
2772
2797
} ;
2773
2798
2774
2799
// @pragma Modification
@@ -2964,29 +2989,25 @@ return /******/ (function(modules) { // webpackBootstrap
2964
2989
} ;
2965
2990
2966
2991
VNode . prototype . removeAfter = function ( ownerID , level , index ) {
2967
- if ( index === level ? 1 << level : 0 || this . array . length === 0 ) {
2992
+ if ( index === ( level ? 1 << level : 0 ) || this . array . length === 0 ) {
2968
2993
return this ;
2969
2994
}
2970
2995
var sizeIndex = ( ( index - 1 ) >>> level ) & MASK ;
2971
2996
if ( sizeIndex >= this . array . length ) {
2972
2997
return this ;
2973
2998
}
2974
- var removingLast = sizeIndex === this . array . length - 1 ;
2999
+
2975
3000
var newChild ;
2976
3001
if ( level > 0 ) {
2977
3002
var oldChild = this . array [ sizeIndex ] ;
2978
3003
newChild = oldChild && oldChild . removeAfter ( ownerID , level - SHIFT , index ) ;
2979
- if ( newChild === oldChild && removingLast ) {
3004
+ if ( newChild === oldChild && sizeIndex === this . array . length - 1 ) {
2980
3005
return this ;
2981
3006
}
2982
3007
}
2983
- if ( removingLast && ! newChild ) {
2984
- return this ;
2985
- }
3008
+
2986
3009
var editable = editableVNode ( this , ownerID ) ;
2987
- if ( ! removingLast ) {
2988
- editable . array . pop ( ) ;
2989
- }
3010
+ editable . array . splice ( sizeIndex + 1 ) ;
2990
3011
if ( newChild ) {
2991
3012
editable . array [ sizeIndex ] = newChild ;
2992
3013
}
@@ -3078,6 +3099,10 @@ return /******/ (function(modules) { // webpackBootstrap
3078
3099
function updateList ( list , index , value ) {
3079
3100
index = wrapIndex ( list , index ) ;
3080
3101
3102
+ if ( index !== index ) {
3103
+ return list ;
3104
+ }
3105
+
3081
3106
if ( index >= list . size || index < 0 ) {
3082
3107
return list . withMutations ( function ( list ) {
3083
3108
index < 0 ?
@@ -3169,6 +3194,14 @@ return /******/ (function(modules) { // webpackBootstrap
3169
3194
}
3170
3195
3171
3196
function setListBounds ( list , begin , end ) {
3197
+ // Sanitize begin & end using this shorthand for ToInt32(argument)
3198
+ // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
3199
+ if ( begin !== undefined ) {
3200
+ begin = begin | 0 ;
3201
+ }
3202
+ if ( end !== undefined ) {
3203
+ end = end | 0 ;
3204
+ }
3172
3205
var owner = list . __ownerID || new OwnerID ( ) ;
3173
3206
var oldOrigin = list . _origin ;
3174
3207
var oldCapacity = list . _capacity ;
@@ -3681,7 +3714,7 @@ return /******/ (function(modules) { // webpackBootstrap
3681
3714
3682
3715
function src_Set__Set ( value ) {
3683
3716
return value === null || value === undefined ? emptySet ( ) :
3684
- isSet ( value ) ? value :
3717
+ isSet ( value ) && ! isOrdered ( value ) ? value :
3685
3718
emptySet ( ) . withMutations ( function ( set ) {
3686
3719
var iter = SetIterable ( value ) ;
3687
3720
assertNotInfinite ( iter . size ) ;
@@ -4426,10 +4459,6 @@ return /******/ (function(modules) { // webpackBootstrap
4426
4459
return reify ( this , concatFactory ( this , values ) ) ;
4427
4460
} ,
4428
4461
4429
- contains : function ( searchValue ) {
4430
- return this . includes ( searchValue ) ;
4431
- } ,
4432
-
4433
4462
includes : function ( searchValue ) {
4434
4463
return this . some ( function ( value ) { return is ( value , searchValue ) } ) ;
4435
4464
} ,
@@ -4719,7 +4748,7 @@ return /******/ (function(modules) { // webpackBootstrap
4719
4748
4720
4749
hashCode : function ( ) {
4721
4750
return this . __hash || ( this . __hash = hashIterable ( this ) ) ;
4722
- } ,
4751
+ }
4723
4752
4724
4753
4725
4754
// ### Internal
@@ -4742,6 +4771,7 @@ return /******/ (function(modules) { // webpackBootstrap
4742
4771
IterablePrototype . inspect =
4743
4772
IterablePrototype . toSource = function ( ) { return this . toString ( ) ; } ;
4744
4773
IterablePrototype . chain = IterablePrototype . flatMap ;
4774
+ IterablePrototype . contains = IterablePrototype . includes ;
4745
4775
4746
4776
// Temporary warning about using length
4747
4777
( function ( ) {
@@ -4812,7 +4842,7 @@ return /******/ (function(modules) { // webpackBootstrap
4812
4842
function ( k , v ) { return mapper . call ( context , k , v , this$0 ) }
4813
4843
) . flip ( )
4814
4844
) ;
4815
- } ,
4845
+ }
4816
4846
4817
4847
} ) ;
4818
4848
@@ -4867,7 +4897,10 @@ return /******/ (function(modules) { // webpackBootstrap
4867
4897
if ( numArgs === 0 || ( numArgs === 2 && ! removeNum ) ) {
4868
4898
return this ;
4869
4899
}
4870
- index = resolveBegin ( index , this . size ) ;
4900
+ // If index is negative, it should resolve relative to the size of the
4901
+ // collection. However size may be expensive to compute if not cached, so
4902
+ // only call count() if the number is in fact negative.
4903
+ index = resolveBegin ( index , index < 0 ? this . count ( ) : this . size ) ;
4871
4904
var spliced = this . slice ( 0 , index ) ;
4872
4905
return reify (
4873
4906
this ,
@@ -4940,7 +4973,7 @@ return /******/ (function(modules) { // webpackBootstrap
4940
4973
var iterables = arrCopy ( arguments ) ;
4941
4974
iterables [ 0 ] = this ;
4942
4975
return reify ( this , zipWithFactory ( this , zipper , iterables ) ) ;
4943
- } ,
4976
+ }
4944
4977
4945
4978
} ) ;
4946
4979
@@ -4966,7 +4999,7 @@ return /******/ (function(modules) { // webpackBootstrap
4966
4999
4967
5000
keySeq : function ( ) {
4968
5001
return this . valueSeq ( ) ;
4969
- } ,
5002
+ }
4970
5003
4971
5004
} ) ;
4972
5005
@@ -5070,7 +5103,7 @@ return /******/ (function(modules) { // webpackBootstrap
5070
5103
Repeat : Repeat ,
5071
5104
5072
5105
is : is ,
5073
- fromJS : fromJS ,
5106
+ fromJS : fromJS
5074
5107
5075
5108
} ;
5076
5109
0 commit comments