@dpkit/core
Version:
Fast TypeScript data management framework built on top of the Data Package standard and Polars DataFrames
21 lines (17 loc) • 475 B
text/typescript
import { getFilename, getFormat } from "../general/index.js"
import type { Resource } from "./Resource.js"
export function inferFormat(resource: Partial<Resource>) {
let format = resource.format
if (!format) {
if (resource.path) {
const path = Array.isArray(resource.path)
? resource.path[0]
: resource.path
if (path) {
const filename = getFilename(path)
format = getFormat(filename)
}
}
}
return format
}