Skip to content

Commit

Permalink
fix: implement alternative way to pass array values
Browse files Browse the repository at this point in the history
  • Loading branch information
IamSebastianDev committed Nov 27, 2022
1 parent 2c27375 commit 3b23b97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/Evaluators/In.evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { isNonNull } from '../../utils';
* @returns { EvaluatorFunction }
*/

export const In = (condition: Array<unknown>): EvaluatorFunction => {
export const In = (...condition: Array<unknown>): EvaluatorFunction => {
return (value: unknown, propName?: string) => {
if (!isNonNull(value)) {
throw new TypeError(`[Query] Property ${propName} is null or undefined.`);
}

return condition.findIndex((e) => e == value) !== -1;
return [...condition].flat().findIndex((e) => e == value) !== -1;
};
};

0 comments on commit 3b23b97

Please sign in to comment.