ftconfig
F*ck the config
Installation
npm install @theoparis/config
Usage
const ftconfig = require("@theoparis/config");
const config = ftconfig.readFile("./package.json")
.modify((obj) => {
config.name = "simple";
return obj
})
.save();
const obj = config.toObject();
Module Methods
ftconfig.readFile(filepath, [options])
Parameters
filepath
{String}
Filepathoptions
{Object}
encoding
{String="utf-8"}
type
{String}
yaml
json
json5
hjson
toml
ini
Return
Class Config
ftconfig.read(configString, [options])
Parameters
configString
{String}
config stringoptions
{Object}
type
{String}
yaml
json
json5
hjson
toml
ini
Return
Class Config
ftconfig.read(configString, [type])
Parameters
configString
{String}
config stringtype
{String}
yaml
json
json5
hjson
toml
ini
Return
Class Config
Config.modify(function)
Parameters
configString
{Function}
Get which type Return what
Return
Class Config
Config.validate(modify, [options])
Parameters
modify
{boolean}
Modify the config object or just validate itcallback
{Function}
Return
Class Config
Config.save([filepath])
Parameters
filepath
{String}
Target Filepath
Return
Class Config
Config.save([options])
Parameters
options
{Object}
path
{String}
encoding
{String="utf-8"}
indent
{Number=2}
Return
Class Config
Config.toString([options])
Parameters
Return
String
Config.toObject()
Return
Object