yaml-ast-parser
[![Build Status](https://travis-ci.org/mulesoft-labs/yaml-ast-parser.svg?branch=master)](https://travis-ci.org/mulesoft-labs/yaml-ast-parser)
Last updated 6 years ago by denis.denisenko .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install yaml-ast-parser 
SYNC missed versions from official npm registry.

yaml-ast-parser

Build Status

This is a fork of JS-YAML which supports parsing of YAML into AST.

In additional to parsing YAML to AST, it has following features:

  • restoration after the errors and reporting errors as a part of AST nodes.
  • built-in support for !include tag used in RAML

Usage

The type information below is relevant when using TypeScript, if using from JavaScript only the field/method information is relevant.

load method can be used to load the tree and returns a YAMLNode.

YAMLNode

YAMLNode class is an ancestor for all node kinds. It's kind field determine node kind, one of Kind enum:

  • SCALAR, MAPPING, MAP, SEQ, ANCHOR_REF or INCLUDE_REF.

After node kind is determined, it can be cast to one of the YAMLNode descendants types:

  • YAMLScalar, YAMLMapping, YamlMap, YAMLSequence or YAMLAnchorReference.
class important members
YAMLNode startPosition and endPosition provide node range.
YAMLScalar string value field
YAMLMapping YAMLScalar key and YAMLNode value fields
YAMLSequence YAMLNode[] items field
YamlMap YAMLMapping[] mappings field
YAMLAnchorReference string referencesAnchor and YAMLNode value

YAMLScalar

Scalars are one of the three main node types defined by YAML and are effectively leaf nodes.

There are many factors that can influence the type of datum represent in scalar node (context, schema, tag, etc.).

To help inspection of a YAMLScalar to determine its datatype when a document uses the Core Schema, you can pass the YAMLScalar to the determineScalarType function. It will return an enum value indicating null, bool, int, float, or string.

Once you know the type, there are also some helper functions to help read the value by passing them the string, value: parseYamlBoolean, parseYamlFloat, and parseYamlInteger.

Current Tags

  • 0.0.43                                ...           latest (6 years ago)

26 Versions

  • 0.0.43                                ...           6 years ago
  • 0.0.42                                ...           6 years ago
  • 0.0.41                                ...           6 years ago
  • 0.0.40                                ...           7 years ago
  • 0.0.39                                ...           7 years ago
  • 0.0.38                                ...           7 years ago
  • 0.0.37                                ...           7 years ago
  • 0.0.36                                ...           7 years ago
  • 0.0.35                                ...           7 years ago
  • 0.0.34                                ...           7 years ago
  • 0.0.33                                ...           7 years ago
  • 0.0.32                                ...           8 years ago
  • 0.0.31                                ...           8 years ago
  • 0.0.30                                ...           8 years ago
  • 0.0.29                                ...           8 years ago
  • 0.0.28                                ...           8 years ago
  • 0.0.27                                ...           8 years ago
  • 0.0.26                                ...           9 years ago
  • 0.0.25                                ...           9 years ago
  • 0.0.24                                ...           9 years ago
  • 0.0.23                                ...           9 years ago
  • 0.0.22                                ...           9 years ago
  • 0.0.21                                ...           9 years ago
  • 0.0.20                                ...           9 years ago
  • 0.0.19                                ...           9 years ago
  • 0.0.18                                ...           9 years ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (8)

© 2010 - cnpmjs.org x YWFE | Home | YWFE