<commit_before>import {
  Feature,
  FeatureCollection,
  Geometries,
  GeometryCollection,
  isNumber,
  Point,
} from "@turf/helpers";

/**
 * Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
 *
 * @name getCoord
 * @param {Array<number>|Geometry<Point>|Feature<Point>} coord GeoJSON Point or an Array of numbers
 * @returns {Array<number>} coordinates
 * @example
 * var pt = turf.point([10, 10]);
 *
 * var coord = turf.getCoord(pt);
 * //= [10, 10]
 */
export function getCoord(coord: Feature<Point> | Point | number[]): number[] {
  if (!coord) {
    throw new Error("coord is required");
  }

  if (!Array.isArray(coord)) {
    if (
      coord.type === "Feature" &&
      coord.geometry !== null &&
      coord.geometry.type === "Point"
    ) {
      return coord.geometry.coordinates;
    }
    if (coord.type === "Point") {
      return coord.coordinates;
    }
  }
  if (
    Array.isArray(coord) &&
    coord.length >= 2 &&
    !Array.isArray(coord[0]) &&
    !Array.isArray(coord[1])
  ) {
    return coord;
  }

  throw new Error("coord must be GeoJSON Point or an Array of numbers");
}

/**
 * Unwrap coordinates from a Feature, Geometry Object or an Array
 *<commit_msg>@turf/invariant's getCoord now shallow clones its result (#2167)<commit_after>import {
  Feature,
  FeatureCollection,
  Geometries,
  GeometryCollection,
  isNumber,
  Point,
} from "@turf/helpers";

/**
 * Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
 *
 * @name getCoord
 * @param {Array<number>|Geometry<Point>|Feature<Point>} coord GeoJSON Point or an Array of numbers
 * @returns {Array<number>} coordinates
 * @example
 * var pt = turf.point([10, 10]);
 *
 * var coord = turf.getCoord(pt);
 * //= [10, 10]
 */
export function getCoord(coord: Feature<Point> | Point | number[]): number[] {
  if (!coord) {
    throw new Error("coord is required");
  }

  if (!Array.isArray(coord)) {
    if (
      coord.type === "Feature" &&
      coord.geometry !== null &&
      coord.geometry.type === "Point"
    ) {
      return [...coord.geometry.coordinates];
    }
    if (coord.type === "Point") {
      return [...coord.coordinates];
    }
  }
  if (
    Array.isArray(coord) &&
    coord.length >= 2 &&
    !Array.isArray(coord[0]) &&
    !Array.isArray(coord[1])
  ) {
    return [...coord];
  }

  throw new Error("coord must be GeoJSON Point or an Array of numbers");
}

/**
 * Unwrap coordinates from a Feature, Geometry Object or an Array
 *
{'fraction_non_alphanumeric': 0.15461847389558234, 'fraction_numerical': 0.010441767068273093, 'mean_word_length': 3.1105610561056105, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '2114575', 'n_tokens_mistral': 822, 'n_tokens_neox': 793, 'n_words': 219}