lodash._baseiteratee
Advanced tools
Comparing version 4.6.0 to 4.6.1
147
index.js
/** | ||
* lodash 4.6.0 (Custom Build) <https://lodash.com/> | ||
* lodash 4.6.1 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -58,3 +58,6 @@ * Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
/** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */ | ||
/** | ||
* Used to match `RegExp` | ||
* [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). | ||
*/ | ||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; | ||
@@ -287,3 +290,4 @@ | ||
/** | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -318,7 +322,7 @@ */ | ||
/** Used to detect maps, sets, and weakmaps. */ | ||
var dataViewCtorString = DataView ? (DataView + '') : '', | ||
mapCtorString = Map ? funcToString.call(Map) : '', | ||
promiseCtorString = Promise ? funcToString.call(Promise) : '', | ||
setCtorString = Set ? funcToString.call(Set) : '', | ||
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : ''; | ||
var dataViewCtorString = toSource(DataView), | ||
mapCtorString = toSource(Map), | ||
promiseCtorString = toSource(Promise), | ||
setCtorString = toSource(Set), | ||
weakMapCtorString = toSource(WeakMap); | ||
@@ -330,3 +334,3 @@ /** Used to convert symbols to primitives and strings. */ | ||
/** | ||
* Creates an hash object. | ||
* Creates a hash object. | ||
* | ||
@@ -944,12 +948,3 @@ * @private | ||
if (matchData.length == 1 && matchData[0][2]) { | ||
var key = matchData[0][0], | ||
value = matchData[0][1]; | ||
return function(object) { | ||
if (object == null) { | ||
return false; | ||
} | ||
return object[key] === value && | ||
(value !== undefined || (key in Object(object))); | ||
}; | ||
return matchesStrictComparable(matchData[0][0], matchData[0][1]); | ||
} | ||
@@ -970,2 +965,5 @@ return function(object) { | ||
function baseMatchesProperty(path, srcValue) { | ||
if (isKey(path) && isStrictComparable(srcValue)) { | ||
return matchesStrictComparable(path, srcValue); | ||
} | ||
return function(object) { | ||
@@ -1127,3 +1125,4 @@ var objValue = get(object, path); | ||
// Coerce regexes to strings and treat strings, primitives and objects, | ||
// as equal. See https://es5.github.io/#x15.10.6.4 for more details. | ||
// as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring | ||
// for more details. | ||
return object == (other + ''); | ||
@@ -1310,4 +1309,4 @@ | ||
var result = objectToString.call(value), | ||
Ctor = result == objectTag ? value.constructor : null, | ||
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : ''; | ||
Ctor = result == objectTag ? value.constructor : undefined, | ||
ctorString = Ctor ? toSource(Ctor) : undefined; | ||
@@ -1337,25 +1336,21 @@ if (ctorString) { | ||
function hasPath(object, path, hasFunc) { | ||
if (object == null) { | ||
return false; | ||
} | ||
var result = hasFunc(object, path); | ||
if (!result && !isKey(path)) { | ||
path = baseCastPath(path); | ||
path = isKey(path, object) ? [path] : baseCastPath(path); | ||
var index = -1, | ||
length = path.length; | ||
var result, | ||
index = -1, | ||
length = path.length; | ||
while (object != null && ++index < length) { | ||
var key = path[index]; | ||
if (!(result = hasFunc(object, key))) { | ||
break; | ||
} | ||
object = object[key]; | ||
while (++index < length) { | ||
var key = path[index]; | ||
if (!(result = object != null && hasFunc(object, key))) { | ||
break; | ||
} | ||
object = object[key]; | ||
} | ||
var length = object ? object.length : undefined; | ||
return result || ( | ||
!!length && isLength(length) && isIndex(path, length) && | ||
(isArray(object) || isString(object) || isArguments(object)) | ||
); | ||
if (result) { | ||
return result; | ||
} | ||
var length = object ? object.length : 0; | ||
return !!length && isLength(length) && isIndex(key, length) && | ||
(isArray(object) || isString(object) || isArguments(object)); | ||
} | ||
@@ -1438,2 +1433,40 @@ | ||
/** | ||
* A specialized version of `matchesProperty` for source values suitable | ||
* for strict equality comparisons, i.e. `===`. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @param {*} srcValue The value to match. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function matchesStrictComparable(key, srcValue) { | ||
return function(object) { | ||
if (object == null) { | ||
return false; | ||
} | ||
return object[key] === srcValue && | ||
(srcValue !== undefined || (key in Object(object))); | ||
}; | ||
} | ||
/** | ||
* Converts `func` to its source code. | ||
* | ||
* @private | ||
* @param {Function} func The function to process. | ||
* @returns {string} Returns the source code. | ||
*/ | ||
function toSource(func) { | ||
if (func != null) { | ||
try { | ||
return funcToString.call(func); | ||
} catch (e) {} | ||
try { | ||
return (func + ''); | ||
} catch (e) {} | ||
} | ||
return ''; | ||
} | ||
/** | ||
* Performs a | ||
@@ -1642,4 +1675,5 @@ * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
/** | ||
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. | ||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* Checks if `value` is the | ||
* [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) | ||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
@@ -1718,10 +1752,7 @@ * @static | ||
function isNative(value) { | ||
if (value == null) { | ||
if (!isObject(value)) { | ||
return false; | ||
} | ||
if (isFunction(value)) { | ||
return reIsNative.test(funcToString.call(value)); | ||
} | ||
return isObjectLike(value) && | ||
(isHostObject(value) ? reIsNative : reIsHostCtor).test(value); | ||
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; | ||
return pattern.test(toSource(value)); | ||
} | ||
@@ -1800,3 +1831,3 @@ | ||
* Gets the value at `path` of `object`. If the resolved value is | ||
* `undefined` the `defaultValue` is used in its place. | ||
* `undefined`, the `defaultValue` is used in its place. | ||
* | ||
@@ -1841,3 +1872,3 @@ * @static | ||
* | ||
* var object = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) }); | ||
* var object = _.create({ 'a': _.create({ 'b': 2 }) }); | ||
* | ||
@@ -1847,6 +1878,6 @@ * _.hasIn(object, 'a'); | ||
* | ||
* _.hasIn(object, 'a.b.c'); | ||
* _.hasIn(object, 'a.b'); | ||
* // => true | ||
* | ||
* _.hasIn(object, ['a', 'b', 'c']); | ||
* _.hasIn(object, ['a', 'b']); | ||
* // => true | ||
@@ -1858,3 +1889,3 @@ * | ||
function hasIn(object, path) { | ||
return hasPath(object, path, baseHasIn); | ||
return object != null && hasPath(object, path, baseHasIn); | ||
} | ||
@@ -1969,10 +2000,10 @@ | ||
* var objects = [ | ||
* { 'a': { 'b': { 'c': 2 } } }, | ||
* { 'a': { 'b': { 'c': 1 } } } | ||
* { 'a': { 'b': 2 } }, | ||
* { 'a': { 'b': 1 } } | ||
* ]; | ||
* | ||
* _.map(objects, _.property('a.b.c')); | ||
* _.map(objects, _.property('a.b')); | ||
* // => [2, 1] | ||
* | ||
* _.map(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); | ||
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); | ||
* // => [1, 2] | ||
@@ -1979,0 +2010,0 @@ */ |
{ | ||
"name": "lodash._baseiteratee", | ||
"version": "4.6.0", | ||
"version": "4.6.1", | ||
"description": "The internal lodash function `baseIteratee` exported as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash._baseiteratee v4.6.0 | ||
# lodash._baseiteratee v4.6.1 | ||
@@ -18,2 +18,2 @@ The internal [lodash](https://lodash.com/) function `baseIteratee` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [package source](https://github.com/lodash/lodash/blob/4.6.0-npm-packages/lodash._baseiteratee) for more details. | ||
See the [package source](https://github.com/lodash/lodash/blob/4.6.1-npm-packages/lodash._baseiteratee) for more details. |
57357
1843