Skip to content

流水线

ExpressionPipeline 提供可组合的中间件架构。

基本用法

typescript
import { ExpressionPipeline } from '@sciexpr/core'

const pipeline = new ExpressionPipeline()
  .use(new ParseStage())
  .use(new ValidateStage())
  .use(new RenderStage())

const result = await pipeline.execute('\\frac{1}{2}')

自定义阶段

typescript
class AutoCorrectStage implements PipelineStage {
  name = 'auto-correct'

  async process(ctx, next) {
    ctx.input = ctx.input.replace(/\\\\frac/g, '\\frac')
    await next()
  }
}

建议顺序

Normalize → Parse → Validate → Transform → Render → Output

基于 MIT 协议发布