8000 Bump to v3.3.0. · lodash/lodash@5dc85cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 5dc85cc

Browse files
committed
Bump to v3.3.0.
1 parent 05cb741 commit 5dc85cc

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lodash v3.2.0
1+
# lodash v3.3.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

@@ -24,11 +24,11 @@ In Node.js/io.js:
2424
var _ = require('lodash');
2525
// or a method category
2626
var array = require('lodash/array');
27-
// or a me F987 thod
27+
// or a method (works great with browserify/webpack to create smaller builds)
2828
var chunk = require('lodash/array/chunk');
2929
```
3030

31-
See the [package source](https://github.com/lodash/lodash/tree/3.2.0-npm) for more details.
31+
See the [package source](https://github.com/lodash/lodash/tree/3.3.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.2.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.2.0-amd) builds
43-
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.2.0-es) build
42+
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.3.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.3.0-amd) builds
43+
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.3.0-es) build
4444

4545
## Further Reading
4646

@@ -69,23 +69,20 @@ lodash is also available in a variety of other builds & module formats.
6969
* [_.curry](https://lodash.com/docs#curry) & [_.curryRight](https://lodash.com/docs#curryRight) for creating [curried](http://hughfdjackson.com/javascript/why-curry-helps/) functions
7070
* [_.debounce](https://lodash.com/docs#debounce) & [_.throttle](https://lodash.com/docs#throttle) are cancelable & accept options for more control
7171
* [_.fill](https://lodash.com/docs#fill) to fill arrays with values
72-
* [_.findIndex](https://lodash.com/docs#findIndex) & [_.findKey](https://lodash.com/docs#findKey) for finding indexes & keys
72+
* [_.findKey](https://lodash.com/docs#findKey) for finding keys
7373
* [_.flow](https://lodash.com/docs#flow) to complement [_.flowRight](https://lodash.com/docs#flowRight) (a.k.a `_.compose`)
7474
* [_.forEach](https://lodash.com/docs#forEach) supports exiting early
7575
* [_.forIn](https://lodash.com/docs#forIn) for iterating all enumerable properties
7676
* [_.forOwn](https://lodash.com/docs#forOwn) for iterating own properties
7777
* [_.includes](https://lodash.com/docs#includes) accepts a `fromIndex`
78-
* [_.isError](https://lodash.com/docs#isError) to check for error objects
78+
* [_.inRange](https://lodash.com/docs#inRange) for checking whether a number is within a given range
7979
* [_.isNative](https://lodash.com/docs#isNative) to check for native functions
8080
* [_.isPlainObject](https://lodash.com/docs#isPlainObject) & [_.toPlainObject](https://lodash.com/docs#toPlainObject) to check for & convert to `Object` objects
8181
* [_.isTypedArray](https://lodash.com/docs#isTypedArray) to check for typed arrays
82-
* [_.keysIn](https://lodash.com/docs#keysIn) & [_.valuesIn](https://lodash.com/docs#valuesIn) for getting keys & values of all enumerable properties
83-
* [_.mapValues](https://lodash.com/docs#mapValues) for [mapping](https://lodash.com/docs#map) values to an object
8482
* [_.matches](https://lodash.com/docs#matches) supports deep object comparisons
8583
* [_.matchesProperty](https://lodash.com/docs#matchesProperty) to complement [_.matches](https://lodash.com/docs#matches) & [_.property](https://lodash.com/docs#property)
8684
* [_.merge](https://lodash.com/docs#merge) for a deep [_.extend](https://lodash.com/docs#extend)
8785
* [_.parseInt](https://lodash.com/docs#parseInt) for consistent cross-environment behavior
88-
* [_.propertyOf](https://lodash.com/docs#propertyOf) to complement [_.property](https://lodash.com/docs#property)
8986
* [_.pull](https://lodash.com/docs#pull), [_.pullAt](https://lodash.com/docs#pullAt), & [_.remove](https://lodash.com/docs#remove) for mutating arrays
9087
* [_.random](https://lodash.com/docs#random) supports returning floating-point numbers
9188
* [_.runInContext](https://lodash.com/docs#runInContext) for collisionless mixins & easier mocking
@@ -96,6 +93,7 @@ lodash is also available in a variety of other builds & module formats.
9693
* [_.template](https://lodash.com/docs#template) supports [*“imports”*](https://lodash.com/docs#templateSettings-imports) options & [ES template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components)
9794
* [_.transform](https://lodash.com/docs#transform) as a powerful alternative to [_.reduce](https://lodash.com/docs#reduce) for transforming objects
9895
* [_.xor](https://lodash.com/docs#xor) to complement [_.difference](https://lodash.com/docs#difference), [_.intersection](https://lodash.com/docs#intersection), & [_.union](https://lodash.com/docs#union)
96+
* [_.valuesIn](https://lodash.com/docs#valuesIn) for getting values of all enumerable properties
9997
* [_.bind](https://lodash.com/docs#bind), [_.curry](https://lodash.com/docs#curry), [_.partial](https://lodash.com/docs#partial), &
10098
[more](https://lodash.com/docs "_.bindKey, _.curryRight, _.partialRight") support customizable argument placeholders
10199
* [_.capitalize](https://lodash.com/docs#capitalize), [_.trim](https://lodash.com/docs#trim), &
@@ -104,8 +102,8 @@ lodash is also available in a variety of other builds & module formats.
104102
[more](https://lodash.com/docs "_.assign, _.cloneDeep, _.merge") accept callbacks
105103
* [_.dropWhile](https://lodash.com/docs#dropWhile), [_.takeWhile](https://lodash.com/docs#takeWhile), &
106104
[more](https://lodash.com/docs "_.drop, _.dropRightWhile, _.take, _.takeRightWhile") to complement [_.first](https://lodash.com/docs#first), [_.initial](https://lodash.com/docs#initial), [_.last](https://lodash.com/docs#last), & [_.rest](https://lodash.com/docs#rest)
107-
* [_.findLast](https://lodash.com/docs#findLast), [_.findLastIndex](https://lodash.com/docs#findLastIndex), &
108-
[more](https://lodash.com/docs "_.findLastKey, _.flowRight, _.forEachRight, _.forInRight, _.forOwnRight, _.partialRight") right-associative methods
105+
* [_.findLast](https://lodash.com/docs#findLast), [_.findLastKey](https://lodash.com/docs#findLastKey), &
106+
[more](https://lodash.com/docs "_.flowRight, _.forEachRight, _.forInRight, _.forOwnRight, _.partialRight") right-associative methods
109107
* [_.includes](https://lodash.com/docs#includes), [_.toArray](https://lodash.com/docs#toArray), &
110108
[more](https://lodash.com/docs "_.at, _.countBy, _.every, _.filter, _.find, _.findLast, _.forEach, _.forEachRight, _.groupBy, _.indexBy, _.invoke, _.map, _.max, _.min, _.partition, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.size, _.some, _.sortBy") accept strings
111109
* [_#commit](https://lodash.com/docs#prototype-commit) & [_#plant](https://lodash.com/docs#prototype-plant) for working with chain sequences
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var baseDifference = require('../internal/baseDifference'),
2020
* @returns {Array} Returns the new array of filtered values.
2121
* @example
2222
*
23-
* _.difference([1, 2, 3], [5, 2, 10]);
23+
* _.difference([1, 2, 3], [4, 2]);
2424
* // => [1, 3]
2525
*/
2626
function difference() {
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ var baseCallback = require('../internal/baseCallback'),
2727
* @returns {Array} Returns the slice of `array`.
2828
* @example
2929
*
30-
* _.dropRightWhile([1, 2, 3], function(n) { return n > 1; });
30+
* _.dropRightWhile([1, 2, 3], function(n) {
31+
* return n > 1;
32+
* });
3133
* // => [1]
3234
*
3335
* var users = [
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ var baseCallback = require('../internal/baseCallback'),
2727
* @returns {Array} Returns the slice of `array`.
2828
* @example
2929
*
30-
* _.dropWhile([1, 2, 3], function(n) { return n < 3; });
30+
* _.dropWhile([1, 2, 3], function(n) {
31+
* return n < 3;
32+
* });
3133
* // => [3]
3234
*
3335
* var users = [
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ var baseCallback = require('../internal/baseCallback');
3131
* { 'user': 'pebbles', 'active': true }
3232
* ];
3333
*
34-
* _.findIndex(users, function(chr) { return chr.user == 'barney'; });
34+
* _.findIndex(users, function(chr) {
35+
* return chr.user == 'barney';
36+
* });
3537
* // => 0
3638
*
3739
* // using the `_.matches` callback shorthand
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ var baseCallback = require('../internal/baseCallback');
3131
* { 'user': 'pebbles', 'active': false }
3232
* ];
3333
*
34-
* _.findLastIndex(users, function(chr) { return chr.user == 'pebbles'; });
34+
* _.findLastIndex(users, function(chr) {
35+
* return chr.user == 'pebbles';
36+
* });
3537
* // => 2
3638
*
3739
* // using the `_.matches` callback shorthand
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ var baseFlatten = require('../internal/baseFlatten'),
1414
* @returns {Array} Returns the new flattened array.
1515
* @example
1616
*
17-
* _.flatten([1, [2], [3, [[4]]]]);
18-
* // => [1, 2, 3, [[4]]];
17+
* _.flatten([1, [2, 3, [4]]]);
18+
* // => [1, 2, 3, [4]];
1919
*
2020
* // using `isDeep`
21-
* _.flatten([1, [2], [3, [[4]]]], true);
21+
* _.flatten([1, [2, 3, [4]]], true);
2222
* // => [1, 2, 3, 4];
2323
*/
2424
function flatten(array, isDeep, guard) {
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var baseFlatten = require('../internal/baseFlatten');
1010
* @returns {Array} Returns the new flattened array.
1111
* @example
1212
*
13-
* _.flattenDeep([1, [2], [3, [[4]]]]);
13+
* _.flattenDeep([1, [2, 3, [4]]]);
1414
* // => [1, 2, 3, 4];
1515
*/
1616
function flattenDeep(array) {
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ var nativeMax = Math.max;
2525
* @returns {number} Returns the index of the matched value, else `-1`.
2626
* @example
2727
*
28-
* _.indexOf([1, 2, 3, 1, 2, 3], 2);
29-
* // => 1
28+
* _.indexOf([1, 2, 1, 2], 2);
29+
* // => 2
3030
*
3131
* // using `fromIndex`
32-
* _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
33-
* // => 4
32+
* _.indexOf([1, 2, 1, 2], 2, 2);
33+
* // => 3
3434
*
3535
* // performing a binary search
36-
* _.indexOf([4, 4, 5, 5, 6, 6], 5, true);
36+
* _.indexOf([1, 1, 2, 2], 2, true);
3737
* // => 2
3838
*/
3939
function indexOf(array, value, fromIndex) {
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ var baseIndexOf = require('../internal/baseIndexOf'),
1919
* @param {...Array} [arrays] The arrays to inspect.
2020
* @returns {Array} Returns the new array of shared values.
2121
* @example
22-
*
23-
* _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
24-
* // => [1, 2]
22+
* _.intersection([1, 2], [4, 2], [2, 1]);
23+
* // => [2]
2524
*/
2625
function intersection() {
2726
var args = [],
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ var nativeMax = Math.max,
1919
* @returns {number} Returns the index of the matched value, else `-1`.
2020
* @example
2121
*
22-
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
23-
* // => 4
22+
* _.lastIndexOf([1, 2, 1, 2], 2);
23+
* // => 3
2424
*
2525
* // using `fromIndex`
26-
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
26+
* _.lastIndexOf([1, 2, 1, 2], 2, 2);
2727
* // => 1
2828
*
2929
* // performing a binary search
30-
* _.lastIndexOf([4, 4, 5, 5, 6, 6], 5, true);
30+
* _.lastIndexOf([1, 1, 2, 2], 2, true);
3131
* // => 3
3232
*/
3333
function lastIndexOf(array, value, fromIndex) {
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var splice = arrayProto.splice;
2525
* @example
2626
*
2727
* var array = [1, 2, 3, 1, 2, 3];
28+
*
2829
* _.pull(array, 2, 3);
2930
* console.log(array);
3031
* // => [1, 1]
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var baseFlatten = require('../internal/baseFlatten'),
1818
* @example
1919
*
2020
* var array = [5, 10, 15, 20];
21-
* var evens = _.pullAt(array, [1, 3]);
21+
* var evens = _.pullAt(array, 1, 3);
2222
*
2323
* console.log(array);
2424
* // => [5, 15]
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ var splice = arrayProto.splice;
3535
* @example
3636
*
3737
* var array = [1, 2, 3, 4];
38-
* var evens = _.remove(array, function(n) { return n % 2 == 0; });
38+
* var evens = _.remove(array, function(n) {
39+
* return n % 2 == 0;
40+
* });
3941
*
4042
* console.log(array);
4143
* // => [1, 3]
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var baseCallback = require('../internal/baseCallback'),
3535
* _.sortedIndex([30, 50], 40);
3636
* // => 1
3737
*
38-
* _.sortedIndex([4, 4, 5, 5, 6, 6], 5);
38+
* _.sortedIndex([4, 4, 5, 5], 5);
3939
* // => 2
4040
*
4141
* var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var baseCallback = require('../internal/baseCallback'),
1919
* into `array`.
2020
* @example
2121
*
22-
* _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5);
22+
* _.sortedLastIndex([4, 4, 5, 5], 5);
2323
* // => 4
2424
*/
2525
function sortedLastIndex(array, value, iteratee, thisArg) {
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ var baseCallback = require('../internal/baseCallback'),
2727
* @returns {Array} Returns the slice of `array`.
2828
* @example
2929
*
30-
* _.takeRightWhile([1, 2, 3], function(n) { return n > 1; });
30+
* _.takeRightWhile([1, 2, 3], function(n) {
31+
* return n > 1;
32+
* });
3133
* // => [2, 3]
3234
*
3335
* var users = [
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ var baseCallback = require('../internal/baseCallback'),
2727
* @returns {Array} Returns the slice of `array`.
2828
* @example
2929
*
30-
* _.takeWhile([1, 2, 3], function(n) { return n < 3; });
30+
* _.takeWhile([1, 2, 3], function(n) {
31+
* return n < 3;
32+
* });
3133
* // => [1, 2]
3234
*
3335
* var users = [
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ var baseFlatten = require('../internal/baseFlatten'),
1717
* @returns {Array} Returns the new array of combined values.
1818
* @example
1919
*
20-
* _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]);
21-
* // => [1, 2, 3, 5, 4]
20+
* _.union([1, 2], [4, 2], [2, 1]);
21+
* // => [1, 2, 4]
2222
*/
2323
function union() {
2424
return baseUniq(baseFlatten(arguments, false, true));
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ var baseCallback = require('../internal/baseCallback'),
4646
* // => [1, 2]
4747
*
4848
* // using an iteratee function
49-
* _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math);
49+
* _.uniq([1, 2.5, 1.5, 2], function(n) {
50+
* return this.floor(n);
51+
* }, Math);
5052
* // => [1, 2.5]
5153
*
5254
* // using the `_.property` callback shorthand
@@ -58,8 +60,7 @@ function uniq(array, isSorted, iteratee, thisArg) {
5860
if (!length) {
5961
return [];
6062
}
61-
// Juggle arguments.
62-
if (typeof isSorted != 'boolean' && isSorted != null) {
63+
if (isSorted != null && typeof isSorted != 'boolean') {
6364
thisArg = iteratee;
6465
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
6566
isSorted = false;
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ var baseDifference = require('../internal/baseDifference'),
1818
* @returns {Array} Returns the new array of filtered values.
1919
* @example
2020
*
21-
* _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
22-
* // => [2, 3, 4]
21+
* _.without([1, 2, 1, 3], 1, 2);
22+
* // => [3]
2323
*/
2424
function without(array) {
2525
return baseDifference(array, baseSlice(arguments, 1));
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ var baseDifference = require('../internal/baseDifference'),
1515
* @returns {Array} Returns the new array of values.
1616
* @example
1717
*
18-
* _.xor([1, 2, 3], [5, 2, 1, 4]);
19-
* // => [3, 5, 4]
20-
*
21-
* _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]);
22-
* // => [1, 4, 5]
18+
* _.xor([1, 2], [4, 2]);
19+
* // => [1, 4]
2320
*/
2421
function xor() {
2522
var index = -1,
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ var lodash = require('./lodash');
1919
*
2020
* var youngest = _.chain(users)
2121
* .sortBy('age')
22-
* .map(function(chr) { return chr.user + ' is ' + chr.age; })
22+
* .map(function(chr) {
23+
* return chr.user + ' is ' + chr.age;
24+
* })
2325
* .first()
2426
* .value();
2527
* // => 'pebbles is 1'
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var LazyWrapper = require('../internal/LazyWrapper'),
22
LodashWrapper = require('../internal/LodashWrapper'),
3+
baseLodash = require('../internal/baseLodash'),
34
isArray = require('../lang/isArray'),
45
isObjectLike = require('../internal/isObjectLike'),
56
wrapperClone = require('../internal/wrapperClone');
@@ -82,11 +83,15 @@ var hasOwnProperty = objectProto.hasOwnProperty;
8283
* var wrapped = _([1, 2, 3]);
8384
*
8485
* // returns an unwrapped value
85-
* wrapped.reduce(function(sum, n) { return sum + n; });
86+
* wrapped.reduce(function(sum, n) {
87+
* return sum + n;
88+
* });
8689
* // => 6
8790
*
8891
* // returns a wrapped value
89-
* var squares = wrapped.map(function(n) { return n * n; });
92+
* var squares = wrapped.map(function(n) {
93+
* return n * n;
94+
* });
9095
*
9196
* _.isArray(squares);
9297
* // => false
@@ -106,4 +111,7 @@ function lodash(value) {
106111
return new LodashWrapper(value);
107112
}
108113

114+
// Ensure wrappers are instances of `baseLodash`.
115+
lodash.prototype = baseLodash.prototype;
116+
109117
module.exports = lodash;
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
* @example
1515
*
1616
* _([1, 2, 3])
17-
* .tap(function(array) { array.pop(); })
17+
* .tap(function(array) {
18+
* array.pop();
19+
* })
1820
* .reverse()
1921
* .value();
2022
* // => [2, 1]
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
*
1313
* _([1, 2, 3])
1414
* .last()
15-
* .thru(function(value) { return [value]; })
15+
* .thru(function(value) {
16+
* return [value];
17+
* })
1618
* .value();
1719
* // => [3]
1820
*/