Skip to content
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

Merged
merged 4 commits into from
Feb 19, 2021
Merged

Conversation

Danieladu
Copy link
Contributor

Fixes #3303

Description

Add any and all 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

@coveralls
Copy link

coveralls commented Feb 18, 2021

Pull Request Test Coverage Report for Build 580038351

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 13 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.04%) to 84.831%

Files with Coverage Reduction New Missed Lines %
libraries/adaptive-expressions/src/functionUtils.internal.ts 3 95.78%
libraries/adaptive-expressions/src/triggerTrees/node.ts 10 90.51%
Totals Coverage Status
Change from base Build 579638704: -0.04%
Covered Lines: 18579
Relevant Lines: 20882

💛 - 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'],
Copy link
Contributor

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?

Copy link
Contributor Author

@Danieladu Danieladu Feb 19, 2021

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.

libraries/adaptive-expressions/src/builtinFunctions/any.ts Outdated Show resolved Hide resolved
* @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{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@Danieladu Danieladu merged commit 8eb69cd into main Feb 19, 2021
@Danieladu Danieladu deleted the hond/any-all-function branch February 19, 2021 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

port: Add 'any' and 'all' prebuilt function (#5155)
3 participants