n-dimensional convolutions in JavaScript