1.10.2 • Published 2 months ago

yaml v1.10.2

Weekly downloads
10,902,993
License
ISC
Repository
github
Last release
2 months ago

YAML

JavaScript parser and stringifier for YAML 1.2

Note: yaml 0.x and 1.x are rather different implementations. For the earlier yaml, see tj/js-yaml.

Usage

npm install yaml
import { resolve } from 'yaml'

const yaml =
`YAML:
  - A human-readable data serialization language
  - https://en.wikipedia.org/wiki/YAML
yaml:
  - A complete JavaScript implementation
  - https://www.npmjs.com/package/yaml
`

const doc = resolve(yaml)[0]

doc.toJSON()
/*
 *  { YAML:
 *    [ 'A human-readable data serialization language',
 *      'https://en.wikipedia.org/wiki/YAML' ],
 *    yaml:
 *    [ 'A complete JavaScript implementation',
 *      'https://www.npmjs.com/package/yaml' ] }
*/

doc.toString() === yaml

Beta Progress

The reason why this project exists is to have a tool that's capable of properly generating and handling YAML files with comments, specifically to provide context for translation strings that have been lifted out of JS source code. We're not there yet, as the prerequisite for that is having a complete and functioning YAML library.

The AST level of the library has been released separately, and is fully functional.

What Works So Far

Parsing

  • Support for all YAML node types, including alias nodes and multi-document streams
  • Complete support for the Fallback, JSON, and Core Schemas, as well as an "extended" schema that covers all of the YAML 1.1 scalar types except for !!yaml.
  • Support for << merge keys (default-enabled, disable with merge: false option)
  • Complete match between the parsed in.yaml and in.json files across all of the yaml-test-suite test cases (note: A few of the tests are not in agreement with the spec, so this requires the use of a custom branch until PR #24 and issue #25 are resolved)
  • Comments are parsed and included up to the AST level of the API
  • "Native" Map and Seq collections have toJSON() methods for bare JavaScript Object and Array output
  • Any string input should be accepted, and produce some output. Errors (if any) are not thrown, but included in the document's errors array

Stringifying

  • Document#toString() mostly works, producing idempotent YAML from all but a few corner cases
  • AST#toString() works completely, but is clumsy to use

Still Needs Work

  • Object creation: Document, Map and Seq need constructors accepting plain JS objects
  • Long lines should be wrapped
  • Collections need to retain tag and comment data
  • Item add/remove should keep tags and comments in place
  • Not all parser errors are reported
  • API needs finalising
cosmiconfigpostcss-load-configcssnano@williele/broker-cmdvuedragdropuploadimagesalgotia-test-packageeas-clientinit-log4brains@kaishuu0123/oas-linter@kaishuu0123/oas-resolver@kaishuu0123/oas-validator@kaishuu0123/swagger2openapireact-native-bluetooth2killi8n-react-native-fast-imagenest-aws-serverless-tools@adobe/aio-cli-plugin-aem-cloud-migrationsnippetofligo2ligosnippet3snippetofligosnippetofligo3plurilock-watson-sdkcopperclientplatform-builderautoml-template@smarterlabs/omni-yamlmd-pulllaunchdarkly-node-server-sdk-fork@schm-dt/email-templates@stelligent/mutatoyaiact-cliimport-io-cli@olivr/test2@olivr/test3neatyyyyy@olivr/neat@pixelfactory/privatebin-cliligo-code-snippetligo-code-snippet2ligo-code-snippet7mligo-code-snippet8mligo-snippet-test1ligo-snippet-test2ligo-snippet-test3ligo-snippetsligosnippetligosnippet-testligosnippet-test10ligosnippet-test11ligosnippet-test5ligosnippet-test8ligosnippet-test9ligosnippet1ligosnippet1mligosnippet2ligosnippet2mligosnippet4ligosnippet4mligosnippet5ligosnippet5mligosnippet7ligosnippet8ligosnippet9ligosnippettestligosnippettest5ligosnippetzligosnippetz1ligosnippetz2ligosnippetz22ligosnippetz222ligosnippetz3ligosnippetz4ligosnippetz99@nodesoccoop/angular-ncr-srcsleeguangxing-truckligosnippetstestdiode-inspr-testdiode-testttdiode-inspr-test-test-testdiode-inspr-testtdiode-testdiode-test-test-diodeinspr-test-diode-test@lottojs/lottojsexpress-snapmasterdiode-test-insprcodestore-cliinspr-diode-testgenerate-typesfmt2@sentry/quicktype-with-markdownnestjs-swager-converter-cloud-endpoint@bumble/dot-plopenxametypeswarmorangepiggy-climirai-bothomebridge-tuya-lan2antennerparcel-namer-entriesdokztest
2.0.0-8

2 months ago

2.0.0-7

3 months ago

2.0.0-6

4 months ago

2.0.0-5

6 months ago

1.10.2

8 months ago

2.0.0-4

8 months ago

1.10.1

8 months ago

2.0.0-3

9 months ago

2.0.0-2

9 months ago

2.0.0-1

1 year ago

2.0.0-0

1 year ago

1.10.0

1 year ago

1.9.2

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.8.3

2 years ago

1.8.2

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.1

2 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-rc.8

3 years ago

1.0.0-rc.7

3 years ago

1.0.0-rc.6

3 years ago

1.0.0-rc.5

3 years ago

1.0.0-rc.4

3 years ago

1.0.0-rc.3

3 years ago

1.0.0-rc.2

3 years ago

1.0.0-rc.1

3 years ago

1.0.0-beta.7

3 years ago

1.0.0-beta.6

3 years ago

1.0.0-beta.5

3 years ago

1.0.0-beta.4

4 years ago

1.0.0-beta.3

4 years ago

1.0.0-beta.2

4 years ago

1.0.0-beta.1

4 years ago

0.3.0

6 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago