Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify filter function

  • Loading branch information...
commit 8990b0692b487a9ab40537c01cb50e21d7945e87 1 parent 449066c
@kossnocorp authored
Showing with 7 additions and 10 deletions.
  1. +7 −10 src/gtl.coffee
View
17 src/gtl.coffee
@@ -132,20 +132,17 @@ class Gtl.Filter
constructor: ->
@comparators = new Gtl.StandartComparatorSet()
- filter: (array, rules, iterator) ->
+ filter: (array, rules, iterator = []) ->
result = clone(array)
- unless iterator
- iterator = []
+ if rules.or or rules.in
+ iterator.push(rule: 'or', iterator: rules.or || rules.in)
- if rules.or or rules.in
- iterator.push(rule: 'or', iterator: rules.or || rules.in)
+ if rules.and
+ iterator.push(rule: 'and', iterator: rules.and)
- if rules.and
- iterator.push(rule: 'and', iterator: rules.and)
-
- if iterator.length == 0
- iterator = (elm) -> elm
+ if iterator.length == 0
+ iterator = (elm) -> elm
for name, rule of rules
if ['or', 'in', 'and'].indexOf(name) == -1
Please sign in to comment.
Something went wrong with that request. Please try again.