Sha256: 84d51a53ea72e167bf00a4dfd7487d1af3c9907da9c81973d27a334d44730d40

Contents?: true

Size: 1.75 KB

Versions: 270

Compression:

Stored size: 1.75 KB

Contents

var baseWrapperValue = require('./_baseWrapperValue'),
    getView = require('./_getView'),
    isArray = require('./isArray');

/** Used to indicate the type of lazy iteratees. */
var LAZY_FILTER_FLAG = 1,
    LAZY_MAP_FLAG = 2;

/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;

/**
 * Extracts the unwrapped value from its lazy wrapper.
 *
 * @private
 * @name value
 * @memberOf LazyWrapper
 * @returns {*} Returns the unwrapped value.
 */
function lazyValue() {
  var array = this.__wrapped__.value(),
      dir = this.__dir__,
      isArr = isArray(array),
      isRight = dir < 0,
      arrLength = isArr ? array.length : 0,
      view = getView(0, arrLength, this.__views__),
      start = view.start,
      end = view.end,
      length = end - start,
      index = isRight ? end : (start - 1),
      iteratees = this.__iteratees__,
      iterLength = iteratees.length,
      resIndex = 0,
      takeCount = nativeMin(length, this.__takeCount__);

  if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
    return baseWrapperValue(array, this.__actions__);
  }
  var result = [];

  outer:
  while (length-- && resIndex < takeCount) {
    index += dir;

    var iterIndex = -1,
        value = array[index];

    while (++iterIndex < iterLength) {
      var data = iteratees[iterIndex],
          iteratee = data.iteratee,
          type = data.type,
          computed = iteratee(value);

      if (type == LAZY_MAP_FLAG) {
        value = computed;
      } else if (!computed) {
        if (type == LAZY_FILTER_FLAG) {
          continue outer;
        } else {
          break outer;
        }
      }
    }
    result[resIndex++] = value;
  }
  return result;
}

module.exports = lazyValue;

Version data entries

270 entries across 269 versions & 28 rubygems

Version Path
immosquare-cleaner-0.1.27 node_modules/lodash/_lazyValue.js
immosquare-cleaner-0.1.26 node_modules/lodash/_lazyValue.js
immosquare-cleaner-0.1.25 node_modules/lodash/_lazyValue.js
immosquare-cleaner-0.1.24 node_modules/lodash/_lazyValue.js
immosquare-cleaner-0.1.23 node_modules/lodash/_lazyValue.js
sumomo-0.10.4 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.10.3 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.10.2 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.10.1 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.10.0 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
reed_sdk-1.0.1 node_modules/lodash/_lazyValue.js
reed_sdk-1.0.0 node_modules/lodash/_lazyValue.js
boring_generators-0.12.0 tmp/templates/app_template/node_modules/lodash/_lazyValue.js
sumomo-0.9.0 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.8.22 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.8.21 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.8.20 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.8.17 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
sumomo-0.8.16 data/sumomo/api_modules/node_modules/lodash/_lazyValue.js
disco_app-0.18.0 test/dummy/node_modules/lodash/_lazyValue.js