Compare commits

...

1 Commits

Author SHA1 Message Date
John-David Dalton
76b7758fc7 Bump to v4.17.1. 2016-11-14 20:54:18 -08:00
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. 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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -12,7 +12,7 @@ define(['./_castPath', './_isKey', './_toKey'], function(castPath, isKey, toKey)
* @returns {*} Returns the resolved value. * @returns {*} Returns the resolved value.
*/ */
function baseGet(object, path) { function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
var index = 0, var index = 0,
length = path.length; 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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -14,12 +14,9 @@ define(['./_apply', './_castPath', './_isKey', './last', './_parent', './_toKey'
* @returns {*} Returns the result of the invoked method. * @returns {*} Returns the result of the invoked method.
*/ */
function baseInvoke(object, path, args) { function baseInvoke(object, path, args) {
if (!isKey(path, object)) { path = castPath(path, object);
path = castPath(path); object = parent(object, path);
object = parent(object, path); var func = object == null ? object : object[toKey(last(path))];
path = last(path);
}
var func = object == null ? object : object[toKey(path)];
return func == null ? undefined : apply(func, object, args); 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. */ /** Used for built-in method references. */
var arrayProto = Array.prototype; var arrayProto = Array.prototype;
@@ -26,17 +26,14 @@ define(['./_castPath', './_isIndex', './_isKey', './last', './_parent', './_toKe
if (isIndex(index)) { if (isIndex(index)) {
splice.call(array, index, 1); splice.call(array, index, 1);
} }
else if (!isKey(index, array)) { else {
var path = castPath(index), var path = castPath(index, array),
object = parent(array, path); object = parent(array, path);
if (object != null) { if (object != null) {
delete object[toKey(last(path))]; delete object[toKey(last(path))];
} }
} }
else {
delete array[toKey(index)];
}
} }
} }
return array; 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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -17,7 +17,7 @@ define(['./_assignValue', './_castPath', './_isIndex', './_isKey', './isObject',
if (!isObject(object)) { if (!isObject(object)) {
return object; return object;
} }
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
var index = -1, var index = -1,
length = path.length, 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. */ /** Used for built-in method references. */
var objectProto = Object.prototype; 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`. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/ */
function baseUnset(object, path) { function baseUnset(object, path) {
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
object = parent(object, path); object = parent(object, path);
var key = toKey(last(path)); var key = toKey(last(path));
return !(object != null && hasOwnProperty.call(object, key)) || delete object[key]; 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. * Casts `value` to a path array if it's not one.
* *
* @private * @private
* @param {*} value The value to inspect. * @param {*} value The value to inspect.
* @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array. * @returns {Array} Returns the cast property path array.
*/ */
function castPath(value) { function castPath(value, object) {
return isArray(value) ? value : stringToPath(value); if (isArray(value)) {
return value;
}
return isKey(value, object) ? [value] : stringToPath(toString(value));
} }
return castPath; 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`. * 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`. * @returns {boolean} Returns `true` if `path` exists, else `false`.
*/ */
function hasPath(object, path, hasFunc) { function hasPath(object, path, hasFunc) {
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
var index = -1, var index = -1,
length = path.length, length = path.length,

View File

@@ -9,7 +9,7 @@ define(['./_baseGet', './_baseSlice'], function(baseGet, baseSlice) {
* @returns {*} Returns the parent value. * @returns {*} Returns the parent value.
*/ */
function parent(object, path) { 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; 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. */ /** Used to match property names within property paths. */
var reLeadingDot = /^\./, var reLeadingDot = /^\./,
@@ -15,8 +15,6 @@ define(['./_memoizeCapped', './toString'], function(memoizeCapped, toString) {
* @returns {Array} Returns the property path array. * @returns {Array} Returns the property path array.
*/ */
var stringToPath = memoizeCapped(function(string) { var stringToPath = memoizeCapped(function(string) {
string = toString(string);
var result = []; var result = [];
if (reLeadingDot.test(string)) { if (reLeadingDot.test(string)) {
result.push(''); result.push('');

View File

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

69
main.js
View File

@@ -13,7 +13,7 @@
var undefined; var undefined;
/** Used as the semantic version number. */ /** 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. */ /** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
@@ -3057,7 +3057,7 @@
* @returns {*} Returns the resolved value. * @returns {*} Returns the resolved value.
*/ */
function baseGet(object, path) { function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
var index = 0, var index = 0,
length = path.length; length = path.length;
@@ -3243,12 +3243,9 @@
* @returns {*} Returns the result of the invoked method. * @returns {*} Returns the result of the invoked method.
*/ */
function baseInvoke(object, path, args) { function baseInvoke(object, path, args) {
if (!isKey(path, object)) { path = castPath(path, object);
path = castPath(path); object = parent(object, path);
object = parent(object, path); var func = object == null ? object : object[toKey(last(path))];
path = last(path);
}
var func = object == null ? object : object[toKey(path)];
return func == null ? undefined : apply(func, object, args); return func == null ? undefined : apply(func, object, args);
} }
@@ -3886,17 +3883,14 @@
if (isIndex(index)) { if (isIndex(index)) {
splice.call(array, index, 1); splice.call(array, index, 1);
} }
else if (!isKey(index, array)) { else {
var path = castPath(index), var path = castPath(index, array),
object = parent(array, path); object = parent(array, path);
if (object != null) { if (object != null) {
delete object[toKey(last(path))]; delete object[toKey(last(path))];
} }
} }
else {
delete array[toKey(index)];
}
} }
} }
return array; return array;
@@ -4016,7 +4010,7 @@
if (!isObject(object)) { if (!isObject(object)) {
return object; return object;
} }
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
var index = -1, var index = -1,
length = path.length, length = path.length,
@@ -4357,9 +4351,8 @@
* @returns {boolean} Returns `true` if the property is deleted, else `false`. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/ */
function baseUnset(object, path) { function baseUnset(object, path) {
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
object = parent(object, path); object = parent(object, path);
var key = toKey(last(path)); var key = toKey(last(path));
return !(object != null && hasOwnProperty.call(object, key)) || delete object[key]; return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
} }
@@ -4501,10 +4494,14 @@
* *
* @private * @private
* @param {*} value The value to inspect. * @param {*} value The value to inspect.
* @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array. * @returns {Array} Returns the cast property path array.
*/ */
function castPath(value) { function castPath(value, object) {
return isArray(value) ? value : stringToPath(value); 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`. * @returns {boolean} Returns `true` if `path` exists, else `false`.
*/ */
function hasPath(object, path, hasFunc) { function hasPath(object, path, hasFunc) {
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
var index = -1, var index = -1,
length = path.length, length = path.length,
@@ -6606,7 +6603,7 @@
* @returns {*} Returns the parent value. * @returns {*} Returns the parent value.
*/ */
function parent(object, path) { 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. * @returns {Array} Returns the property path array.
*/ */
var stringToPath = memoizeCapped(function(string) { var stringToPath = memoizeCapped(function(string) {
string = toString(string);
var result = []; var result = [];
if (reLeadingDot.test(string)) { if (reLeadingDot.test(string)) {
result.push(''); result.push('');
@@ -9482,12 +9477,10 @@
var invokeMap = baseRest(function(collection, path, args) { var invokeMap = baseRest(function(collection, path, args) {
var index = -1, var index = -1,
isFunc = typeof path == 'function', isFunc = typeof path == 'function',
isProp = isKey(path),
result = isArrayLike(collection) ? Array(collection.length) : []; result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value) { baseEach(collection, function(value) {
var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined); result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args);
}); });
return result; return result;
}); });
@@ -13478,8 +13471,15 @@
if (object == null) { if (object == null) {
return result; 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); 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; var length = paths.length;
while (length--) { while (length--) {
@@ -13530,7 +13530,7 @@
* // => { 'a': 1, 'c': 3 } * // => { 'a': 1, 'c': 3 }
*/ */
var pick = flatRest(function(object, paths) { 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 } * // => { 'a': 1, 'c': 3 }
*/ */
function pickBy(object, predicate) { 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' * // => 'default'
*/ */
function result(object, path, defaultValue) { function result(object, path, defaultValue) {
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
var index = -1, var index = -1,
length = path.length; length = path.length;
@@ -16103,7 +16112,7 @@
if (isArray(value)) { if (isArray(value)) {
return arrayMap(value, toKey); 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. */ /** Used to compose bitmasks for cloning. */
var CLONE_DEEP_FLAG = 1, var CLONE_DEEP_FLAG = 1,
@@ -30,8 +30,15 @@ define(['./_baseClone', './_baseUnset', './_copyObject', './_flatRest', './_getA
if (object == null) { if (object == null) {
return result; 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); 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; var length = paths.length;
while (length--) { while (length--) {

View File

@@ -1,6 +1,6 @@
{ {
"name": "lodash-amd", "name": "lodash-amd",
"version": "4.17.0", "version": "4.17.1",
"description": "Lodash exported as AMD modules.", "description": "Lodash exported as AMD modules.",
"keywords": "amd, modules, stdlib, util", "keywords": "amd, modules, stdlib, util",
"homepage": "https://lodash.com/custom-builds", "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. * Creates an object composed of the picked `object` properties.
@@ -18,7 +18,7 @@ define(['./_arrayMap', './_basePick', './_flatRest', './_toKey'], function(array
* // => { 'a': 1, 'c': 3 } * // => { 'a': 1, 'c': 3 }
*/ */
var pick = flatRest(function(object, paths) { var pick = flatRest(function(object, paths) {
return object == null ? {} : basePick(object, arrayMap(paths, toKey)); return object == null ? {} : basePick(object, paths);
}); });
return pick; 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 * Creates an object composed of the `object` properties `predicate` returns
@@ -19,7 +19,16 @@ define(['./_baseIteratee', './_basePickBy', './_getAllKeysIn'], function(baseIte
* // => { 'a': 1, 'c': 3 } * // => { 'a': 1, 'c': 3 }
*/ */
function pickBy(object, predicate) { 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; 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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -33,7 +33,7 @@ define(['./_castPath', './isFunction', './_isKey', './_toKey'], function(castPat
* // => 'default' * // => 'default'
*/ */
function result(object, path, defaultValue) { function result(object, path, defaultValue) {
path = isKey(path, object) ? [path] : castPath(path); path = castPath(path, object);
var index = -1, var index = -1,
length = path.length; 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. * Converts `value` to a property path array.
@@ -21,7 +21,7 @@ define(['./_arrayMap', './_copyArray', './isArray', './isSymbol', './_stringToPa
if (isArray(value)) { if (isArray(value)) {
return arrayMap(value, toKey); return arrayMap(value, toKey);
} }
return isSymbol(value) ? [value] : copyArray(stringToPath(value)); return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
} }
return toPath; return toPath;