Bump to v3.7.0.

This commit is contained in:
John-David Dalton
2015-12-16 17:49:35 -08:00
parent 9724afd7a6
commit fec213a98c
121 changed files with 1686 additions and 815 deletions

View File

@@ -1,4 +1,4 @@
define(['../internal/baseCallback', '../internal/isIterateeCall', '../internal/isObjectLike', './matches'], function(baseCallback, isIterateeCall, isObjectLike, matches) {
define(['../internal/baseCallback', '../internal/isIterateeCall'], function(baseCallback, isIterateeCall) {
/**
* Creates a function that invokes `func` with the `this` binding of `thisArg`
@@ -42,9 +42,7 @@ define(['../internal/baseCallback', '../internal/isIterateeCall', '../internal/i
if (guard && isIterateeCall(func, thisArg, guard)) {
thisArg = null;
}
return isObjectLike(func)
? matches(func)
: baseCallback(func, thisArg);
return baseCallback(func, thisArg);
}
return callback;

View File

@@ -1,7 +1,7 @@
define(['../internal/baseClone', '../internal/baseMatchesProperty'], function(baseClone, baseMatchesProperty) {
/**
* Creates a function which compares the property value of `key` on a given
* Creates a function which compares the property value of `path` on a given
* object to `value`.
*
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
@@ -11,7 +11,7 @@ define(['../internal/baseClone', '../internal/baseMatchesProperty'], function(ba
* @static
* @memberOf _
* @category Utility
* @param {string} key The key of the property to get.
* @param {Array|string} path The path of the property to get.
* @param {*} value The value to compare.
* @returns {Function} Returns the new function.
* @example
@@ -24,8 +24,8 @@ define(['../internal/baseClone', '../internal/baseMatchesProperty'], function(ba
* _.find(users, _.matchesProperty('user', 'fred'));
* // => { 'user': 'fred' }
*/
function matchesProperty(key, value) {
return baseMatchesProperty(key + '', baseClone(value, true));
function matchesProperty(path, value) {
return baseMatchesProperty(path, baseClone(value, true));
}
return matchesProperty;

31
utility/method.js Normal file
View File

@@ -0,0 +1,31 @@
define(['../internal/invokePath', '../function/restParam'], function(invokePath, restParam) {
/**
* Creates a function which invokes the method at `path` on a given object.
*
* @static
* @memberOf _
* @category Utility
* @param {Array|string} path The path of the method to invoke.
* @returns {Function} Returns the new function.
* @example
*
* var objects = [
* { 'a': { 'b': { 'c': _.constant(2) } } },
* { 'a': { 'b': { 'c': _.constant(1) } } }
* ];
*
* _.map(objects, _.method('a.b.c'));
* // => [2, 1]
*
* _.invoke(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c');
* // => [1, 2]
*/
var method = restParam(function(path, args) {
return function(object) {
return invokePath(object, path, args);
}
});
return method;
});

30
utility/methodOf.js Normal file
View File

@@ -0,0 +1,30 @@
define(['../internal/invokePath', '../function/restParam'], function(invokePath, restParam) {
/**
* The opposite of `_.method`; this method creates a function which invokes
* the method at a given path on `object`.
*
* @static
* @memberOf _
* @category Utility
* @param {Object} object The object to query.
* @returns {Function} Returns the new function.
* @example
*
* var array = _.times(3, _.constant),
* object = { 'a': array, 'b': array, 'c': array };
*
* _.map(['a[2]', 'c[0]'], _.methodOf(object));
* // => [2, 0]
*
* _.map([['a', '2'], ['c', '0']], _.methodOf(object));
* // => [2, 0]
*/
var methodOf = restParam(function(object, args) {
return function(path) {
return invokePath(object, path, args);
};
});
return methodOf;
});

View File

@@ -11,13 +11,13 @@ define(['../internal/arrayCopy', '../internal/baseFunctions', '../lang/isFunctio
* destination object. If `object` is a function then methods are added to
* its prototype as well.
*
* **Note:** Use `_.runInContext` to create a pristine `lodash` function
* for mixins to avoid conflicts caused by modifying the original.
* **Note:** Use `_.runInContext` to create a pristine `lodash` function to
* avoid conflicts caused by modifying the original.
*
* @static
* @memberOf _
* @category Utility
* @param {Function|Object} [object=this] object The destination object.
* @param {Function|Object} [object=lodash] The destination object.
* @param {Object} source The object of functions to add.
* @param {Object} [options] The options object.
* @param {boolean} [options.chain=true] Specify whether the functions added

View File

@@ -1,30 +1,29 @@
define(['../internal/baseProperty'], function(baseProperty) {
define(['../internal/baseProperty', '../internal/basePropertyDeep', '../internal/isKey'], function(baseProperty, basePropertyDeep, isKey) {
/**
* Creates a function which returns the property value of `key` on a given object.
* Creates a function which returns the property value at `path` on a
* given object.
*
* @static
* @memberOf _
* @category Utility
* @param {string} key The key of the property to get.
* @param {Array|string} path The path of the property to get.
* @returns {Function} Returns the new function.
* @example
*
* var users = [
* { 'user': 'fred' },
* { 'user': 'barney' }
* var objects = [
* { 'a': { 'b': { 'c': 2 } } },
* { 'a': { 'b': { 'c': 1 } } }
* ];
*
* var getName = _.property('user');
* _.map(objects, _.property('a.b.c'));
* // => [2, 1]
*
* _.map(users, getName);
* // => ['fred', 'barney']
*
* _.pluck(_.sortBy(users, getName), 'user');
* // => ['barney', 'fred']
* _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
* // => [1, 2]
*/
function property(key) {
return baseProperty(key + '');
function property(path) {
return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
}
return property;

View File

@@ -1,30 +1,28 @@
define([], function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
define(['../internal/baseGet', '../internal/toPath'], function(baseGet, toPath) {
/**
* The opposite of `_.property`; this method creates a function which returns
* the property value of a given key on `object`.
* the property value at a given path on `object`.
*
* @static
* @memberOf _
* @category Utility
* @param {Object} object The object to inspect.
* @param {Object} object The object to query.
* @returns {Function} Returns the new function.
* @example
*
* var object = { 'a': 3, 'b': 1, 'c': 2 };
* var array = [0, 1, 2],
* object = { 'a': array, 'b': array, 'c': array };
*
* _.map(['a', 'c'], _.propertyOf(object));
* // => [3, 2]
* _.map(['a[2]', 'c[0]'], _.propertyOf(object));
* // => [2, 0]
*
* _.sortBy(['a', 'b', 'c'], _.propertyOf(object));
* // => ['b', 'c', 'a']
* _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
* // => [2, 0]
*/
function propertyOf(object) {
return function(key) {
return object == null ? undefined : object[key];
return function(path) {
return baseGet(object, toPath(path), path + '');
};
}

View File

@@ -9,7 +9,7 @@ define(['../internal/isIterateeCall'], function(isIterateeCall) {
/**
* Creates an array of numbers (positive and/or negative) progressing from
* `start` up to, but not including, `end`. If `end` is not specified it is
* set to `start` with `start` then set to `0`. If `start` is less than `end`
* set to `start` with `start` then set to `0`. If `end` is less than `start`
* a zero-length range is created unless a negative `step` is specified.
*
* @static

View File

@@ -1,5 +1,8 @@
define(['../internal/bindCallback', '../internal/root'], function(bindCallback, root) {
/** Native method references. */
var floor = Math.floor;
/* Native method references for those with the same name as other `lodash` methods. */
var nativeIsFinite = root.isFinite,
nativeMin = Math.min;
@@ -27,7 +30,7 @@ define(['../internal/bindCallback', '../internal/root'], function(bindCallback,
* _.times(3, function(n) {
* mage.castSpell(n);
* });
* // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2` respectively
* // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2`
*
* _.times(3, function(n) {
* this.cast(n);
@@ -35,7 +38,7 @@ define(['../internal/bindCallback', '../internal/root'], function(bindCallback,
* // => also invokes `mage.castSpell(n)` three times
*/
function times(n, iteratee, thisArg) {
n = +n;
n = floor(n);
// Exit early to avoid a JSC JIT bug in Safari 8
// where `Array(0)` is treated as `Array(1)`.