mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
define(['../lang/isError'], function(isError) {
|
||||
define(['../lang/isError', '../function/restParam'], function(isError, restParam) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -10,7 +10,7 @@ define(['../lang/isError'], function(isError) {
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {*} func The function to attempt.
|
||||
* @param {Function} func The function to attempt.
|
||||
* @returns {*} Returns the `func` result or error object.
|
||||
* @example
|
||||
*
|
||||
@@ -23,20 +23,13 @@ define(['../lang/isError'], function(isError) {
|
||||
* elements = [];
|
||||
* }
|
||||
*/
|
||||
function attempt() {
|
||||
var func = arguments[0],
|
||||
length = arguments.length,
|
||||
args = Array(length ? (length - 1) : 0);
|
||||
|
||||
while (--length > 0) {
|
||||
args[length - 1] = arguments[length];
|
||||
}
|
||||
var attempt = restParam(function(func, args) {
|
||||
try {
|
||||
return func.apply(undefined, args);
|
||||
} catch(e) {
|
||||
return isError(e) ? e : new Error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return attempt;
|
||||
});
|
||||
|
||||
@@ -18,12 +18,11 @@ define(['../internal/baseClone', '../internal/baseMatchesProperty'], function(ba
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney' },
|
||||
* { 'user': 'fred' },
|
||||
* { 'user': 'pebbles' }
|
||||
* { 'user': 'fred' }
|
||||
* ];
|
||||
*
|
||||
* _.find(users, _.matchesProperty('user', 'fred'));
|
||||
* // => { 'user': 'fred', 'age': 40 }
|
||||
* // => { 'user': 'fred' }
|
||||
*/
|
||||
function matchesProperty(key, value) {
|
||||
return baseMatchesProperty(key + '', baseClone(value, true));
|
||||
|
||||
@@ -11,6 +11,9 @@ 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.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
@@ -28,7 +31,7 @@ define(['../internal/arrayCopy', '../internal/baseFunctions', '../lang/isFunctio
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* // use `_.runInContext` to avoid potential conflicts (esp. in Node.js)
|
||||
* // use `_.runInContext` to avoid conflicts (esp. in Node.js)
|
||||
* var _ = require('lodash').runInContext();
|
||||
*
|
||||
* _.mixin({ 'vowels': vowels });
|
||||
@@ -65,12 +68,10 @@ define(['../internal/arrayCopy', '../internal/baseFunctions', '../lang/isFunctio
|
||||
return function() {
|
||||
var chainAll = this.__chain__;
|
||||
if (chain || chainAll) {
|
||||
var result = object(this.__wrapped__);
|
||||
(result.__actions__ = arrayCopy(this.__actions__)).push({
|
||||
'func': func,
|
||||
'args': arguments,
|
||||
'thisArg': object
|
||||
});
|
||||
var result = object(this.__wrapped__),
|
||||
actions = result.__actions__ = arrayCopy(this.__actions__);
|
||||
|
||||
actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
|
||||
result.__chain__ = chainAll;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ define(['../internal/baseProperty'], function(baseProperty) {
|
||||
* var getName = _.property('user');
|
||||
*
|
||||
* _.map(users, getName);
|
||||
* // => ['fred', barney']
|
||||
* // => ['fred', 'barney']
|
||||
*
|
||||
* _.pluck(_.sortBy(users, getName), 'user');
|
||||
* // => ['barney', 'fred']
|
||||
|
||||
@@ -4,7 +4,7 @@ define([], function() {
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* The inverse of `_.property`; this method creates a function which returns
|
||||
* The opposite of `_.property`; this method creates a function which returns
|
||||
* the property value of a given key on `object`.
|
||||
*
|
||||
* @static
|
||||
|
||||
Reference in New Issue
Block a user