'use strict' module.exports = normalize; function normalize (arr, dim) { if (!arr || arr.length == null) throw Error('Argument should be an array') if (dim == null) dim = 1 else dim = Math.floor(dim) var bounds = Array(dim * 2) for (var offset = 0; offset < dim; offset++) { var max = -Infinity, min = Infinity, i = offset, l = arr.length; for (; i < l; i+=dim) { if (arr[i] > max) max = arr[i]; if (arr[i] < min) min = arr[i]; } bounds[offset] = min bounds[dim + offset] = max } return bounds; }