mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Should ensure callback is a function in _.isEqual.
Former-commit-id: b53f8e0ab1bafff395ff19cd069940ba6c37eb5f
This commit is contained in:
@@ -1550,11 +1550,8 @@
|
|||||||
function isEqual(a, b, callback, thisArg, stackA, stackB) {
|
function isEqual(a, b, callback, thisArg, stackA, stackB) {
|
||||||
// used to indicate that when comparing objects, `a` has at least the properties of `b`
|
// used to indicate that when comparing objects, `a` has at least the properties of `b`
|
||||||
var whereIndicator = callback === indicatorObject;
|
var whereIndicator = callback === indicatorObject;
|
||||||
if (callback && !whereIndicator) {
|
if (typeof callback == 'function' && !whereIndicator) {
|
||||||
callback = (typeof thisArg == 'undefined')
|
callback = lodash.createCallback(callback, thisArg, 2);
|
||||||
? callback
|
|
||||||
: lodash.createCallback(callback, thisArg, 2);
|
|
||||||
|
|
||||||
var result = callback(a, b);
|
var result = callback(a, b);
|
||||||
if (typeof result != 'undefined') {
|
if (typeof result != 'undefined') {
|
||||||
return !!result;
|
return !!result;
|
||||||
|
|||||||
@@ -1386,6 +1386,14 @@
|
|||||||
strictEqual(actual, false);
|
strictEqual(actual, false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should ensure `callback` is a function', function() {
|
||||||
|
var array = [1, 2, 3],
|
||||||
|
eq = _.partial(_.isEqual, array),
|
||||||
|
actual = _.every([array, [1, 0, 3]], eq);
|
||||||
|
|
||||||
|
strictEqual(actual, false);
|
||||||
|
})
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user