MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / lazyValue

Function lazyValue

lib/web/jshint.js:2637–2695  ·  view source on GitHub ↗

* Extracts the unwrapped value from its lazy wrapper. * * @private * @name value * @memberOf LazyWrapper * @returns {*} Returns the unwrapped value.

()

Source from the content-addressed store, hash-verified

2635 * @returns {*} Returns the unwrapped value.
2636 */
2637 function lazyValue() {
2638 var array = this.__wrapped__.value();
2639 if (!isArray(array)) {
2640 return baseWrapperValue(array, this.__actions__);
2641 }
2642 var dir = this.__dir__,
2643 isRight = dir < 0,
2644 view = getView(0, array.length, this.__views__),
2645 start = view.start,
2646 end = view.end,
2647 length = end - start,
2648 index = isRight ? end : (start - 1),
2649 takeCount = nativeMin(length, this.__takeCount__),
2650 iteratees = this.__iteratees__,
2651 iterLength = iteratees ? iteratees.length : 0,
2652 resIndex = 0,
2653 result = [];
2654
2655 outer:
2656 while (length-- && resIndex < takeCount) {
2657 index += dir;
2658
2659 var iterIndex = -1,
2660 value = array[index];
2661
2662 while (++iterIndex < iterLength) {
2663 var data = iteratees[iterIndex],
2664 iteratee = data.iteratee,
2665 type = data.type;
2666
2667 if (type == LAZY_DROP_WHILE_FLAG) {
2668 if (data.done && (isRight ? (index > data.index) : (index < data.index))) {
2669 data.count = 0;
2670 data.done = false;
2671 }
2672 data.index = index;
2673 if (!data.done) {
2674 var limit = data.limit;
2675 if (!(data.done = limit > -1 ? (data.count++ >= limit) : !iteratee(value))) {
2676 continue outer;
2677 }
2678 }
2679 } else {
2680 var computed = iteratee(value);
2681 if (type == LAZY_MAP_FLAG) {
2682 value = computed;
2683 } else if (!computed) {
2684 if (type == LAZY_FILTER_FLAG) {
2685 continue outer;
2686 } else {
2687 break outer;
2688 }
2689 }
2690 }
2691 }
2692 result[resIndex++] = value;
2693 }
2694 return result;

Callers

nothing calls this directly

Calls 3

baseWrapperValueFunction · 0.85
getViewFunction · 0.85
isArrayFunction · 0.70

Tested by

no test coverage detected