transform.d.ts 1.7 KB

12345678910111213141516
  1. import LinesAndColumns from "lines-and-columns";
  2. import { Range } from "./transforms/range";
  3. import { Alias, BlockFolded, BlockLiteral, Comment, Content, Directive, Document, FlowMapping, FlowSequence, Mapping, Plain, Point, Position, QuoteDouble, QuoteSingle, Sequence } from "./types";
  4. import * as YAML from "./yaml";
  5. export declare type YamlNode = null | YAML.ast.Alias | YAML.cst.BlankLine | YAML.ast.BlockFolded | YAML.ast.BlockLiteral | YAML.cst.Comment | YAML.cst.Directive | YAML.ast.Document | YAML.ast.FlowMap | YAML.ast.FlowSeq | YAML.ast.Map | YAML.ast.PlainValue | YAML.ast.QuoteDouble | YAML.ast.QuoteSingle | YAML.ast.Scalar | YAML.ast.Seq;
  6. export declare type YamlToUnist<T extends YamlNode> = T extends null ? null : T extends YAML.ast.Alias ? Alias : T extends YAML.ast.BlockFolded ? BlockFolded : T extends YAML.ast.BlockLiteral ? BlockLiteral : T extends YAML.cst.Comment ? Comment : T extends YAML.cst.Directive ? Directive : T extends YAML.ast.Document ? Document : T extends YAML.ast.FlowMap ? FlowMapping : T extends YAML.ast.FlowSeq ? FlowSequence : T extends YAML.ast.Map ? Mapping : T extends YAML.ast.PlainValue ? Plain : T extends YAML.ast.QuoteDouble ? QuoteDouble : T extends YAML.ast.QuoteSingle ? QuoteSingle : T extends YAML.ast.Seq ? Sequence : never;
  7. export interface Context {
  8. text: string;
  9. locator: LinesAndColumns;
  10. comments: Comment[];
  11. transformOffset: (offset: number) => Point;
  12. transformRange: (range: Range) => Position;
  13. transformNode: <T extends YamlNode>(node: T) => YamlToUnist<T>;
  14. transformContent: (node: YAML.ast.Node) => Content;
  15. }
  16. export declare function transformNode<T extends YamlNode>(node: T, context: Context): YamlToUnist<T>;