@dpkit/datahub
Version:
Fast TypeScript data management framework built on top of the Data Package standard and Polars DataFrames
21 lines (16 loc) • 561 B
text/typescript
import type { Plugin } from "@dpkit/core"
import { isRemotePath } from "@dpkit/core"
import { loadPackageFromDatahub } from "./package/index.ts"
export class DatahubPlugin implements Plugin {
async loadPackage(source: string) {
const isDatahub = getIsDatahub(source)
if (!isDatahub) return undefined
const dataPackage = await loadPackageFromDatahub(source)
return dataPackage
}
}
function getIsDatahub(path: string) {
const isRemote = isRemotePath(path)
if (!isRemote) return false
return new URL(path).hostname === "datahub.io"
}