folderToDocuments(linksPath) .each(result => { index.addDoc(result); }) .done(() => { const indexJSON = index.toJSON(); fs.writeFile(indexPath, JSON.stringify(indexJSON), () => { console.log('Successfully saved index!'); }); });
const run = async () => { await folderToDocuments(linksPath, {arrayMod}) .each(result => index.addDoc(result)) .toPromise(Promise); console.log('Successfully generated index!');