UCD.js Docs

Routes

Define filters, parsers, transforms, route data, caching, and outputs

Routes are the main unit of pipeline work. A route matches files, parses them into rows, optionally transforms those rows, and resolves the result into route data and outputs.

Route shape

A route definition can include:

  • id
  • filter
  • depends
  • parser
  • transforms
  • resolver
  • outputs
  • cache
import { definePipelineRoute, byName } from "@ucdjs/pipeline-core";

const myRoute = definePipelineRoute({
  id: "unicode-data",
  filter: byName("UnicodeData.txt"),
  parser: standardParser,
  resolver: async (ctx, rows) => {
    const result = [];
    for await (const row of rows) {
      result.push(row);
    }
    return result;
  },
});

Filters

Filters determine which files the route should process.

filter: byName("Blocks.txt")

See /pipelines/filters for the full helper set, including byDir, byExt, byGlob, byPath, bySource, byProp, and the filter combinators.

Parser

The parser is an async generator that turns file content into rows. Preset parsers such as standardParser, sequenceParser, and unicodeDataParser cover the common UCD formats.

Transforms

Transforms run after parsing and before resolution:

transforms: [
  createSortTransform({ direction: "desc" }),
  uppercaseValues,
]

Each transform receives the previous transform's output stream.

Route dependencies and route data

Routes depend on other routes through depends:

depends: ["route:colors"]

A dependent resolver then consumes upstream route data with ctx.getRouteData(...):

resolver: async (ctx, rows) => {
  const colorData = ctx.getRouteData("colors");
  // ...
}

Resolver

The resolver turns rows into final route data. It receives the current version, file metadata, logger, clock helpers, and any declared upstream route data.

Cache

Set cache: true when the route work is deterministic and worth reusing across runs.

Outputs

Use outputs when the route should publish stable, inspectable results or persist files:

outputs: [{
  id: "colors-json",
  path: "data/colors/colors.json",
}]

See /pipelines/outputs for the runtime output model.

On this page