Bump to v4.17.1.

This commit is contained in:
John-David Dalton
2016-11-14 20:54:18 -08:00
parent 7402021739
commit 76b7758fc7
18 changed files with 94 additions and 79 deletions

View File

@@ -1,4 +1,4 @@
# lodash-amd v4.17.0
# lodash-amd v4.17.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.17.0-amd) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.17.1-amd) for more details.

View File

@@ -1,4 +1,4 @@
define(['./_castPath', './_isKey', './_toKey'], function(castPath, isKey, toKey) {
define(['./_castPath', './_toKey'], function(castPath, toKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -12,7 +12,7 @@ define(['./_castPath', './_isKey', './_toKey'], function(castPath, isKey, toKey)
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
var index = 0,
length = path.length;

View File

@@ -1,4 +1,4 @@
define(['./_apply', './_castPath', './_isKey', './last', './_parent', './_toKey'], function(apply, castPath, isKey, last, parent, toKey) {
define(['./_apply', './_castPath', './last', './_parent', './_toKey'], function(apply, castPath, last, parent, toKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -14,12 +14,9 @@ define(['./_apply', './_castPath', './_isKey', './last', './_parent', './_toKey'
* @returns {*} Returns the result of the invoked method.
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
path = castPath(path);
path = castPath(path, object);
object = parent(object, path);
path = last(path);
}
var func = object == null ? object : object[toKey(path)];
var func = object == null ? object : object[toKey(last(path))];
return func == null ? undefined : apply(func, object, args);
}

View File

@@ -1,4 +1,4 @@
define(['./_castPath', './_isIndex', './_isKey', './last', './_parent', './_toKey'], function(castPath, isIndex, isKey, last, parent, toKey) {
define(['./_castPath', './_isIndex', './last', './_parent', './_toKey'], function(castPath, isIndex, last, parent, toKey) {
/** Used for built-in method references. */
var arrayProto = Array.prototype;
@@ -26,17 +26,14 @@ define(['./_castPath', './_isIndex', './_isKey', './last', './_parent', './_toKe
if (isIndex(index)) {
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
var path = castPath(index),
else {
var path = castPath(index, array),
object = parent(array, path);
if (object != null) {
delete object[toKey(last(path))];
}
}
else {
delete array[toKey(index)];
}
}
}
return array;

View File

@@ -1,4 +1,4 @@
define(['./_assignValue', './_castPath', './_isIndex', './_isKey', './isObject', './_toKey'], function(assignValue, castPath, isIndex, isKey, isObject, toKey) {
define(['./_assignValue', './_castPath', './_isIndex', './isObject', './_toKey'], function(assignValue, castPath, isIndex, isObject, toKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -17,7 +17,7 @@ define(['./_assignValue', './_castPath', './_isIndex', './_isKey', './isObject',
if (!isObject(object)) {
return object;
}
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
var index = -1,
length = path.length,

View File

@@ -1,4 +1,4 @@
define(['./_castPath', './_isKey', './last', './_parent', './_toKey'], function(castPath, isKey, last, parent, toKey) {
define(['./_castPath', './last', './_parent', './_toKey'], function(castPath, last, parent, toKey) {
/** Used for built-in method references. */
var objectProto = Object.prototype;
@@ -15,9 +15,8 @@ define(['./_castPath', './_isKey', './last', './_parent', './_toKey'], function(
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
object = parent(object, path);
var key = toKey(last(path));
return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
}

View File

@@ -1,14 +1,18 @@
define(['./isArray', './_stringToPath'], function(isArray, stringToPath) {
define(['./isArray', './_isKey', './_stringToPath', './toString'], function(isArray, isKey, stringToPath, toString) {
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
function castPath(value, object) {
if (isArray(value)) {
return value;
}
return isKey(value, object) ? [value] : stringToPath(toString(value));
}
return castPath;

View File

@@ -1,4 +1,4 @@
define(['./_castPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './_toKey'], function(castPath, isArguments, isArray, isIndex, isKey, isLength, toKey) {
define(['./_castPath', './isArguments', './isArray', './_isIndex', './isLength', './_toKey'], function(castPath, isArguments, isArray, isIndex, isLength, toKey) {
/**
* Checks if `path` exists on `object`.
@@ -10,7 +10,7 @@ define(['./_castPath', './isArguments', './isArray', './_isIndex', './_isKey', '
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
var index = -1,
length = path.length,

View File

@@ -9,7 +9,7 @@ define(['./_baseGet', './_baseSlice'], function(baseGet, baseSlice) {
* @returns {*} Returns the parent value.
*/
function parent(object, path) {
return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
}
return parent;

View File

@@ -1,4 +1,4 @@
define(['./_memoizeCapped', './toString'], function(memoizeCapped, toString) {
define(['./_memoizeCapped'], function(memoizeCapped) {
/** Used to match property names within property paths. */
var reLeadingDot = /^\./,
@@ -15,8 +15,6 @@ define(['./_memoizeCapped', './toString'], function(memoizeCapped, toString) {
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoizeCapped(function(string) {
string = toString(string);
var result = [];
if (reLeadingDot.test(string)) {
result.push('');

View File

@@ -1,7 +1,4 @@
define(['./_apply', './_baseEach', './_baseInvoke', './_baseRest', './isArrayLike', './_isKey'], function(apply, baseEach, baseInvoke, baseRest, isArrayLike, isKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
define(['./_apply', './_baseEach', './_baseInvoke', './_baseRest', './isArrayLike'], function(apply, baseEach, baseInvoke, baseRest, isArrayLike) {
/**
* Invokes the method at `path` of each element in `collection`, returning
@@ -29,12 +26,10 @@ define(['./_apply', './_baseEach', './_baseInvoke', './_baseRest', './isArrayLik
var invokeMap = baseRest(function(collection, path, args) {
var index = -1,
isFunc = typeof path == 'function',
isProp = isKey(path),
result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value) {
var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args);
result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
});
return result;
});

67
main.js
View File

@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
var VERSION = '4.17.0';
var VERSION = '4.17.1';
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
@@ -3057,7 +3057,7 @@
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
var index = 0,
length = path.length;
@@ -3243,12 +3243,9 @@
* @returns {*} Returns the result of the invoked method.
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
path = castPath(path);
path = castPath(path, object);
object = parent(object, path);
path = last(path);
}
var func = object == null ? object : object[toKey(path)];
var func = object == null ? object : object[toKey(last(path))];
return func == null ? undefined : apply(func, object, args);
}
@@ -3886,17 +3883,14 @@
if (isIndex(index)) {
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
var path = castPath(index),
else {
var path = castPath(index, array),
object = parent(array, path);
if (object != null) {
delete object[toKey(last(path))];
}
}
else {
delete array[toKey(index)];
}
}
}
return array;
@@ -4016,7 +4010,7 @@
if (!isObject(object)) {
return object;
}
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
var index = -1,
length = path.length,
@@ -4357,9 +4351,8 @@
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
object = parent(object, path);
var key = toKey(last(path));
return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
}
@@ -4501,10 +4494,14 @@
*
* @private
* @param {*} value The value to inspect.
* @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
function castPath(value, object) {
if (isArray(value)) {
return value;
}
return isKey(value, object) ? [value] : stringToPath(toString(value));
}
/**
@@ -6129,7 +6126,7 @@
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
var index = -1,
length = path.length,
@@ -6606,7 +6603,7 @@
* @returns {*} Returns the parent value.
*/
function parent(object, path) {
return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
}
/**
@@ -6746,8 +6743,6 @@
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoizeCapped(function(string) {
string = toString(string);
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
@@ -9482,12 +9477,10 @@
var invokeMap = baseRest(function(collection, path, args) {
var index = -1,
isFunc = typeof path == 'function',
isProp = isKey(path),
result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value) {
var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args);
result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
});
return result;
});
@@ -13478,8 +13471,15 @@
if (object == null) {
return result;
}
var bitmask = CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG;
paths = arrayMap(paths, function(path) {
path = castPath(path, object);
bitmask |= (path.length > 1 ? CLONE_DEEP_FLAG : 0);
return path;
});
copyObject(object, getAllKeysIn(object), result);
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
result = baseClone(result, bitmask);
var length = paths.length;
while (length--) {
@@ -13530,7 +13530,7 @@
* // => { 'a': 1, 'c': 3 }
*/
var pick = flatRest(function(object, paths) {
return object == null ? {} : basePick(object, arrayMap(paths, toKey));
return object == null ? {} : basePick(object, paths);
});
/**
@@ -13552,7 +13552,16 @@
* // => { 'a': 1, 'c': 3 }
*/
function pickBy(object, predicate) {
return object == null ? {} : basePickBy(object, getAllKeysIn(object), getIteratee(predicate));
if (object == null) {
return {};
}
var props = arrayMap(getAllKeysIn(object), function(prop) {
return [prop];
});
predicate = getIteratee(predicate);
return basePickBy(object, props, function(value, path) {
return predicate(value, path[0]);
});
}
/**
@@ -13585,7 +13594,7 @@
* // => 'default'
*/
function result(object, path, defaultValue) {
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
var index = -1,
length = path.length;
@@ -16103,7 +16112,7 @@
if (isArray(value)) {
return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
}
/**

11
omit.js
View File

@@ -1,4 +1,4 @@
define(['./_baseClone', './_baseUnset', './_copyObject', './_flatRest', './_getAllKeysIn'], function(baseClone, baseUnset, copyObject, flatRest, getAllKeysIn) {
define(['./_arrayMap', './_baseClone', './_baseUnset', './_castPath', './_copyObject', './_flatRest', './_getAllKeysIn'], function(arrayMap, baseClone, baseUnset, castPath, copyObject, flatRest, getAllKeysIn) {
/** Used to compose bitmasks for cloning. */
var CLONE_DEEP_FLAG = 1,
@@ -30,8 +30,15 @@ define(['./_baseClone', './_baseUnset', './_copyObject', './_flatRest', './_getA
if (object == null) {
return result;
}
var bitmask = CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG;
paths = arrayMap(paths, function(path) {
path = castPath(path, object);
bitmask |= (path.length > 1 ? CLONE_DEEP_FLAG : 0);
return path;
});
copyObject(object, getAllKeysIn(object), result);
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
result = baseClone(result, bitmask);
var length = paths.length;
while (length--) {

View File

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

View File

@@ -1,4 +1,4 @@
define(['./_arrayMap', './_basePick', './_flatRest', './_toKey'], function(arrayMap, basePick, flatRest, toKey) {
define(['./_basePick', './_flatRest'], function(basePick, flatRest) {
/**
* Creates an object composed of the picked `object` properties.
@@ -18,7 +18,7 @@ define(['./_arrayMap', './_basePick', './_flatRest', './_toKey'], function(array
* // => { 'a': 1, 'c': 3 }
*/
var pick = flatRest(function(object, paths) {
return object == null ? {} : basePick(object, arrayMap(paths, toKey));
return object == null ? {} : basePick(object, paths);
});
return pick;

View File

@@ -1,4 +1,4 @@
define(['./_baseIteratee', './_basePickBy', './_getAllKeysIn'], function(baseIteratee, basePickBy, getAllKeysIn) {
define(['./_arrayMap', './_baseIteratee', './_basePickBy', './_getAllKeysIn'], function(arrayMap, baseIteratee, basePickBy, getAllKeysIn) {
/**
* Creates an object composed of the `object` properties `predicate` returns
@@ -19,7 +19,16 @@ define(['./_baseIteratee', './_basePickBy', './_getAllKeysIn'], function(baseIte
* // => { 'a': 1, 'c': 3 }
*/
function pickBy(object, predicate) {
return object == null ? {} : basePickBy(object, getAllKeysIn(object), baseIteratee(predicate));
if (object == null) {
return {};
}
var props = arrayMap(getAllKeysIn(object), function(prop) {
return [prop];
});
predicate = baseIteratee(predicate);
return basePickBy(object, props, function(value, path) {
return predicate(value, path[0]);
});
}
return pickBy;

View File

@@ -1,4 +1,4 @@
define(['./_castPath', './isFunction', './_isKey', './_toKey'], function(castPath, isFunction, isKey, toKey) {
define(['./_castPath', './isFunction', './_toKey'], function(castPath, isFunction, toKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -33,7 +33,7 @@ define(['./_castPath', './isFunction', './_isKey', './_toKey'], function(castPat
* // => 'default'
*/
function result(object, path, defaultValue) {
path = isKey(path, object) ? [path] : castPath(path);
path = castPath(path, object);
var index = -1,
length = path.length;

View File

@@ -1,4 +1,4 @@
define(['./_arrayMap', './_copyArray', './isArray', './isSymbol', './_stringToPath', './_toKey'], function(arrayMap, copyArray, isArray, isSymbol, stringToPath, toKey) {
define(['./_arrayMap', './_copyArray', './isArray', './isSymbol', './_stringToPath', './_toKey', './toString'], function(arrayMap, copyArray, isArray, isSymbol, stringToPath, toKey, toString) {
/**
* Converts `value` to a property path array.
@@ -21,7 +21,7 @@ define(['./_arrayMap', './_copyArray', './isArray', './isSymbol', './_stringToPa
if (isArray(value)) {
return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
}
return toPath;