vue electron read file
import fs from 'fs'
import readline from 'readline'
import iconv from 'iconv-lite'
ipcMain.on('readfile', async (event, arg) => {
await readLines()
event.sender.send('readfile-reply', 'complete')
})
function readLines() {
return new Promise((resolve, reject) => {
stream = fs.createReadStream(filePath).pipe(iconv.decodeStream('shift-jis'))
let reader = readline.createInterface(stream, {})
reader
.on('line', line => {
insertLine(line)
})
.on('close', () => {
resolve() // "Resolve" in the close event.
})
.on('error', function(err) {
reject(err)
})
})
}