Skip to content

Commit

Permalink
Reduce code duplication for easier reading (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubamrein authored Aug 27, 2021
1 parent 54d3901 commit e59a317
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions Sources/jsonlogic/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -818,21 +818,13 @@ class Parser {
return Divide(arg: try self.parse(json: value))
case "%":
return Modulo(arg: try self.parse(json: value))
case ">":
case ">", "after":
return Comparison(arg: try self.parse(json: value), operation: >)
case "after":
return Comparison(arg: try self.parse(json: value), operation: >)
case "<":
return Comparison(arg: try self.parse(json: value), operation: <)
case "before":
case "<", "before":
return Comparison(arg: try self.parse(json: value), operation: <)
case ">=":
case ">=", "not-before":
return Comparison(arg: try self.parse(json: value), operation: >=)
case "not-before":
return Comparison(arg: try self.parse(json: value), operation: >=)
case "<=":
return Comparison(arg: try self.parse(json: value), operation: <=)
case "not-after":
case "<=", "not-after":
return Comparison(arg: try self.parse(json: value), operation: <=)
case "if", "?:":
guard let array = try self.parse(json: value) as? ArrayOfExpressions else {
Expand Down

0 comments on commit e59a317

Please sign in to comment.