UNPKG

@dpkit/core

Version:

Fast TypeScript data management framework built on top of the Data Package standard and Polars DataFrames

23 lines (20 loc) 568 B
import { AssertionError } from "../error/index.ts" import type { Descriptor } from "../general/index.ts" import type { Package } from "./Package.ts" import { validatePackageDescriptor } from "./validate.ts" /** * Assert a Package descriptor (JSON Object) against its profile */ export async function assertPackage( source: Descriptor | Package, options?: { basepath?: string }, ) { const { errors, dataPackage } = await validatePackageDescriptor( source, options, ) if (!dataPackage) throw new AssertionError(errors) return dataPackage }