mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
Add fast path for objects with a single primitive value back to _.matches and add isStrictComparable helper to reduce _.matches and _.isEqual.
This commit is contained in:
18
test/test.js
18
test/test.js
@@ -6721,24 +6721,24 @@
|
||||
strictEqual(matches(otherObject), false);
|
||||
});
|
||||
|
||||
test('should not change match behavior if `source` is augmented', 6, function() {
|
||||
_.each([{ 'a': 1, 'b': 2 }, { 'a': { 'b': 2, 'c': 3 } }], function(source, index) {
|
||||
test('should not change match behavior if `source` is augmented', 9, function() {
|
||||
_.each([{ 'a': { 'b': 2, 'c': 3 } }, { 'a': 1, 'b': 2 }, { 'a': 1 }], function(source, index) {
|
||||
var object = _.cloneDeep(source),
|
||||
matches = _.matches(source);
|
||||
|
||||
strictEqual(matches(object), true, 'a' + index);
|
||||
strictEqual(matches(object), true);
|
||||
|
||||
if (index) {
|
||||
source.a.b = 1;
|
||||
source.a.c = 2;
|
||||
source.a.d = 3;
|
||||
} else {
|
||||
source.a = 2;
|
||||
source.b = 1;
|
||||
source.c = 3;
|
||||
} else {
|
||||
source.a.b = 1;
|
||||
source.a.c = 2;
|
||||
source.a.d = 3;
|
||||
}
|
||||
strictEqual(matches(object), true, 'b' + index);
|
||||
strictEqual(matches(source), false, 'c' + index);
|
||||
strictEqual(matches(object), true);
|
||||
strictEqual(matches(source), false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user