Socket
Socket
Sign inDemoInstall

write-yaml-file

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

write-yaml-file

Stringify and write YAML to a file atomically


Version published
Weekly downloads
558K
increased by14.53%
Maintainers
1
Weekly downloads
 
Created

What is write-yaml-file?

The write-yaml-file npm package allows you to write YAML files easily from JavaScript objects. It is useful for configuration management, data serialization, and other tasks where YAML is preferred over JSON or other formats.

What are write-yaml-file's main functionalities?

Write a simple YAML file

This feature allows you to write a simple YAML file from a JavaScript object. The code sample demonstrates how to create a YAML file named 'output.yaml' with basic user information.

const writeYamlFile = require('write-yaml-file');

const data = {
  name: 'John Doe',
  age: 30,
  occupation: 'Software Developer'
};

writeYamlFile('output.yaml', data).then(() => {
  console.log('YAML file written successfully!');
});

Write a nested YAML file

This feature allows you to write a nested YAML file from a JavaScript object. The code sample demonstrates how to create a YAML file named 'nested_output.yaml' with nested user information.

const writeYamlFile = require('write-yaml-file');

const data = {
  user: {
    name: 'Jane Doe',
    details: {
      age: 28,
      occupation: 'Data Scientist'
    }
  }
};

writeYamlFile('nested_output.yaml', data).then(() => {
  console.log('Nested YAML file written successfully!');
});

Write a YAML file with custom options

This feature allows you to write a YAML file with custom options such as indentation. The code sample demonstrates how to create a YAML file named 'custom_output.yaml' with a custom indentation of 4 spaces.

const writeYamlFile = require('write-yaml-file');

const data = {
  name: 'Alice',
  age: 25,
  occupation: 'Graphic Designer'
};

const options = {
  indent: 4
};

writeYamlFile('custom_output.yaml', data, options).then(() => {
  console.log('YAML file with custom options written successfully!');
});

Other packages similar to write-yaml-file

Keywords

FAQs

Package last updated on 28 Oct 2018

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