|
13 | 13 | var undefined;
|
14 | 14 |
|
15 | 15 | /** Used as the semantic version number. */
|
16 |
| - var VERSION = '4.17.15'; |
| 16 | + var VERSION = '4.17.20'; |
17 | 17 |
|
18 | 18 | /** Error message constants. */
|
19 | 19 | var FUNC_ERROR_TEXT = 'Expected a function';
|
|
1183 | 1183 | if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
1184 | 1184 | return false;
|
1185 | 1185 | }
|
| 1186 | + // Check that cyclic values are equal. |
| 1187 | + var arrStacked = stack.get(array); |
| 1188 | + var othStacked = stack.get(other); |
| 1189 | + if (arrStacked && othStacked) { |
| 1190 | + return arrStacked == other && othStacked == array; |
| 1191 | + } |
1186 | 1192 | var index = -1,
|
1187 | 1193 | result = true,
|
1188 | 1194 | seen = (bitmask & COMPARE_UNORDERED_FLAG) ? [] : undefined;
|
|
1293 | 1299 | return false;
|
1294 | 1300 | }
|
1295 | 1301 | }
|
| 1302 | + // Check that cyclic values are equal. |
| 1303 | + var objStacked = stack.get(object); |
| 1304 | + var othStacked = stack.get(other); |
| 1305 | + if (objStacked && othStacked) { |
| 1306 | + return objStacked == other && othStacked == object; |
| 1307 | + } |
1296 | 1308 | var result = true;
|
1297 | 1309 |
|
1298 | 1310 | var skipCtor = isPartial;
|
|
1935 | 1947 | * // The `_.property` iteratee shorthand.
|
1936 | 1948 | * _.filter(users, 'active');
|
1937 | 1949 | * // => objects for ['barney']
|
| 1950 | + * |
| 1951 | + * // Combining several predicates using `_.overEvery` or `_.overSome`. |
| 1952 | + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); |
| 1953 | + * // => objects for ['fred', 'barney'] |
1938 | 1954 | */
|
1939 | 1955 | function filter(collection, predicate) {
|
1940 | 1956 | return baseFilter(collection, baseIteratee(predicate));
|
|
2188 | 2204 | * var users = [
|
2189 | 2205 | * { 'user': 'fred', 'age': 48 },
|
2190 | 2206 | * { 'user': 'barney', 'age': 36 },
|
2191 |
| - * { 'user': 'fred', 'age': 40 }, |
| 2207 | + * { 'user': 'fred', 'age': 30 }, |
2192 | 2208 | * { 'user': 'barney', 'age': 34 }
|
2193 | 2209 | * ];
|
2194 | 2210 | *
|
2195 | 2211 | * _.sortBy(users, [function(o) { return o.user; }]);
|
2196 |
| - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] |
| 2212 | + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] |
2197 | 2213 | *
|
2198 | 2214 | * _.sortBy(users, ['user', 'age']);
|
2199 |
| - * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] |
| 2215 | + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] |
2200 | 2216 | */
|
2201 | 2217 | function sortBy(collection, iteratee) {
|
2202 | 2218 | var index = 0;
|
|
3503 | 3519 | * values against any array or object value, respectively. See `_.isEqual`
|
3504 | 3520 | * for a list of supported value comparisons.
|
3505 | 3521 | *
|
| 3522 | + * **Note:** Multiple values can be checked by combining several matchers |
| 3523 | + * using `_.overSome` |
| 3524 | + * |
3506 | 3525 | * @static
|
3507 | 3526 | * @memberOf _
|
3508 | 3527 | * @since 3.0.0
|
|
3518 | 3537 | *
|
3519 | 3538 | * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
|
3520 | 3539 | * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
|
| 3540 | + * |
| 3541 | + * // Checking for several possible values |
| 3542 | + * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); |
| 3543 | + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] |
3521 | 3544 | */
|
3522 | 3545 | function matches(source) {
|
3523 | 3546 | return baseMatches(assign({}, source));
|
|
0 commit comments