@imkremen/xlf2xlf
Version:
A command-line utility to automatically translate .xlf translation files using Google Translate
37 lines (33 loc) • 707 B
JavaScript
const fs = require('fs');
/**
* Wraps fs.readFile with Promise
*
* @param {string} path
* @returns
*/
function readFileAsync(path) {
return new Promise((resolve, reject) => {
fs.readFile(path, (err, data) => {
if (err) {
reject(err);
}
resolve(data);
})
});
}
/**
* Wraps fs.writeFile with Promise
*
* @param {string} path
* @param {string} data
* @returns
*/
function writeFileAsync(path, data) {
return new Promise((resolve, reject) => {
fs.writeFile(path, data, null, (err) => {
reject(err);
});
resolve(data);
});
}
module.exports = { readFileAsync , writeFileAsync };