-
Notifications
You must be signed in to change notification settings - Fork 283
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
[PORT]Add 'any' and 'all' prebuilt function #3325
Conversation
Pull Request Test Coverage Report for Build 580038351
💛 - Coveralls |
@@ -420,7 +420,6 @@ const badExpressions = [ | |||
['where(items, item, item2, item3)', 'should have three parameters'], | |||
['where(items, add(1), item)', 'Second paramter of where is not an identifier'], | |||
['where(items, 1, item)', 'Second paramter error'], | |||
['where(items, x, sum(x))', 'third paramter error'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently SDK would treat the "error item" in Where
iteration as a "false" result and drop it to avoid too much errors.
So where(items, x, sum(x))
is valid, but empty array would be returned.
* @param list item list. | ||
* @param callback call back. return the should break flag. | ||
*/ | ||
public static lambdaEvaluator<T = unknown, U = unknown>(expression: Expression, state: MemoryInterface, options: Options, list: T[], callback: (currentItem: T, result: U, error: string) => boolean): void{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Fixes #3303
Description
Add
any
andall
prebuilt function for Collections.Examples
any(createArray(1, 'cool'), item, isInteger(item))
->true
any(createArray('first', 'cool'), item => isInteger(item))
->false
all(createArray(1, 'cool'), item, isInteger(item))
->false
all(createArray(1, 2), item => isInteger(item))
->true