function snapTo(value, values, tolerance) {
  tolerance = tolerance === undefined ? 10 : tolerance;

  var idx, snapValue;

  for (idx = 0; idx < values.length; idx++) {
    snapValue = values[idx];

    if (abs(snapValue - value) <= tolerance) {
      return snapValue;
    }
  }
}
Snap value to a collection of reference values.

@param {number} value
@param {Array<number>} values
@param {number} [tolerance=10]

@return {number} the value we snapped to or null, if none snapped