@@ -1170,11 +1170,6 @@ var ToIndexedSequence = function ToIndexedSequence(iter) {
1170
1170
contains : function ( value ) {
1171
1171
return this . _iter . contains ( value ) ;
1172
1172
} ,
1173
- cacheResult : function ( ) {
1174
- this . _iter . cacheResult ( ) ;
1175
- this . size = this . _iter . size ;
1176
- return this ;
1177
- } ,
1178
1173
__iterate : function ( fn , reverse ) {
1179
1174
var $__0 = this ;
1180
1175
var iterations = 0 ;
@@ -1226,11 +1221,6 @@ var ToKeyedSequence = function ToKeyedSequence(indexed, useKeys) {
1226
1221
}
1227
1222
return mappedSequence ;
1228
1223
} ,
1229
- cacheResult : function ( ) {
1230
- this . _iter . cacheResult ( ) ;
1231
- this . size = this . _iter . size ;
1232
- return this ;
1233
- } ,
1234
1224
__iterate : function ( fn , reverse ) {
1235
1225
var $__0 = this ;
1236
1226
var ii ;
@@ -1260,11 +1250,6 @@ var ToSetSequence = function ToSetSequence(iter) {
1260
1250
has : function ( key ) {
1261
1251
return this . _iter . contains ( key ) ;
1262
1252
} ,
1263
- cacheResult : function ( ) {
1264
- this . _iter . cacheResult ( ) ;
1265
- this . size = this . _iter . size ;
1266
- return this ;
1267
- } ,
1268
1253
__iterate : function ( fn , reverse ) {
1269
1254
var $__0 = this ;
1270
1255
return this . _iter . __iterate ( ( function ( v ) {
@@ -1287,11 +1272,6 @@ var FromEntriesSequence = function FromEntriesSequence(entries) {
1287
1272
entrySeq : function ( ) {
1288
1273
return this . _iter . toSeq ( ) ;
1289
1274
} ,
1290
- cacheResult : function ( ) {
1291
- this . _iter . cacheResult ( ) ;
1292
- this . size = this . _iter . size ;
1293
- return this ;
1294
- } ,
1295
1275
__iterate : function ( fn , reverse ) {
1296
1276
var $__0 = this ;
1297
1277
return this . _iter . __iterate ( ( function ( entry ) {
@@ -1318,8 +1298,10 @@ var FromEntriesSequence = function FromEntriesSequence(entries) {
1318
1298
} ) ) ;
1319
1299
}
1320
1300
} , { } , LazyKeyedSequence ) ;
1301
+ ToIndexedSequence . prototype . cacheResult = ToKeyedSequence . prototype . cacheResult = ToSetSequence . prototype . cacheResult = FromEntriesSequence . prototype . cacheResult = cacheResultThrough ;
1321
1302
function flipFactory ( iterable ) {
1322
1303
var flipSequence = makeSequence ( iterable ) ;
1304
+ flipSequence . _iter = iterable ;
1323
1305
flipSequence . size = iterable . size ;
1324
1306
flipSequence . flip = ( function ( ) {
1325
1307
return iterable ;
@@ -1337,6 +1319,7 @@ function flipFactory(iterable) {
1337
1319
flipSequence . contains = ( function ( key ) {
1338
1320
return iterable . has ( key ) ;
1339
1321
} ) ;
1322
+ flipSequence . cacheResult = cacheResultThrough ;
1340
1323
flipSequence . __iterateUncached = function ( fn , reverse ) {
1341
1324
var $__0 = this ;
1342
1325
return iterable . __iterate ( ( function ( v , k ) {
@@ -1392,6 +1375,7 @@ function mapFactory(iterable, mapper, context) {
1392
1375
}
1393
1376
function reverseFactory ( iterable , useKeys ) {
1394
1377
var reversedSequence = makeSequence ( iterable ) ;
1378
+ reversedSequence . _iter = iterable ;
1395
1379
reversedSequence . size = iterable . size ;
1396
1380
reversedSequence . reverse = ( function ( ) {
1397
1381
return iterable ;
@@ -1414,11 +1398,7 @@ function reverseFactory(iterable, useKeys) {
1414
1398
reversedSequence . contains = ( function ( value ) {
1415
1399
return iterable . contains ( value ) ;
1416
1400
} ) ;
1417
- reversedSequence . cacheResult = function ( ) {
1418
- iterable . cacheResult ( ) ;
1419
- this . size = iterable . size ;
1420
- return this ;
1421
- } ;
1401
+ reversedSequence . cacheResult = cacheResultThrough ;
1422
1402
reversedSequence . __iterate = function ( fn , reverse ) {
1423
1403
var $__0 = this ;
1424
1404
return iterable . __iterate ( ( function ( v , k ) {
@@ -1779,6 +1759,15 @@ function resolveSize(iter) {
1779
1759
function makeSequence ( iterable ) {
1780
1760
return Object . create ( ( isKeyed ( iterable ) ? LazyKeyedSequence : isIndexed ( iterable ) ? LazyIndexedSequence : LazySetSequence ) . prototype ) ;
1781
1761
}
1762
+ function cacheResultThrough ( ) {
1763
+ if ( this . _iter . cacheResult ) {
1764
+ this . _iter . cacheResult ( ) ;
1765
+ this . size = this . _iter . size ;
1766
+ return this ;
1767
+ } else {
1768
+ return LazySequence . prototype . cacheResult . call ( this ) ;
1769
+ }
1770
+ }
1782
1771
var Collection = function Collection ( ) {
1783
1772
throw TypeError ( 'Abstract' ) ;
1784
1773
} ;
0 commit comments