UNPKG

@dpkit/table

Version:

Data Package implementation in TypeScript.

19 lines (15 loc) 495 B
import type { StringField } from "@dpkit/core" import { DataType, col } from "nodejs-polars" import type { Expr } from "nodejs-polars" // TODO: // Add more validation: // - Validate regex if format provided and it can be performant (e.g. uuid) // - Validate categories // TODO: support categoriesOrder export function parseStringField(field: StringField, expr?: Expr) { expr = expr ?? col(field.name) if (field.categories) { expr = expr.cast(DataType.Categorical) } return expr }