Pair.d.ts 1.2 KB

123456789101112131415161718192021
  1. import { CreateNodeContext } from '../doc/createNode.js';
  2. import type { CollectionItem } from '../parse/cst.js';
  3. import type { Schema } from '../schema/Schema.js';
  4. import type { StringifyContext } from '../stringify/stringify.js';
  5. import { addPairToJSMap } from './addPairToJSMap.js';
  6. import { NODE_TYPE } from './identity.js';
  7. import type { ToJSContext } from './toJS.js';
  8. export declare function createPair(key: unknown, value: unknown, ctx: CreateNodeContext): Pair<import("./Node.js").Node, import("./Alias.js").Alias | import("./Scalar.js").Scalar<unknown> | import("./YAMLMap.js").YAMLMap<unknown, unknown> | import("./YAMLSeq.js").YAMLSeq<unknown>>;
  9. export declare class Pair<K = unknown, V = unknown> {
  10. readonly [NODE_TYPE]: symbol;
  11. /** Always Node or null when parsed, but can be set to anything. */
  12. key: K;
  13. /** Always Node or null when parsed, but can be set to anything. */
  14. value: V | null;
  15. /** The CST token that was composed into this pair. */
  16. srcToken?: CollectionItem;
  17. constructor(key: K, value?: V | null);
  18. clone(schema?: Schema): Pair<K, V>;
  19. toJSON(_?: unknown, ctx?: ToJSContext): ReturnType<typeof addPairToJSMap>;
  20. toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
  21. }