(collection)
| 206 | cacheResultThrough; |
| 207 | |
| 208 | export function flipFactory(collection) { |
| 209 | const flipSequence = makeSequence(collection); |
| 210 | flipSequence._iter = collection; |
| 211 | flipSequence.size = collection.size; |
| 212 | flipSequence.flip = () => collection; |
| 213 | flipSequence.reverse = function () { |
| 214 | const reversedSequence = collection.reverse.apply(this); // super.reverse() |
| 215 | reversedSequence.flip = () => collection.reverse(); |
| 216 | return reversedSequence; |
| 217 | }; |
| 218 | flipSequence.has = (key) => collection.includes(key); |
| 219 | flipSequence.includes = (key) => collection.has(key); |
| 220 | flipSequence.cacheResult = cacheResultThrough; |
| 221 | flipSequence.__iterateUncached = function (fn, reverse) { |
| 222 | return collection.__iterate((v, k) => fn(k, v, this) !== false, reverse); |
| 223 | }; |
| 224 | flipSequence.__iteratorUncached = function (type, reverse) { |
| 225 | if (type === ITERATE_ENTRIES) { |
| 226 | const iterator = collection.__iterator(type, reverse); |
| 227 | return new Iterator(() => { |
| 228 | const step = iterator.next(); |
| 229 | if (!step.done) { |
| 230 | const k = step.value[0]; |
| 231 | step.value[0] = step.value[1]; |
| 232 | step.value[1] = k; |
| 233 | } |
| 234 | return step; |
| 235 | }); |
| 236 | } |
| 237 | return collection.__iterator( |
| 238 | type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, |
| 239 | reverse |
| 240 | ); |
| 241 | }; |
| 242 | return flipSequence; |
| 243 | } |
| 244 | |
| 245 | export function mapFactory(collection, mapper, context) { |
| 246 | const mappedSequence = makeSequence(collection); |
no test coverage detected