src/http/download.js
/**
 * Save list of posts to a JSON file
 */
Save list of posts to a JSON file
Save list of posts to a JSON file
async function toJSON(posts, filePath) {
    let first = true;
    fs.writeFileSync(filePath, "[");
    for (const post of posts) {
        if (first) {
            first = false;
        }
        else {
            fs.appendFileSync(filePath, ", ");
        }
        fs.appendFileSync(filePath, JSON.stringify(post));
    }
    fs.appendFileSync(filePath, "]");
}
async function toJSON ( posts , filePath ) { let first = true ; fs . writeFileSync ( filePath , "[" ) ; for ( const post of posts ) { if ( first ) { first = false ; } else { fs . appendFileSync ( filePath , ", " ) ; } fs . appendFileSync ( filePath , JSON . stringify ( post ) ) ; } fs . appendFileSync ( filePath , "]" ) ; }
Save list of posts to a JSON file
Save list of posts to a JSON file