Answers for "Working with TOML in JavaScript"

1

Working with TOML in JavaScript

/*
    This code comes from Vincent Lab
    And it has a video version linked here: https://www.youtube.com/watch?v=kdZN9IOfyeE
*/

// Import dependencies
const fs = require("fs");
const toml = require("toml");

// Read a toml file
const data = toml.parse(fs.readFileSync("config.toml"));
console.dir(data);

// Make a toml file
const title = "Cars";
const cars = ["BMW", "Audi", "Tesla"];
fs.writeFileSync("test.toml", `
    title = "${title}"
    cars = ${JSON.stringify(cars)}
`);
Posted by: Guest on April-20-2021

Code answers related to "Working with TOML in JavaScript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language