1 import toml
from 'toml';
4 /** @module cytube-common/configuration/configloader */
7 * Load a toml file and pass the results to a configuration
10 * @param {function} constructor Constructor to call with the loaded data
11 * @param {string} filename Path to the toml file to load
12 * @returns {Object} Configuration object constructed from the provided constructor
13 * @throws {SyntaxError} Errors propagated from toml.parse()
15 export function loadFromToml(constructor, filename
) {
16 const rawContents
= fs
.readFileSync(filename
).toString('utf8');
17 const configData
= toml
.parse(rawContents
);
18 return new (constructor)(configData
);