<commit_before>const getJSON = require('get-json');
const unique = require('array-unique');

/** URL of the Overpass API being used */
const overpass = 'http://overpass-api.de/api/interpreter?data=';

/**
 * Get all road names within a specified distance from a location.
 * @param {Number} lat - Latitude of centre location.
 * @param {Number} long - Longitude of centre location.
 * @param {Number} distance - Radius distance in metres.
 * @param {Function} callback - callback(err, data)
 * @returns {Array} - Array of road names, use callback.
 */
function fromLocation(lat, long, distance, callback) {
  const query = `[out:json]; way["highway"](around:${distance},${lat},${long}); out;`;

  if (typeof lat !== 'number' || typeof long !== 'number' || typeof distance !== 'number') {
    return callback(new Error('Lat, Long, and Distance must be numbers'), null);
  }

  if (Math.abs(lat) > 90) {
    return callback(new Error('Latitude must be between -90 and 90'), null);
  }

  if (Math.abs(long) > 180) {
    return callback(new Error('Longitude must be between -180 and 180'), null);
  }

  if (distance < 0) {
    return callback(new Error('Distance must be greater than 0'), null);
  }
<commit_msg>Seperate validation of fromLocation to another method<commit_after>const getJSON = require('get-json');
const unique = require('array-unique');

/** URL of the Overpass API being used */
const overpass = 'http://overpass-api.de/api/interpreter?data=';

/**
 * Validation checks for fromLocation params
 * @param {Number} lat - Latitude of centre location.
 * @param {Number} long - Longitude of centre location.
 * @param {Number} distance - Radius distance in metres.
 * @returns {Error} - Error object if validation fails, null otherwise
 */
function validateFromLocation(lat, long, distance) {
  if (typeof lat !== 'number' || typeof long !== 'number' || typeof distance !== 'number') {
    return new Error('Lat, Long, and Distance must be numbers');
  }

  if (Math.abs(lat) > 90) {
    return new Error('Latitude must be between -90 and 90');
  }

  if (Math.abs(long) > 180) {
    return new Error('Longitude must be between -180 and 180');
  }

  if (distance < 0) {
    return new Error('Distance must be greater than 0');
  }

  return null;
}

/**
 * Get all road names within a specified distance from a location.
 * @param {Number} lat - Latitude of centre location.
 * @param {Number} long - Longitude of centre location.
 * @param {Number} distance - Radius distance in metres.
 * @param {Function} callback - callback(err, data)
 * @returns {Array} - Array of road names, use callback.
 */
function fromLocation(lat, long, distance, callback) {
  const query = `[out:json]; way["highway"](around:${distance},${lat},${long}); out;`;

  const validationError = validateFromLocation(lat, long, distance);

  if (validationError) {
    return callback(validationError);
  }

{'fraction_non_alphanumeric': 0.143646408839779, 'fraction_numerical': 0.011740331491712707, 'mean_word_length': 4.038260869565217, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1280913', 'n_tokens_mistral': 878, 'n_tokens_neox': 835, 'n_words': 310}