Compare commits

...

1 Commits

Author SHA1 Message Date
John-David Dalton
2ab869e88a Bump to v4.13.1. 2016-05-23 12:25:07 -07:00
7 changed files with 69 additions and 34 deletions

View File

@@ -1,4 +1,4 @@
# lodash-amd v4.13.0
# lodash-amd v4.13.1
The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
@@ -27,4 +27,4 @@ require({
});
```
See the [package source](https://github.com/lodash/lodash/tree/4.13.0-amd) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.13.1-amd) for more details.

32
_createFind.js Normal file
View File

@@ -0,0 +1,32 @@
define(['./_baseIteratee', './isArrayLike', './keys'], function(baseIteratee, isArrayLike, keys) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Creates a `_.find` or `_.findLast` function.
*
* @private
* @param {Function} findIndexFunc The function to find the collection index.
* @returns {Function} Returns the new find function.
*/
function createFind(findIndexFunc) {
return function(collection, predicate, fromIndex) {
var iterable = Object(collection);
predicate = baseIteratee(predicate, 3);
if (!isArrayLike(collection)) {
var props = keys(collection);
}
var index = findIndexFunc(props || collection, function(value, key) {
if (props) {
key = value;
value = iterable[key];
}
return predicate(value, key, iterable);
}, fromIndex);
return index > -1 ? collection[props ? props[index] : index] : undefined;
};
}
return createFind;
});

View File

@@ -7,7 +7,7 @@ define(['./_coreJsData', './isFunction', './stubFalse'], function(coreJsData, is
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `func` is maskable, else `false`.
*/
var isMaskable = !coreJsData ? stubFalse : isFunction;
var isMaskable = coreJsData ? isFunction : stubFalse;
return isMaskable;
});

11
find.js
View File

@@ -1,7 +1,4 @@
define(['./findIndex', './isArrayLike', './values'], function(findIndex, isArrayLike, values) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
define(['./_createFind', './findIndex'], function(createFind, findIndex) {
/**
* Iterates over elements of `collection`, returning the first element
@@ -40,11 +37,7 @@ define(['./findIndex', './isArrayLike', './values'], function(findIndex, isArray
* _.find(users, 'active');
* // => object for 'barney'
*/
function find(collection, predicate, fromIndex) {
collection = isArrayLike(collection) ? collection : values(collection);
var index = findIndex(collection, predicate, fromIndex);
return index > -1 ? collection[index] : undefined;
}
var find = createFind(findIndex);
return find;
});

View File

@@ -1,7 +1,4 @@
define(['./findLastIndex', './isArrayLike', './values'], function(findLastIndex, isArrayLike, values) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
define(['./_createFind', './findLastIndex'], function(createFind, findLastIndex) {
/**
* This method is like `_.find` except that it iterates over elements of
@@ -23,11 +20,7 @@ define(['./findLastIndex', './isArrayLike', './values'], function(findLastIndex,
* });
* // => 3
*/
function findLast(collection, predicate, fromIndex) {
collection = isArrayLike(collection) ? collection : values(collection);
var index = findLastIndex(collection, predicate, fromIndex);
return index > -1 ? collection[index] : undefined;
}
var findLast = createFind(findLastIndex);
return findLast;
});

41
main.js
View File

@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
var VERSION = '4.13.0';
var VERSION = '4.13.1';
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
@@ -4550,6 +4550,31 @@
return wrapper;
}
/**
* Creates a `_.find` or `_.findLast` function.
*
* @private
* @param {Function} findIndexFunc The function to find the collection index.
* @returns {Function} Returns the new find function.
*/
function createFind(findIndexFunc) {
return function(collection, predicate, fromIndex) {
var iterable = Object(collection);
predicate = getIteratee(predicate, 3);
if (!isArrayLike(collection)) {
var props = keys(collection);
}
var index = findIndexFunc(props || collection, function(value, key) {
if (props) {
key = value;
value = iterable[key];
}
return predicate(value, key, iterable);
}, fromIndex);
return index > -1 ? collection[props ? props[index] : index] : undefined;
};
}
/**
* Creates a `_.flow` or `_.flowRight` function.
*
@@ -5795,7 +5820,7 @@
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `func` is maskable, else `false`.
*/
var isMaskable = !coreJsData ? stubFalse : isFunction;
var isMaskable = coreJsData ? isFunction : stubFalse;
/**
* Checks if `value` is likely a prototype object.
@@ -8473,11 +8498,7 @@
* _.find(users, 'active');
* // => object for 'barney'
*/
function find(collection, predicate, fromIndex) {
collection = isArrayLike(collection) ? collection : values(collection);
var index = findIndex(collection, predicate, fromIndex);
return index > -1 ? collection[index] : undefined;
}
var find = createFind(findIndex);
/**
* This method is like `_.find` except that it iterates over elements of
@@ -8499,11 +8520,7 @@
* });
* // => 3
*/
function findLast(collection, predicate, fromIndex) {
collection = isArrayLike(collection) ? collection : values(collection);
var index = findLastIndex(collection, predicate, fromIndex);
return index > -1 ? collection[index] : undefined;
}
var findLast = createFind(findLastIndex);
/**
* Creates a flattened array of values by running each element in `collection`

View File

@@ -1,6 +1,6 @@
{
"name": "lodash-amd",
"version": "4.13.0",
"version": "4.13.1",
"description": "Lodash exported as AMD modules.",
"keywords": "amd, modules, stdlib, util",
"homepage": "https://lodash.com/custom-builds",