UNPKG

1.66 kBTypeScriptView Raw
1import type { BlockScalar, FlowScalar } from '../parse/cst.js';
2import { NodeBase, Range } from './Node.js';
3import { ToJSContext } from './toJS.js';
4export declare const isScalarValue: (value: unknown) => boolean;
5export declare namespace Scalar {
6 interface Parsed extends Scalar {
7 range: Range;
8 source: string;
9 srcToken?: FlowScalar | BlockScalar;
10 }
11 type BLOCK_FOLDED = 'BLOCK_FOLDED';
12 type BLOCK_LITERAL = 'BLOCK_LITERAL';
13 type PLAIN = 'PLAIN';
14 type QUOTE_DOUBLE = 'QUOTE_DOUBLE';
15 type QUOTE_SINGLE = 'QUOTE_SINGLE';
16 type Type = BLOCK_FOLDED | BLOCK_LITERAL | PLAIN | QUOTE_DOUBLE | QUOTE_SINGLE;
17}
18export declare class Scalar<T = unknown> extends NodeBase {
19 static readonly BLOCK_FOLDED = "BLOCK_FOLDED";
20 static readonly BLOCK_LITERAL = "BLOCK_LITERAL";
21 static readonly PLAIN = "PLAIN";
22 static readonly QUOTE_DOUBLE = "QUOTE_DOUBLE";
23 static readonly QUOTE_SINGLE = "QUOTE_SINGLE";
24 value: T;
25 /** An optional anchor on this node. Used by alias nodes. */
26 anchor?: string;
27 /**
28 * By default (undefined), numbers use decimal notation.
29 * The YAML 1.2 core schema only supports 'HEX' and 'OCT'.
30 * The YAML 1.1 schema also supports 'BIN' and 'TIME'
31 */
32 format?: string;
33 /** If `value` is a number, use this value when stringifying this node. */
34 minFractionDigits?: number;
35 /** Set during parsing to the source string value */
36 source?: string;
37 /** The scalar style used for the node's string representation */
38 type?: Scalar.Type;
39 constructor(value: T);
40 toJSON(arg?: any, ctx?: ToJSContext): any;
41 toString(): string;
42}