working with toml in javascript

Solutions on MaxInterview for working with toml in javascript by the best coders in the world

showing results for - "working with toml in javascript"
Kamelia
12 Feb 2017
1/*
2    This code comes from Vincent Lab
3    And it has a video version linked here: https://www.youtube.com/watch?v=kdZN9IOfyeE
4*/
5
6// Import dependencies
7const fs = require("fs");
8const toml = require("toml");
9
10// Read a toml file
11const data = toml.parse(fs.readFileSync("config.toml"));
12console.dir(data);
13
14// Make a toml file
15const title = "Cars";
16const cars = ["BMW", "Audi", "Tesla"];
17fs.writeFileSync("test.toml", `
18    title = "${title}"
19    cars = ${JSON.stringify(cars)}
20`);