Should AND and OR operators support 0 or more arguments (instead of 2 or more)
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.9k
- Forks
- 266
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 55
Description
It makes sense to turn the and and or operators into vararg functions. That would simplify their usage, as shown by this code snippet from this issue:
let conditions = [];
for (const key of filters) {
conditions.push(eq(product.id, key));
}
return or(...conditions);
This is currently not possible because or expects exactly two arguments. This should be the behavior of or:
- if 0 arguments provided: evaluates to
true - if 1 predicate provided: returns that predicate
- if 2 predicates provided:
ors them together - if 3 or more predicates provided: nested
ors
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names the TypeScript and and or operators but no files or tests. First locate their definitions and existing operator tests, then verify the requested zero-, one-, two-, and three-plus-predicate cases; clarify the corresponding behavior for and before treating the work as complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100