I iterate over the repository and parse JSON files there. I populate batch array with the data in order to use it later for batch insert using pg. 
This is how I populate batch array
const batch = [];
dir.readFiles('../resources/data/', { match: /\.json$/ }, (err, content, next) => {
    if (err) throw err;
    const jsn = JSON.parse(content);
    const generatorName = jsn.name;
    const generatorParts = jsn.name_parts;
    Object.entries(generatorParts).forEach(([key, value]) => {
        const pr_sp = value.precede_space;
        const ordr = value.order;
        const nm_prts = value.parts;
        nm_prts.forEach(item => {
            batch.push([generatorName, key, item, ordr, pr_sp]);
        });
    });
    next();
});
console.log(batch);
But console.log shows that the batch is empty. What is the problem?
