|
1 | 1 | /**
|
2 | 2 | * @license
|
3 |
| - * lodash 3.0.1 (Custom Build) <https://lodash.com/> |
| 3 | + * lodash 3.1.0 (Custom Build) <https://lodash.com/> |
4 | 4 | * Build: `lodash modern -d -o ./index.js`
|
5 | 5 | * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
6 | 6 | * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
|
|
13 | 13 | var undefined;
|
14 | 14 |
|
15 | 15 | /** Used as the semantic version number. */
|
16 |
| - var VERSION = '3.0.1'; |
| 16 | + var VERSION = '3.1.0'; |
17 | 17 |
|
18 | 18 | /** Used to compose bitmasks for wrapper metadata. */
|
19 | 19 | var BIND_FLAG = 1,
|
|
769 | 769 |
|
770 | 770 | /**
|
771 | 771 | * Used as the maximum length of an array-like value.
|
772 |
| - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength) |
| 772 | + * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) |
773 | 773 | * for more details.
|
774 | 774 | */
|
775 | 775 | var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
|
827 | 827 | * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
|
828 | 828 | * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
|
829 | 829 | * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
|
830 |
| - * `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`, |
| 830 | + * `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, |
831 | 831 | * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
832 | 832 | * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
|
833 | 833 | * `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
|
834 | 834 | * `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
|
835 | 835 | * `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
|
836 |
| - * `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, |
837 |
| - * `unescape`, `uniqueId`, `value`, and `words` |
| 836 | + * `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, |
| 837 | + * `trunc`, `unescape`, `uniqueId`, `value`, and `words` |
838 | 838 | *
|
839 | 839 | * The wrapper function `sample` will return a wrapped value when `n` is provided,
|
840 | 840 | * otherwise an unwrapped value is returned.
|
|
1647 | 1647 | }
|
1648 | 1648 | // Handle "_.property" and "_.matches" style callback shorthands.
|
1649 | 1649 | return type == 'object'
|
1650 |
| - ? baseMatches(func, !argCount) |
| 1650 | + ? baseMatches(func) |
1651 | 1651 | : baseProperty(func + '');
|
1652 | 1652 | }
|
1653 | 1653 |
|
|
2268 | 2268 | *
|
2269 | 2269 | * @private
|
2270 | 2270 | * @param {Object} source The object of property values to match.
|
2271 |
| - * @param {boolean} [isCloned] Specify cloning the source object. |
2272 | 2271 | * @returns {Function} Returns the new function.
|
2273 | 2272 | */
|
2274 |
| - function baseMatches(source, isCloned) { |
| 2273 | + function baseMatches(source) { |
2275 | 2274 | var props = keys(source),
|
2276 | 2275 | length = props.length;
|
2277 | 2276 |
|
|
2285 | 2284 | };
|
2286 | 2285 | }
|
2287 | 2286 | }
|
2288 |
| - if (isCloned) { |
2289 |
| - source = baseClone(source, true); |
2290 |
| - } |
2291 | 2287 | var values = Array(length),
|
2292 | 2288 | strictCompareFlags = Array(length);
|
2293 | 2289 |
|
|
3598 | 3594 | var length = object.length,
|
3599 | 3595 | prereq = isLength(length) && isIndex(index, length);
|
3600 | 3596 | } else {
|
3601 |
| - prereq = type == 'string' && index in value; |
| 3597 | + prereq = type == 'string' && index in object; |
3602 | 3598 | }
|
3603 | 3599 | return prereq && object[index] === value;
|
3604 | 3600 | }
|
3605 | 3601 |
|
3606 | 3602 | /**
|
3607 | 3603 | * Checks if `value` is a valid array-like length.
|
3608 | 3604 | *
|
| 3605 | + * **Note:** This function is based on ES `ToLength`. See the |
| 3606 | + * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength) |
| 3607 | + * for more details. |
| 3608 | + * |
3609 | 3609 | * @private
|
3610 | 3610 | * @param {*} value The value to check.
|
3611 | 3611 | * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
5676 | 5676 | * // => 'fred'
|
5677 | 5677 | */
|
5678 | 5678 | function findWhere(collection, source) {
|
5679 |
| - return find(collection, matches(source)); |
| 5679 | + return find(collection, baseMatches(source)); |
5680 | 5680 | }
|
5681 | 5681 |
|
5682 | 5682 | /**
|
|
6053 | 6053 | * // => [36, 40] (iteration order is not guaranteed)
|
6054 | 6054 | */
|
6055 | 6055 | function pluck(collection, key) {
|
6056 |
| - return map(collection, property(key)); |
| 6056 | + return map(collection, baseProperty(key + '')); |
6057 | 6057 | }
|
6058 | 6058 |
|
6059 | 6059 | /**
|
|
6424 | 6424 | * // => ['barney', 'fred']
|
6425 | 6425 | */
|
6426 | 6426 | function where(collection, source) {
|
6427 |
| - return filter(collection, matches(source)); |
| 6427 | + return filter(collection, baseMatches(source)); |
6428 | 6428 | }
|
6429 | 6429 |
|
6430 | 6430 | /*------------------------------------------------------------------------*/
|
|
9069 | 9069 | */
|
9070 | 9070 | var camelCase = createCompounder(function(result, word, index) {
|
9071 | 9071 | word = word.toLowerCase();
|
9072 |
| - return index ? (result + word.charAt(0).toUpperCase() + word.slice(1)) : word; |
| 9072 | + return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word); |
9073 | 9073 | });
|
9074 | 9074 |
|
9075 | 9075 | /**
|
|
9420 | 9420 | * _.snakeCase('Foo Bar');
|
9421 | 9421 | * // => 'foo_bar'
|
9422 | 9422 | *
|
9423 |
| - * _.snakeCase('--foo-bar'); |
| 9423 | + * _.snakeCase('fooBar'); |
9424 | 9424 | * // => 'foo_bar'
|
9425 | 9425 | *
|
9426 |
| - * _.snakeCase('fooBar'); |
| 9426 | + * _.snakeCase('--foo-bar'); |
9427 | 9427 | * // => 'foo_bar'
|
9428 | 9428 | */
|
9429 | 9429 | var snakeCase = createCompounder(function(result, word, index) {
|
9430 | 9430 | return result + (index ? '_' : '') + word.toLowerCase();
|
9431 | 9431 | });
|
9432 | 9432 |
|
| 9433 | + /** |
| 9434 | + * Converts `string` to start case. |
| 9435 | + * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage) |
| 9436 | + * for more details. |
| 9437 | + * |
| 9438 | + * @static |
| 9439 | + * @memberOf _ |
| 9440 | + * @category String |
| 9441 | + * @param {string} [string=''] The string to convert. |
| 9442 | + * @returns {string} Returns the start cased string. |
| 9443 | + * @example |
| 9444 | + * |
| 9445 | + * _.startCase('--foo-bar'); |
| 9446 | + * // => 'Foo Bar' |
| 9447 | + * |
| 9448 | + * _.startCase('fooBar'); |
| 9449 | + * // => 'Foo Bar' |
| 9450 | + * |
| 9451 | + * _.startCase('__foo_bar__'); |
| 9452 | + * // => 'Foo Bar' |
| 9453 | + */ |
| 9454 | + var startCase = createCompounder(function(result, word, index) { |
| 9455 | + return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1)); |
| 9456 | + }); |
| 9457 | + |
9433 | 9458 | /**
|
9434 | 9459 | * Checks if `string` starts with the given target string.
|
9435 | 9460 | *
|
|
9689 | 9714 | if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
9690 | 9715 | return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
|
9691 | 9716 | }
|
9692 |
| - chars = baseToString(chars); |
| 9717 | + chars = (chars + ''); |
9693 | 9718 | return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
|
9694 | 9719 | }
|
9695 | 9720 |
|
|
9720 | 9745 | if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
9721 | 9746 | return string.slice(trimmedLeftIndex(string))
|
9722 | 9747 | }
|
9723 |
| - return string.slice(charsLeftIndex(string, baseToString(chars))); |
| 9748 | + return string.slice(charsLeftIndex(string, (chars + ''))); |
9724 | 9749 | }
|
9725 | 9750 |
|
9726 | 9751 | /**
|
|
9750 | 9775 | if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
9751 | 9776 | return string.slice(0, trimmedRightIndex(string) + 1)
|
9752 | 9777 | }
|
9753 |
| - return string.slice(0, charsRightIndex(string, baseToString(chars)) + 1); |
| 9778 | + return string.slice(0, charsRightIndex(string, (chars + '')) + 1); |
9754 | 9779 | }
|
9755 | 9780 |
|
9756 | 9781 | /**
|
|
9957 | 9982 | if (guard && isIterateeCall(func, thisArg, guard)) {
|
9958 | 9983 | thisArg = null;
|
9959 | 9984 | }
|
9960 |
| - return baseCallback(func, thisArg); |
| 9985 | + return isObjectLike(func) |
| 9986 | + ? matches(func) |
| 9987 | + : baseCallback(func, thisArg); |
9961 | 9988 | }
|
9962 | 9989 |
|
9963 | 9990 | /**
|
|
10025 | 10052 | * // => { 'user': 'barney', 'age': 36 }
|
10026 | 10053 | */
|
10027 | 10054 | function matches(source) {
|
10028 |
| - return baseMatches(source, true); |
| 10055 | + return baseMatches(baseClone(source, true)); |
10029 | 10056 | }
|
10030 | 10057 |
|
10031 | 10058 | /**
|
|
10522 | 10549 | lodash.some = some;
|
10523 | 10550 | lodash.sortedIndex = sortedIndex;
|
10524 | 10551 | lodash.sortedLastIndex = sortedLastIndex;
|
| 10552 | + lodash.startCase = startCase; |
10525 | 10553 | lodash.startsWith = startsWith;
|
10526 | 10554 | lodash.template = template;
|
10527 | 10555 | lodash.trim = trim;
|
@@ -10647,10 +10675,10 @@
|
10647 | 10675 | // Add `LazyWrapper` methods for `_.pluck` and `_.where`.
|
10648 | 10676 | arrayEach(['pluck', 'where'], function(methodName, index) {
|
10649 | 10677 | var operationName = index ? 'filter' : 'map',
|
10650 |
| - createCallback = index ? matches : property; |
| 10678 | + createCallback = index ? baseMatches : baseProperty; |
10651 | 10679 |
|
10652 | 10680 | LazyWrapper.prototype[methodName] = function(value) {
|
10653 |
| - return this[operationName](createCallback(value)); |
| 10681 | + return this[operationName](createCallback(index ? value : (value + ''))); |
10654 | 10682 | };
|
10655 | 10683 | });
|
10656 | 10684 |
|
|
0 commit comments