deleteman / vatican

Micro-framework designed to create REST APIs with minor effort
98 stars 6 forks source link

ProcessingChaining next function #15

Open smart--petea opened 10 years ago

smart--petea commented 10 years ago

The expression

(chain[idx].names && chain[idx].names.indexOf(handler.name) != -1) || !chain[idx].names

is equivalent to

 !chain[idx].names ||  ~chain[idx].names.indexOf(handler.name)
smart--petea commented 10 years ago

if user will add to processingChaing a proc like

{
  fn: function(){},
  name: [],
}

with name=[] then the expression

!chain[idx].names ||  ~chain[idx].names.indexOf(handler.name)

will be false. If to judge that name=[] should match the case of general use then the expression from above must be true. Maybe to check that name are empty array. We obtain

!chain[idx].names || !chain[idx].names.length ||  ~chain[idx].names.indexOf(handler.name)