1 var baseWrapperValue = require('./baseWrapperValue'),
2 getView = require('./getView'),
3 isArray = require('../lang/isArray');
5 /** Used to indicate the type of lazy iteratees. */
6 var LAZY_DROP_WHILE_FLAG = 0,
10 /* Native method references for those with the same name as other `lodash` methods. */
11 var nativeMin = Math.min;
14 * Extracts the unwrapped value from its lazy wrapper.
18 * @memberOf LazyWrapper
19 * @returns {*} Returns the unwrapped value.
21 function lazyValue() {
22 var array = this.__wrapped__.value();
23 if (!isArray(array)) {
24 return baseWrapperValue(array, this.__actions__);
26 var dir = this.__dir__,
28 view = getView(0, array.length, this.__views__),
32 index = isRight ? end : (start - 1),
33 takeCount = nativeMin(length, this.__takeCount__),
34 iteratees = this.__iteratees__,
35 iterLength = iteratees ? iteratees.length : 0,
40 while (length-- && resIndex < takeCount) {
46 while (++iterIndex < iterLength) {
47 var data = iteratees[iterIndex],
48 iteratee = data.iteratee,
51 if (type == LAZY_DROP_WHILE_FLAG) {
52 if (data.done && (isRight ? (index > data.index) : (index < data.index))) {
58 var limit = data.limit;
59 if (!(data.done = limit > -1 ? (data.count++ >= limit) : !iteratee(value))) {
64 var computed = iteratee(value);
65 if (type == LAZY_MAP_FLAG) {
67 } else if (!computed) {
68 if (type == LAZY_FILTER_FLAG) {
76 result[resIndex++] = value;
81 module.exports = lazyValue;