lodash.callback
Advanced tools
+46
-2
| /** | ||
| * lodash 3.2.0 (Custom Build) <https://lodash.com/> | ||
| * lodash 3.3.0 (Custom Build) <https://lodash.com/> | ||
| * Build: `lodash modern modularize exports="npm" -o ./` | ||
@@ -10,5 +10,18 @@ * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
| var baseCallback = require('lodash._basecallback'), | ||
| baseClone = require('lodash._baseclone'), | ||
| baseMatches = require('lodash._basematches'), | ||
| isIterateeCall = require('lodash._isiterateecall'); | ||
| /** | ||
| * Checks if `value` is object-like. | ||
| * | ||
| * @private | ||
| * @param {*} value The value to check. | ||
| * @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
| */ | ||
| function isObjectLike(value) { | ||
| return !!value && typeof value == 'object'; | ||
| } | ||
| /** | ||
| * Creates a function that invokes `func` with the `this` binding of `thisArg` | ||
@@ -55,5 +68,36 @@ * and arguments of the created function. If `func` is a property name the | ||
| } | ||
| return baseCallback(func, thisArg); | ||
| return isObjectLike(func) | ||
| ? matches(func) | ||
| : baseCallback(func, thisArg); | ||
| } | ||
| /** | ||
| * Creates a function which performs a deep comparison between a given object | ||
| * and `source`, returning `true` if the given object has equivalent property | ||
| * values, else `false`. | ||
| * | ||
| * **Note:** This method supports comparing arrays, booleans, `Date` objects, | ||
| * numbers, `Object` objects, regexes, and strings. Objects are compared by | ||
| * their own, not inherited, enumerable properties. For comparing a single | ||
| * own or inherited property value see `_.matchesProperty`. | ||
| * | ||
| * @static | ||
| * @memberOf _ | ||
| * @category Utility | ||
| * @param {Object} source The object of property values to match. | ||
| * @returns {Function} Returns the new function. | ||
| * @example | ||
| * | ||
| * var users = [ | ||
| * { 'user': 'barney', 'age': 36, 'active': true }, | ||
| * { 'user': 'fred', 'age': 40, 'active': false } | ||
| * ]; | ||
| * | ||
| * _.filter(users, _.matches({ 'age': 40, 'active': false })); | ||
| * // => [{ 'user': 'fred', 'age': 40, 'active': false }] | ||
| */ | ||
| function matches(source) { | ||
| return baseMatches(baseClone(source, true)); | ||
| } | ||
| module.exports = callback; |
+3
-1
| { | ||
| "name": "lodash.callback", | ||
| "version": "3.2.0", | ||
| "version": "3.3.0", | ||
| "description": "The modern build of lodash’s `_.callback` as a module.", | ||
@@ -21,4 +21,6 @@ "homepage": "https://lodash.com/", | ||
| "lodash._basecallback": "^3.0.0", | ||
| "lodash._baseclone": "^3.0.0", | ||
| "lodash._basematches": "^3.0.0", | ||
| "lodash._isiterateecall": "^3.0.0" | ||
| } | ||
| } |
+2
-2
@@ -1,2 +0,2 @@ | ||
| # lodash.callback v3.2.0 | ||
| # lodash.callback v3.3.0 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.callback` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
| See the [documentation](https://lodash.com/docs#callback) or [package source](https://github.com/lodash/lodash/blob/3.2.0-npm-packages/lodash.callback) for more details. | ||
| See the [documentation](https://lodash.com/docs#callback) or [package source](https://github.com/lodash/lodash/blob/3.3.0-npm-packages/lodash.callback) for more details. |
6262
30.51%97
76.36%4
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added