1 var baseWrapperValue = require('./_baseWrapperValue'),
2 getView = require('./_getView'),
3 isArray = require('./isArray');
5 /** Used as the size to enable large array optimizations. */
6 var LARGE_ARRAY_SIZE = 200;
8 /** Used to indicate the type of lazy iteratees. */
9 var LAZY_FILTER_FLAG = 1,
12 /* Built-in method references for those with the same name as other `lodash` methods. */
13 var nativeMin = Math.min;
16 * Extracts the unwrapped value from its lazy wrapper.
20 * @memberOf LazyWrapper
21 * @returns {*} Returns the unwrapped value.
23 function lazyValue() {
24 var array = this.__wrapped__.value(),
26 isArr = isArray(array),
28 arrLength = isArr ? array.length : 0,
29 view = getView(0, arrLength, this.__views__),
33 index = isRight ? end : (start - 1),
34 iteratees = this.__iteratees__,
35 iterLength = iteratees.length,
37 takeCount = nativeMin(length, this.__takeCount__);
39 if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
40 return baseWrapperValue(array, this.__actions__);
45 while (length-- && resIndex < takeCount) {
51 while (++iterIndex < iterLength) {
52 var data = iteratees[iterIndex],
53 iteratee = data.iteratee,
55 computed = iteratee(value);
57 if (type == LAZY_MAP_FLAG) {
59 } else if (!computed) {
60 if (type == LAZY_FILTER_FLAG) {
67 result[resIndex++] = value;
72 module.exports = lazyValue;