UNPKG

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