mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import isError from '../lang/isError';
|
||||
import restParam from '../function/restParam';
|
||||
|
||||
/**
|
||||
* Attempts to invoke `func`, returning either the result or the caught error
|
||||
@@ -7,7 +8,7 @@ import isError from '../lang/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
|
||||
*
|
||||
@@ -20,19 +21,12 @@ import isError from '../lang/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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default attempt;
|
||||
|
||||
@@ -19,12 +19,11 @@ import baseMatchesProperty from '../internal/baseMatchesProperty';
|
||||
*
|
||||
* 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));
|
||||
|
||||
@@ -15,6 +15,9 @@ var push = arrayProto.push;
|
||||
* 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
|
||||
@@ -32,7 +35,7 @@ var push = arrayProto.push;
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* // 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 });
|
||||
@@ -69,12 +72,10 @@ function mixin(object, source, options) {
|
||||
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 @@ import baseProperty from '../internal/baseProperty';
|
||||
* var getName = _.property('user');
|
||||
*
|
||||
* _.map(users, getName);
|
||||
* // => ['fred', barney']
|
||||
* // => ['fred', 'barney']
|
||||
*
|
||||
* _.pluck(_.sortBy(users, getName), 'user');
|
||||
* // => ['barney', 'fred']
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 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