UNPKG

@dpkit/core

Version:

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

24 lines (19 loc) 664 B
import { getBasepath, saveDescriptor } from "../general/index.ts" import type { Package } from "./Package.ts" import { denormalizePackage } from "./denormalize.ts" const CURRENT_PROFILE = "https://datapackage.org/profiles/2.0/datapackage.json" /** * Save a Package to a file path * Works in Node.js environments */ export async function savePackageDescriptor( dataPackage: Package, options: { path: string }, ) { const basepath = getBasepath(options.path) const descriptor = denormalizePackage(dataPackage, { basepath }) descriptor.$schema = descriptor.$schema ?? CURRENT_PROFILE await saveDescriptor(descriptor, { path: options.path }) }