| @@ 12216-12262 (lines=47) @@ | ||
| 12213 | }; |
|
| 12214 | ||
| 12215 | // Add `LazyWrapper` methods to `lodash.prototype`. |
|
| 12216 | baseForOwn(LazyWrapper.prototype, function(func, methodName) { |
|
| 12217 | var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), |
|
| 12218 | retUnwrapped = /^(?:first|last)$/.test(methodName), |
|
| 12219 | lodashFunc = lodash[retUnwrapped ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName]; |
|
| 12220 | ||
| 12221 | if (!lodashFunc) { |
|
| 12222 | return; |
|
| 12223 | } |
|
| 12224 | lodash.prototype[methodName] = function() { |
|
| 12225 | var args = retUnwrapped ? [1] : arguments, |
|
| 12226 | chainAll = this.__chain__, |
|
| 12227 | value = this.__wrapped__, |
|
| 12228 | isHybrid = !!this.__actions__.length, |
|
| 12229 | isLazy = value instanceof LazyWrapper, |
|
| 12230 | iteratee = args[0], |
|
| 12231 | useLazy = isLazy || isArray(value); |
|
| 12232 | ||
| 12233 | if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { |
|
| 12234 | // Avoid lazy use if the iteratee has a "length" value other than `1`. |
|
| 12235 | isLazy = useLazy = false; |
|
| 12236 | } |
|
| 12237 | var interceptor = function(value) { |
|
| 12238 | return (retUnwrapped && chainAll) |
|
| 12239 | ? lodashFunc(value, 1)[0] |
|
| 12240 | : lodashFunc.apply(undefined, arrayPush([value], args)); |
|
| 12241 | }; |
|
| 12242 | ||
| 12243 | var action = { 'func': thru, 'args': [interceptor], 'thisArg': undefined }, |
|
| 12244 | onlyLazy = isLazy && !isHybrid; |
|
| 12245 | ||
| 12246 | if (retUnwrapped && !chainAll) { |
|
| 12247 | if (onlyLazy) { |
|
| 12248 | value = value.clone(); |
|
| 12249 | value.__actions__.push(action); |
|
| 12250 | return func.call(value); |
|
| 12251 | } |
|
| 12252 | return lodashFunc.call(undefined, this.value())[0]; |
|
| 12253 | } |
|
| 12254 | if (!retUnwrapped && useLazy) { |
|
| 12255 | value = onlyLazy ? value : new LazyWrapper(this); |
|
| 12256 | var result = func.apply(value, args); |
|
| 12257 | result.__actions__.push(action); |
|
| 12258 | return new LodashWrapper(result, chainAll); |
|
| 12259 | } |
|
| 12260 | return this.thru(interceptor); |
|
| 12261 | }; |
|
| 12262 | }); |
|
| 12263 | ||
| 12264 | // Add `Array` and `String` methods to `lodash.prototype`. |
|
| 12265 | arrayEach(['join', 'pop', 'push', 'replace', 'shift', 'sort', 'splice', 'split', 'unshift'], function(methodName) { |
|
| @@ 16953-16995 (lines=43) @@ | ||
| 16950 | }; |
|
| 16951 | ||
| 16952 | // Add `LazyWrapper` methods to `lodash.prototype`. |
|
| 16953 | baseForOwn(LazyWrapper.prototype, function(func, methodName) { |
|
| 16954 | var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), |
|
| 16955 | isTaker = /^(?:head|last)$/.test(methodName), |
|
| 16956 | lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], |
|
| 16957 | retUnwrapped = isTaker || /^find/.test(methodName); |
|
| 16958 | ||
| 16959 | if (!lodashFunc) { |
|
| 16960 | return; |
|
| 16961 | } |
|
| 16962 | lodash.prototype[methodName] = function() { |
|
| 16963 | var value = this.__wrapped__, |
|
| 16964 | args = isTaker ? [1] : arguments, |
|
| 16965 | isLazy = value instanceof LazyWrapper, |
|
| 16966 | iteratee = args[0], |
|
| 16967 | useLazy = isLazy || isArray(value); |
|
| 16968 | ||
| 16969 | var interceptor = function(value) { |
|
| 16970 | var result = lodashFunc.apply(lodash, arrayPush([value], args)); |
|
| 16971 | return (isTaker && chainAll) ? result[0] : result; |
|
| 16972 | }; |
|
| 16973 | ||
| 16974 | if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { |
|
| 16975 | // Avoid lazy use if the iteratee has a "length" value other than `1`. |
|
| 16976 | isLazy = useLazy = false; |
|
| 16977 | } |
|
| 16978 | var chainAll = this.__chain__, |
|
| 16979 | isHybrid = !!this.__actions__.length, |
|
| 16980 | isUnwrapped = retUnwrapped && !chainAll, |
|
| 16981 | onlyLazy = isLazy && !isHybrid; |
|
| 16982 | ||
| 16983 | if (!retUnwrapped && useLazy) { |
|
| 16984 | value = onlyLazy ? value : new LazyWrapper(this); |
|
| 16985 | var result = func.apply(value, args); |
|
| 16986 | result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); |
|
| 16987 | return new LodashWrapper(result, chainAll); |
|
| 16988 | } |
|
| 16989 | if (isUnwrapped && onlyLazy) { |
|
| 16990 | return func.apply(this, args); |
|
| 16991 | } |
|
| 16992 | result = this.thru(interceptor); |
|
| 16993 | return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; |
|
| 16994 | }; |
|
| 16995 | }); |
|
| 16996 | ||
| 16997 | // Add `Array` methods to `lodash.prototype`. |
|
| 16998 | arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { |
|
| @@ 543-585 (lines=43) @@ | ||
| 540 | }; |
|
| 541 | ||
| 542 | // Add `LazyWrapper` methods to `lodash.prototype`. |
|
| 543 | baseForOwn(LazyWrapper.prototype, function(func, methodName) { |
|
| 544 | var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), |
|
| 545 | isTaker = /^(?:head|last)$/.test(methodName), |
|
| 546 | lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], |
|
| 547 | retUnwrapped = isTaker || /^find/.test(methodName); |
|
| 548 | ||
| 549 | if (!lodashFunc) { |
|
| 550 | return; |
|
| 551 | } |
|
| 552 | lodash.prototype[methodName] = function() { |
|
| 553 | var value = this.__wrapped__, |
|
| 554 | args = isTaker ? [1] : arguments, |
|
| 555 | isLazy = value instanceof LazyWrapper, |
|
| 556 | iteratee = args[0], |
|
| 557 | useLazy = isLazy || isArray(value); |
|
| 558 | ||
| 559 | var interceptor = function(value) { |
|
| 560 | var result = lodashFunc.apply(lodash, arrayPush([value], args)); |
|
| 561 | return (isTaker && chainAll) ? result[0] : result; |
|
| 562 | }; |
|
| 563 | ||
| 564 | if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { |
|
| 565 | // Avoid lazy use if the iteratee has a "length" value other than `1`. |
|
| 566 | isLazy = useLazy = false; |
|
| 567 | } |
|
| 568 | var chainAll = this.__chain__, |
|
| 569 | isHybrid = !!this.__actions__.length, |
|
| 570 | isUnwrapped = retUnwrapped && !chainAll, |
|
| 571 | onlyLazy = isLazy && !isHybrid; |
|
| 572 | ||
| 573 | if (!retUnwrapped && useLazy) { |
|
| 574 | value = onlyLazy ? value : new LazyWrapper(this); |
|
| 575 | var result = func.apply(value, args); |
|
| 576 | result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); |
|
| 577 | return new LodashWrapper(result, chainAll); |
|
| 578 | } |
|
| 579 | if (isUnwrapped && onlyLazy) { |
|
| 580 | return func.apply(this, args); |
|
| 581 | } |
|
| 582 | result = this.thru(interceptor); |
|
| 583 | return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; |
|
| 584 | }; |
|
| 585 | }); |
|
| 586 | ||
| 587 | // Add `Array` methods to `lodash.prototype`. |
|
| 588 | arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { |
|