Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stoplight/yaml

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/yaml

Useful functions when working with YAML.

  • 4.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
719K
decreased by-17.24%
Maintainers
1
Weekly downloads
 
Created

What is @stoplight/yaml?

@stoplight/yaml is a versatile npm package that provides utilities for parsing, stringifying, and processing YAML data. It is particularly useful for developers working with YAML configurations, API specifications, and other structured data formats.

What are @stoplight/yaml's main functionalities?

Parsing YAML to JavaScript Object

This feature allows you to convert a YAML string into a JavaScript object. The `parse` function takes a YAML string as input and returns the corresponding JavaScript object.

const { parse } = require('@stoplight/yaml');
const yamlString = 'key: value\nlist:\n  - item1\n  - item2';
const jsObject = parse(yamlString);
console.log(jsObject);

Stringifying JavaScript Object to YAML

This feature allows you to convert a JavaScript object into a YAML string. The `stringify` function takes a JavaScript object as input and returns the corresponding YAML string.

const { stringify } = require('@stoplight/yaml');
const jsObject = { key: 'value', list: ['item1', 'item2'] };
const yamlString = stringify(jsObject);
console.log(yamlString);

Handling YAML Errors

This feature demonstrates how to handle errors that may occur during YAML parsing. The `parse` function will throw an error if the input YAML string is invalid, which can be caught and handled appropriately.

const { parse } = require('@stoplight/yaml');
try {
  const jsObject = parse('invalid: yaml: string');
} catch (error) {
  console.error('YAML parsing error:', error.message);
}

Other packages similar to @stoplight/yaml

Keywords

FAQs

Package last updated on 04 Mar 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc