UNPKG

@flex-development/pathe

Version:

Universal drop-in replacement for node:path

33 lines (32 loc) 893 B
/** * @file extToValue * @module pathe/lib/extToValue */ import type { EmptyString, Ext } from '@flex-development/pathe'; /** * Get a value for `input` based on its file extension. * * This algorithm picks the value with the longest matching file extension, * so if `map` has the keys `'.mts'` and `'.d.mts'`, the value for `'.d.mts'` * will be returned. * * @see {@linkcode EmptyString} * @see {@linkcode Ext} * * @category * utils * * @template {any} T * Map value * * @this {void} * * @param {URL | string} input * The {@linkcode URL}, URL string, or path to handle * @param {Partial<Record<EmptyString | Ext, T>>} map * Extension map * @return {T | undefined} * Value based on file extension of `input` */ declare function extToValue<T>(this: void, input: URL | string, map: Partial<Record<EmptyString | Ext, T>>): T | undefined; export default extToValue;