A pairwise version could be as simple as:
```
trapz(y::AbstractArray, dx::Number) = length(y) <= 2 ? mean(y)*dx : (sum(y) - 0.5*(y[1]+y[end]))*dx
```