There is an array with more than two million records, I want to build a new array from it, but the function does not work. Even after a twenty minute wait nothing happens. The code freezes when assigning the variable result. What might be the problem?
const arr1 = fs.readFileSync('./csv1.csv', 'utf-8')
.toString()
.split('\n')
.map(row => row.split(';'))
const arr2 = iconv.encode(
iconv.decode(fs.readFileSync('./csv2.csv'), "win1251"), "utf8")
.toString()
.split('\n')
.map(row => row.split(';'))
const concatArrays = arr1.concat(arr2);
const uniqNumber = _.uniq(concatArrays.map(el => parseInt(el[0])))
const result = uniqNumber.map(el => {
return [parseInt(el), concatArrays.filter(([number]) => el === parseInt(number))]
});