You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As an offshoot of the discussion in #190, I'm now thinking about refactoring and recategorising the options that control various stages. I would appreciate some feedback on this. The general idea here is to flatten scalar options into document options, and then to split them into related sets, and to get rid of user-modifiable cross-document default values. This is where I'm at so far:
// options for `new Document()`interfaceDocumentOptions{anchorPrefix?: string;customTags?: (TagId|Tag)[]|((tags: Tag[])=>Tag[]);merge?: boolean;schema?: "core"|"failsafe"|"json"|"yaml-1.1";version?: "1.0"|"1.1"|"1.2";}// options for `doc.parse()`interfaceParseOptions{intAsBigInt?: boolean;keepCstNodes?: boolean;keepNodeTypes?: boolean;prettyErrors?: boolean;resolveKnownTags?: boolean;sortMapEntries?: boolean|((a: Pair,b: Pair)=>number);}// options for `doc.toJS()`interfaceConstructOptions{mapAsMap?: boolean;maxAliasCount?: number;}// options for `doc.createNode()`interfaceCreateNodeOptions{replacer?: any[]|((key: any,value: any)=>boolean);tag?: string;wrapScalars?: boolean;}// options for `doc.toString()`interfaceStringifyOptions{binLineWidth?: number;binType?: Scalar.Type;boolStr?: {true: string,false: string};indent?: number;indentSeq?: boolean;lineWidth?: number;minContentWidth?: number;nullStr?: string;simpleKeys?: boolean;}// these belong in StringifyOptions, but need more worknamespacescalarOptions{interfaceStr{defaultType: Scalar.Type;defaultKeyType: Scalar.Type;defaultQuoteSingle: boolean;doubleQuoted: {jsonEncoding: boolean;minMultiLineLength: number;};}}
Some functions would then combine more than one of these options:
Doing this would allow for YAML.defaultOptions and YAML.scalarOptions to be dropped, and for the options structure to be flattened. Relatively little should change for any of the options that you're currently able to pass a document, but options controlling scalars would get a complete overhaul.
Regarding doc.toJS() and doc.toString(), I'm not sure yet whether an options bag passed in to the document constructor should provide the defaults for these, or if they should only use options directly passed in.
This discussion was converted from issue #194 on December 11, 2020 12:27.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As an offshoot of the discussion in #190, I'm now thinking about refactoring and recategorising the options that control various stages. I would appreciate some feedback on this. The general idea here is to flatten scalar options into document options, and then to split them into related sets, and to get rid of user-modifiable cross-document default values. This is where I'm at so far:
Some functions would then combine more than one of these options:
YAML.parseDocument()
:DocumentOptions & ParseOptions
YAML.parse()
:DocumentOptions & ParseOptions & ConstructOptions
YAML.stringify()
:DocumentOptions & StringifyOptions
Doing this would allow for
YAML.defaultOptions
andYAML.scalarOptions
to be dropped, and for the options structure to be flattened. Relatively little should change for any of the options that you're currently able to pass a document, but options controlling scalars would get a complete overhaul.Regarding
doc.toJS()
anddoc.toString()
, I'm not sure yet whether an options bag passed in to the document constructor should provide the defaults for these, or if they should only use options directly passed in.Beta Was this translation helpful? Give feedback.
All reactions