lodash.findkey
Advanced tools
Comparing version 3.0.0 to 3.0.1
52
index.js
/** | ||
* lodash 3.0.0 (Custom Build) <https://lodash.com/> | ||
* lodash 3.0.1 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> | ||
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
@@ -28,9 +28,27 @@ * Available under MIT license <https://lodash.com/license> | ||
/** | ||
* This method is like `_.findIndex` except that it returns the key of the | ||
* first element `predicate` returns truthy for, instead of the element itself. | ||
* Creates a `_.findKey` or `_.findLastKey` function. | ||
* | ||
* If a property name is provided for `predicate` the created "_.property" | ||
* @private | ||
* @param {Function} objectFunc The function to iterate over an object. | ||
* @returns {Function} Returns the new find function. | ||
*/ | ||
function createFindKey(objectFunc) { | ||
return function(object, predicate, thisArg) { | ||
predicate = baseCallback(predicate, thisArg, 3); | ||
return baseFind(object, predicate, objectFunc, true); | ||
}; | ||
} | ||
/** | ||
* This method is like `_.find` except that it returns the key of the first | ||
* element `predicate` returns truthy for instead of the element itself. | ||
* | ||
* If a property name is provided for `predicate` the created `_.property` | ||
* style callback returns the property value of the given element. | ||
* | ||
* If an object is provided for `predicate` the created "_.matches" style | ||
* If a value is also provided for `thisArg` the created `_.matchesProperty` | ||
* style callback returns `true` for elements that have a matching property | ||
* value, else `false`. | ||
* | ||
* If an object is provided for `predicate` the created `_.matches` style | ||
* callback returns `true` for elements that have the properties of the given | ||
@@ -44,4 +62,3 @@ * object, else `false`. | ||
* @param {Function|Object|string} [predicate=_.identity] The function invoked | ||
* per iteration. If a property name or object is provided it is used to | ||
* create a "_.property" or "_.matches" style callback respectively. | ||
* per iteration. | ||
* @param {*} [thisArg] The `this` binding of `predicate`. | ||
@@ -57,18 +74,21 @@ * @returns {string|undefined} Returns the key of the matched element, else `undefined`. | ||
* | ||
* _.findKey(users, function(chr) { return chr.age < 40; }); | ||
* _.findKey(users, function(chr) { | ||
* return chr.age < 40; | ||
* }); | ||
* // => 'barney' (iteration order is not guaranteed) | ||
* | ||
* // using the "_.matches" callback shorthand | ||
* _.findKey(users, { 'age': 1 }); | ||
* // using the `_.matches` callback shorthand | ||
* _.findKey(users, { 'age': 1, 'active': true }); | ||
* // => 'pebbles' | ||
* | ||
* // using the "_.property" callback shorthand | ||
* // using the `_.matchesProperty` callback shorthand | ||
* _.findKey(users, 'active', false); | ||
* // => 'fred' | ||
* | ||
* // using the `_.property` callback shorthand | ||
* _.findKey(users, 'active'); | ||
* // => 'barney' | ||
*/ | ||
function findKey(object, predicate, thisArg) { | ||
predicate = baseCallback(predicate, thisArg, 3); | ||
return baseFind(object, predicate, baseForOwn, true); | ||
} | ||
var findKey = createFindKey(baseForOwn); | ||
module.exports = findKey; |
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, | ||
Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
@@ -4,0 +4,0 @@ |
{ | ||
"name": "lodash.findkey", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "The modern build of lodash’s `_.findKey` as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.findkey v3.0.0 | ||
# lodash.findkey v3.0.1 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.findKey` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#findKey) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.findkey) for more details. | ||
See the [documentation](https://lodash.com/docs#findKey) or [package source](https://github.com/lodash/lodash/blob/3.0.1-npm-packages/lodash.findkey) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5921
87