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