|
9183 | 9183 | * // The `_.property` iteratee shorthand.
|
9184 | 9184 | * _.filter(users, 'active');
|
9185 | 9185 | * // => objects for ['barney']
|
| 9186 | + * |
| 9187 | + * // Combining several predicates using `_.overEvery` or `_.overSome`. |
| 9188 | + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); |
| 9189 | + * // => objects for ['fred', 'barney'] |
9186 | 9190 | */
|
9187 | 9191 | function filter(collection, predicate) {
|
9188 | 9192 | var func = isArray(collection) ? arrayFilter : baseFilter;
|
|
15560 | 15564 | * values against any array or object value, respectively. See `_.isEqual`
|
15561 | 15565 | * for a list of supported value comparisons.
|
15562 | 15566 | *
|
| 15567 | + * **Note:** Multiple values can be checked by combining several matchers |
| 15568 | + * using `_.overSome` |
| 15569 | + * |
15563 | 15570 | * @static
|
15564 | 15571 | * @memberOf _
|
15565 | 15572 | * @since 3.0.0
|
|
15575 | 15582 | *
|
15576 | 15583 | * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
|
15577 | 15584 | * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
|
| 15585 | + * |
| 15586 | + * // Checking for several possible values |
| 15587 | + * _.filter(users, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); |
| 15588 | + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] |
15578 | 15589 | */
|
15579 | 15590 | function matches(source) {
|
15580 | 15591 | return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
|
|
15589 | 15600 | * `srcValue` values against any array or object value, respectively. See
|
15590 | 15601 | * `_.isEqual` for a list of supported value comparisons.
|
15591 | 15602 | *
|
| 15603 | + * **Note:** Multiple values can be checked by combining several matchers |
| 15604 | + * using `_.overSome` |
| 15605 | + * |
15592 | 15606 | * @static
|
15593 | 15607 | * @memberOf _
|
15594 | 15608 | * @since 3.2.0
|
|
15605 | 15619 | *
|
15606 | 15620 | * _.find(objects, _.matchesProperty('a', 4));
|
15607 | 15621 | * // => { 'a': 4, 'b': 5, 'c': 6 }
|
| 15622 | + * |
| 15623 | + * // Checking for several possible values |
| 15624 | + * _.filter(users, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); |
| 15625 | + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] |
15608 | 15626 | */
|
15609 | 15627 | function matchesProperty(path, srcValue) {
|
15610 | 15628 | return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
|
|
15828 | 15846 | * Creates a function that checks if **all** of the `predicates` return
|
15829 | 15847 | * truthy when invoked with the arguments it receives.
|
15830 | 15848 | *
|
| 15849 | + * Following shorthands are possible for providing predicates. |
| 15850 | + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. |
| 15851 | + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. |
| 15852 | + * |
15831 | 15853 | * @static
|
15832 | 15854 | * @memberOf _
|
15833 | 15855 | * @since 4.0.0
|
|
15854 | 15876 | * Creates a function that checks if **any** of the `predicates` return
|
15855 | 15877 | * truthy when invoked with the arguments it receives.
|
15856 | 15878 | *
|
| 15879 | + * Following shorthands are possible for providing predicates. |
| 15880 | + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. |
| 15881 | + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. |
| 15882 | + * |
15857 | 15883 | * @static
|
15858 | 15884 | * @memberOf _
|
15859 | 15885 | * @since 4.0.0
|
|
15873 | 15899 | *
|
15874 | 15900 | * func(NaN);
|
15875 | 15901 | * // => false
|
| 15902 | + * |
| 15903 | + * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) |
| 15904 | + * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) |
15876 | 15905 | */
|
15877 | 15906 | var overSome = createOver(arraySome);
|
15878 | 15907 |
|
|
0 commit comments