10000 Bump to v3.1.0. · lodash/lodash@9e749da · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e749da

Browse files
committed
Bump to v3.1.0.
1 parent bbec03c commit 9e749da

21 files changed

+127
-66
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lodash v3.0.1
1+
# lodash v3.1.0
22

33
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) modules.
44

@@ -28,7 +28,7 @@ var array = require('lodash/array');
2828
var chunk = require('lodash/array/chunk');
2929
```
3030

31-
See the [package source](https://github.com/lodash/lodash/tree/3.0.1-npm) for more details.
31+
See the [package source](https://github.com/lodash/lodash/tree/3.1.0-npm) for more details.
3232

3333
**Note:**<br>
3434
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
@@ -39,8 +39,8 @@ Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash b
3939
lodash is also available in a variety of other builds & module formats.
4040

4141
* npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds
42-
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.0.1-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.0.1-amd) builds
43-
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.0.1-es) build
42+
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.1.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.1.0-amd) builds
43+
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.1.0-es) build
4444

4545
## Further Reading
4646

@@ -97,7 +97,7 @@ lodash is also available in a variety of other builds & module formats.
9797
* [_.bind](https://lodash.com/docs#bind), [_.curry](https://lodash.com/docs#curry), [_.partial](https://lodash.com/docs#partial), &
9898
[more](https://lodash.com/docs "_.bindKey, _.curryRight, _.partialRight") support customizable argument placeholders
9999
* [_.capitalize](https://lodash.com/docs#capitalize), [_.trim](https://lodash.com/docs#trim), &
100-
[more](https://lodash.com/docs "_.camelCase, _.deburr, _.endsWith, _.escapeRegExp, _.kebabCase, _.pad, _.padLeft, _.padRight, _.repeat, _.snakeCase, _.startsWith, _.trimLeft, _.trimRight, _.trunc, _.words") string methods
100+
[more](https://lodash.com/docs "_.camelCase, _.deburr, _.endsWith, _.escapeRegExp, _.kebabCase, _.pad, _.padLeft, _.padRight, _.repeat, _.snakeCase, _.startCase, _.startsWith, _.trimLeft, _.trimRight, _.trunc, _.words") string methods
101101
* [_.clone](https://lodash.com/docs#clone), [_.isEqual](https://lodash.com/docs#isEqual), &
102102
[more](https://lodash.com/docs "_.assign, _.cloneDeep, _.merge") accept callbacks
103103
* [_.dropWhile](https://lodash.com/docs#dropWhile), [_.takeWhile](https://lodash.com/docs#takeWhile), &
@@ -109,6 +109,6 @@ lodash is also available in a variety of other builds & module formats.
109109

110110
## Support
111111

112-
Tested in Chrome 39-40, Firefox 34-35, IE 6-11, Opera 25-26, Safari 5-8, io.js 1.0.4, Node.js 0.8.28 & 0.10.35, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7RC5.
112+
Tested in Chrome 39-40, Firefox 34-35, IE 6-11, Opera 26-27, Safari 5-8, io.js 1.0.4, Node.js 0.8.28 & 0.10.35, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7RC5.
113113

114114
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing.

chain/lodash.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ var hasOwnProperty = objectProto.hasOwnProperty;
5757
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
5858
* `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
5959
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
60-
* `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`,
60+
* `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
6161
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
6262
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
6363
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
6464
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
6565
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
66-
* `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`,
67-
* `unescape`, `uniqueId`, `value`, and `words`
66+
* `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`,
67+
* `trunc`, `unescape`, `uniqueId`, `value`, and `words`
6868
*
6969
* The wrapper function `sample` will return a wrapped value when `n` is provided,
7070
* otherwise an unwrapped value is returned.

collection/findWhere.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var find = require('./find'),
2-
matches = require('../utility/matches');
1+
var baseMatches = require('../internal/baseMatches'),
2+
find = require('./find');
33

44
/**
55
* Performs a deep comparison between each element in `collection` and the
@@ -26,7 +26,7 @@ var find = require('./find'),
2626
* // => 'fred'
2727
*/
2828
function findWhere(collection, source) {
29-
return find(collection, matches(source));
29+
return find(collection, baseMatches(source));
3030
}
3131

3232
module.exports = findWhere;

collection/pluck.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var map = require('./map'),
2-
property = require('../utility/property');
1+
var baseProperty = require('../internal/baseProperty'),
2+
map = require('./map');
33

44
/**
55
* Gets the value of `key` from all elements in `collection`.
@@ -25,7 +25,7 @@ var map = require('./map'),
2525
* // => [36, 40] (iteration order is not guaranteed)
2626
*/
2727
function pluck(collection, key) {
28-
return map(collection, property(key));
28+
return map(collection, baseProperty(key + ''));
2929
}
3030

3131
module.exports = pluck;

collection/where.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var filter = require('./filter'),
2-
matches = require('../utility/matches');
1+
var baseMatches = require('../internal/baseMatches'),
2+
filter = require('./filter');
33

44
/**
55
* Performs a deep comparison between each element in `collection` and the
@@ -29,7 +29,7 @@ var filter = require('./filter'),
2929
* // => ['barney', 'fred']
3030
*/
3131
function where(collection, source) {
32-
return filter(collection, matches(source));
32+
return filter(collection, baseMatches(source));
3333
}
3434

3535
module.exports = where;

index.js

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* lodash 3.0.1 (Custom Build) <https://lodash.com/>
3+
* lodash 3.1.0 (Custom Build) <https://lodash.com/>
44
* Build: `lodash modern -d -o ./index.js`
55
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
66
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
@@ -13,7 +13,7 @@
1313
var undefined;
1414

1515
/** Used as the semantic version number. */
16-
var VERSION = '3.0.1';
16+
var VERSION = '3.1.0';
1717

1818
/** Used to compose bitmasks for wrapper metadata. */
1919
var BIND_FLAG = 1,
@@ -769,7 +769,7 @@
769769

770770
/**
771771
* 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)
773773
* for more details.
774774
*/
775775
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
@@ -827,14 +827,14 @@
827827
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
828828
* `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
829829
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
830-
* `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`,
830+
* `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
831831
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
832832
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
833833
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
834834
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
835835
* `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`
838838
*
839839
* The wrapper function `sample` will return a wrapped value when `n` is provided,
840840
* otherwise an unwrapped value is returned.
@@ -1647,7 +1647,7 @@
16471647
}
16481648
// Handle "_.property" and "_.matches" style callback shorthands.
16491649
return type == 'object'
1650-
? baseMatches(func, !argCount)
1650+
? baseMatches(func)
16511651
: baseProperty(func + '');
16521652
}
16531653

@@ -2268,10 +2268,9 @@
22682268
*
22692269
* @private
22702270
* @param {Object} source The object of property values to match.
2271-
* @param {boolean} [isCloned] Specify cloning the source object.
22722271
* @returns {Function} Returns the new function.
22732272
*/
2274-
function baseMatches(source, isCloned) {
2273+
function baseMatches(source) {
22752274
var props = keys(source),
22762275
length = props.length;
22772276

@@ -2285,9 +2284,6 @@
22852284
};
22862285
}
22872286
}
2288-
if (isCloned) {
2289-
source = baseClone(source, true);
2290-
}
22912287
var values = Array(length),
22922288
strictCompareFlags = Array(length);
22932289

@@ -3598,14 +3594,18 @@
35983594
var length = object.length,
35993595
prereq = isLength(length) && isIndex(index, length);
36003596
} else {
3601-
prereq = type == 'string' && index in value;
3597+
prereq = type == 'string' && index in object;
36023598
}
36033599
return prereq && object[index] === value;
36043600
}
36053601

36063602
/**
36073603
* Checks if `value` is a valid array-like length.
36083604
*
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+
*
36093609
* @private
36103610
* @param {*} value The value to check.
36113611
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
@@ -5676,7 +5676,7 @@
56765676
* // => 'fred'
56775677
*/
56785678
function findWhere(collection, source) {
5679-
return find(collection, matches(source));
5679+
return find(collection, baseMatches(source));
56805680
}
56815681

56825682
/**
@@ -6053,7 +6053,7 @@
60536053
* // => [36, 40] (iteration order is not guaranteed)
60546054
*/
60556055
function pluck(collection, key) {
6056-
return map(collection, property(key));
6056+
return map(collection, baseProperty(key + ''));
60576057
}
60586058

60596059
/**
@@ -6424,7 +6424,7 @@
64246424
* // => ['barney', 'fred']
64256425
*/
64266426
function where(collection, source) {
6427-
return filter(collection, matches(source));
6427+
return filter(collection, baseMatches(source));
64286428
}
64296429

64306430
/*------------------------------------------------------------------------*/
@@ -9069,7 +9069,7 @@
90699069
*/
90709070
var camelCase = createCompounder(function(result, word, index) {
90719071
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);
90739073
});
90749074

90759075
/**
@@ -9420,16 +9420,41 @@
94209420
* _.snakeCase('Foo Bar');
94219421
* // => 'foo_bar'
94229422
*
9423-
* _.snakeCase('--foo-bar');
9423+
* _.snakeCase('fooBar');
94249424
* // => 'foo_bar'
94259425
*
9426-
* _.snakeCase('fooBar');
9426+
* _.snakeCase('--foo-bar');
94279427
* // => 'foo_bar'
94289428
*/
94299429
var snakeCase = createCompounder(function(result, word, index) {
94309430
return result + (index ? '_' : '') + word.toLowerCase();
94319431
});
94329432

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+
94339458
/**
94349459
* Checks if `string` starts with the given target string.
94359460
*
@@ -9689,7 +9714,7 @@
96899714
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
96909715
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
96919716
}
9692-
chars = baseToString(chars);
9717+
chars = (chars + '');
96939718
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
96949719
}
96959720

@@ -9720,7 +9745,7 @@
97209745
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
97219746
return string.slice(trimmedLeftIndex(string))
97229747
}
9723-
return string.slice(charsLeftIndex(string, baseToString(chars)));
9748+
return string.slice(charsLeftIndex(string, (chars + '')));
97249749
}
97259750

97269751
/**
@@ -9750,7 +9775,7 @@
97509775
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
97519776
return string.slice(0, trimmedRightIndex(string) + 1)
97529777
}
9753-
return string.slice(0, charsRightIndex(string, baseToString(chars)) + 1);
9778+
return string.slice(0, charsRightIndex(string, (chars + '')) + 1);
97549779
}
97559780

97569781
/**
@@ -9957,7 +9982,9 @@
99579982
if (guard && isIterateeCall(func, thisArg, guard)) {
99589983
thisArg = null;
99599984
}
9960-
return baseCallback(func, thisArg);
9985+
return isObjectLike(func)
9986+
? matches(func)
9987+
: baseCallback(func, thisArg);
99619988
}
99629989

99639990
/**
@@ -10025,7 +10052,7 @@
1002510052
* // => { 'user': 'barney', 'age': 36 }
1002610053
*/
1002710054
function matches(source) {
10028-
return baseMatches(source, true);
10055+
return baseMatches(baseClone(source, true));
1002910056
}
1003010057

1003110058
/**
@@ -10522,6 +10549,7 @@
1052210549
lodash.some = some;
1052310550
lodash.sortedIndex = sortedIndex;
1052410551
lodash.sortedLastIndex = sortedLastIndex;
10552+
lodash.startCase = startCase;
1052510553
lodash.startsWith = startsWith;
1052610554
lodash.template = template;
1052710555
lodash.trim = trim;
@@ -10647,10 +10675,10 @@
1064710675
// Add `LazyWrapper` methods for `_.pluck` and `_.where`.
1064810676
arrayEach(['pluck', 'where'], function(methodName, index) {
1064910677
var operationName = index ? 'filter' : 'map',
10650-
createCallback = index ? matches : property;
10678+
createCallback = index ? baseMatches : baseProperty;
1065110679

1065210680
LazyWrapper.prototype[methodName] = function(value) {
10653-
return this[operationName](createCallback(value));
10681+
return this[operationName](createCallback(index ? value : (value + '')));
1065410682
};
1065510683
});
1065610684

internal/baseCallback.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function baseCallback(func, thisArg, argCount) {
2626
}
2727
// Handle "_.property" and "_.matches" style callback shorthands.
2828
return type == 'object'
29-
? baseMatches(func, !argCount)
29+
? baseMatches(func)
3030
: baseProperty(func + '');
3131
}
3232

internal/baseMatches.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var baseClone = require('./baseClone'),
2-
baseIsMatch = require('./baseIsMatch'),
1+
var baseIsMatch = require('./baseIsMatch'),
32
isStrictComparable = require('./isStrictComparable'),
43
keys = require('../object/keys');
54

@@ -15,10 +14,9 @@ var hasOwnProperty = objectProto.hasOwnProperty;
1514
*
1615
* @private
1716
* @param {Object} source The object of property values to match.
18-
* @param {boolean} [isCloned] Specify cloning the source object.
1917
* @returns {Function} Returns the new function.
2018
*/
21-
function baseMatches(source, isCloned) {
19+
function baseMatches(source) {
2220
var props = keys(source),
2321
length = props.length;
2422

@@ -32,9 +30,6 @@ function baseMatches(source, isCloned) {
3230
};
3331
}
3432
}
35-
if (isCloned) {
36-
source = baseClone(source, true);
37-
}
3833
var values = Array(length),
3934
strictCompareFlags = Array(length);
4035

0 commit comments

Comments
 (0)
0