-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filter/select by property #120
Comments
I think a |
If you add it, I'd suggest changing the order of your parameters so that your 'where' properties are the first param, and your data param is second; and also, curry it. This would let you do something like: $selectByLars = selectByProperty(['name' => 'Lars']);
$larsPeople = $selectByLars($people); OR $notEmpty = function($x) { return !is_empty($x); };
$haveLars = compose(
$notEmpty,
selectByProperty(['name' => 'Lars'])
);
if($haveLars($people)) { ... } |
Switching the argument order would be inconsistent with the other functions. The same for currying by default: none of the other functions do this. You can still use a curry function. |
Closing because of inactivity |
much less verbose than:
It could work with multiple properties too, plus nesting. Like graphQL.
The name, alternatively, could be 'where'.
Good idea?
Ive created an implementation here: https://github.com/Erikvv/array-utils-php/blob/master/src/Ve/Where.php
It's a bit too large to be contained in one function.
The text was updated successfully, but these errors were encountered: