Created
September 25, 2018 16:15
-
-
Save tiagosiebler/cc01e863b18a8a2e1654197242fc0007 to your computer and use it in GitHub Desktop.
Pass a simple object and a path, to generate a JSON file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tradesList = [{},...] | |
// saveObjectToFile(tradesList, `./data/${symbol}_f${fromMS}_t${toMS}.json`) | |
const fs = require('fs'); | |
module.exports = (object, filepath) => { | |
return new Promise((resolve, reject) => { | |
const objStr = JSON.stringify(object); | |
fs.writeFile(filepath, objStr, function(err) { | |
if (!err) return resolve(); | |
console.log(err) | |
return reject(err); | |
}) | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment