// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
import { parseMediaType } from "./parse_media_type.ts";
import { extensions } from "./_db.ts";
export { extensions };
/**
 * Returns the extensions known to be associated with the media type `type`, or
 * `undefined` if no extensions are found.
 *
 * Extensions are returned without a leading `.`.
 *
 * @param type The media type to get the extensions for.
 *
 * @returns The extensions for the given media type, or `undefined` if no
 * extensions are found.
 *
 * @example
 * ```ts
 * import { extensionsByType } from "@std/media-types/extensions-by-type";
 * import { assertEquals } from "@std/assert/assert-equals";
 *
 * assertEquals(extensionsByType("application/json"), ["json", "map"]);
 * assertEquals(extensionsByType("text/html; charset=UTF-8"), ["html", "htm", "shtml"]);
 * assertEquals(extensionsByType("application/foo"), undefined);
 * ```
 */ export function extensionsByType(type) {
  try {
    const [mediaType] = parseMediaType(type);
    return extensions.get(mediaType);
  } catch  {
  // just swallow errors, returning undefined
  }
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImh0dHBzOi8vanNyLmlvL0BzdGQvbWVkaWEtdHlwZXMvMC4yMjQuMS9leHRlbnNpb25zX2J5X3R5cGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gQ29weXJpZ2h0IDIwMTgtMjAyNCB0aGUgRGVubyBhdXRob3JzLiBBbGwgcmlnaHRzIHJlc2VydmVkLiBNSVQgbGljZW5zZS5cbi8vIFRoaXMgbW9kdWxlIGlzIGJyb3dzZXIgY29tcGF0aWJsZS5cblxuaW1wb3J0IHsgcGFyc2VNZWRpYVR5cGUgfSBmcm9tIFwiLi9wYXJzZV9tZWRpYV90eXBlLnRzXCI7XG5pbXBvcnQgeyBleHRlbnNpb25zIH0gZnJvbSBcIi4vX2RiLnRzXCI7XG5cbmV4cG9ydCB7IGV4dGVuc2lvbnMgfTtcblxuLyoqXG4gKiBSZXR1cm5zIHRoZSBleHRlbnNpb25zIGtub3duIHRvIGJlIGFzc29jaWF0ZWQgd2l0aCB0aGUgbW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