Socket
Socket
Sign inDemoInstall

yaml

Package Overview
Dependencies
0
Maintainers
0
Versions
85
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    yaml

Yaml parser


Version published
Maintainers
0
Install size
12.2 kB
Created

Package description

What is yaml?

The 'yaml' npm package is a JavaScript library for parsing and serializing YAML, a human-friendly data serialization standard. It can be used to convert YAML to JSON and vice versa, and to work with YAML content programmatically in JavaScript.

What are yaml's main functionalities?

Parsing YAML to JSON

This feature allows you to parse a string of YAML content and convert it into a JavaScript object.

const yaml = require('yaml');
const yamlText = 'key: value\nnumber: 123';
const jsonObject = yaml.parse(yamlText);
console.log(jsonObject);

Stringifying JSON to YAML

This feature enables you to take a JavaScript object and serialize it into a YAML formatted string.

const yaml = require('yaml');
const jsonObject = { key: 'value', number: 123 };
const yamlText = yaml.stringify(jsonObject);
console.log(yamlText);

Custom Tags

This feature allows you to define custom tags for specialized YAML types, enabling the parsing of YAML content with custom data structures.

const yaml = require('yaml');
const customType = { identify: value => value instanceof Set, tag: 'tag:yaml.org,2002:set', resolve: (doc, cst) => new Set(cst.strValue.split(', ')) };
yaml.defaultOptions.customTags = [customType];
const yamlText = '!!set a, b, c';
const data = yaml.parse(yamlText);
console.log(data);

Other packages similar to yaml

Readme

Source

YAML

CommonJS JavaScript YAML parser, fast and tiny. Although this implementation does not currently support the entire YAML specification, feel free to fork the project and submit a patch :)

Usage

require('yaml').eval(string_of_yaml)

Currently Supports

  • Comments
  • Sequences (arrays)
  • Maps (hashes)
  • Inline sequences
  • Inline maps
  • Nesting
  • Primitive scalars (integers, floats, booleans, etc)
  • Extended bools (enabled, disabled, yes, no, on, off, true, false)

Installation

$ npm install yaml

Testing

Update git submodules and run:

$ make test

License

(The MIT License)

Copyright (c) 2009 TJ Holowaychuk tj@vision-media.ca

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Last updated on 21 May 2011

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc