Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.find

Package Overview
Dependencies
Maintainers
5
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.find - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

69

index.js
/**
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
* lodash 3.1.0 (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

@@ -12,14 +12,37 @@ * Available under MIT license <https://lodash.com/license>

baseFind = require('lodash._basefind'),
findIndex = require('lodash.findindex'),
baseFindIndex = require('lodash._basefindindex'),
isArray = require('lodash.isarray');
/**
* Creates a `_.find` or `_.findLast` function.
*
* @private
* @param {Function} eachFunc The function to iterate over a collection.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new find function.
*/
function createFind(eachFunc, fromRight) {
return function(collection, predicate, thisArg) {
predicate = baseCallback(predicate, thisArg, 3);
if (isArray(collection)) {
var index = baseFindIndex(collection, predicate, fromRight);
return index > -1 ? collection[index] : undefined;
}
return baseFind(collection, predicate, eachFunc);
}
}
/**
* Iterates over elements of `collection`, returning the first element
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
* invoked with three arguments; (value, index|key, collection).
* invoked with three arguments: (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* 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

@@ -34,4 +57,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`.

@@ -42,27 +64,26 @@ * @returns {*} Returns the matched element, else `undefined`.

* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true },
* { 'user': 'pebbles', 'age': 1, 'active': false }
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false },
* { 'user': 'pebbles', 'age': 1, 'active': true }
* ];
*
* _.result(_.find(users, function(chr) { return chr.age < 40; }), 'user');
* _.result(_.find(users, function(chr) {
* return chr.age < 40;
* }), 'user');
* // => 'barney'
*
* // using the "_.matches" callback shorthand
* _.result(_.find(users, { 'age': 1 }), 'user');
* // using the `_.matches` callback shorthand
* _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
* // => 'pebbles'
*
* // using the "_.property" callback shorthand
* // using the `_.matchesProperty` callback shorthand
* _.result(_.find(users, 'active', false), 'user');
* // => 'fred'
*
* // using the `_.property` callback shorthand
* _.result(_.find(users, 'active'), 'user');
* // => 'fred'
* // => 'barney'
*/
function find(collection, predicate, thisArg) {
if (isArray(collection)) {
var index = findIndex(collection, predicate, thisArg);
return index > -1 ? collection[index] : undefined;
}
predicate = baseCallback(predicate, thisArg, 3);
return baseFind(collection, predicate, baseEach);
}
var find = createFind(baseEach);
module.exports = find;
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.find",
"version": "3.0.0",
"version": "3.1.0",
"description": "The modern build of lodash’s `_.find` as a module.",

@@ -23,5 +23,5 @@ "homepage": "https://lodash.com/",

"lodash._basefind": "^3.0.0",
"lodash.findindex": "^3.0.0",
"lodash._basefindindex": "^3.0.0",
"lodash.isarray": "^3.0.0"
}
}

@@ -1,2 +0,2 @@

# lodash.find v3.0.0
# lodash.find v3.1.0

@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.find` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module.

See the [documentation](https://lodash.com/docs#find) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.find) for more details.
See the [documentation](https://lodash.com/docs#find) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.find) for more details.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc