Skip to content

keuby/file-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Handler

@lnfsink/file-handler can synchronously read and write files by line

Install

Using npm:

$ npm install @lnfsink/file-handler

Using yarn:

$ yarn add @lnfsink/file-handler

Usage

const handler = require('@lnfsink/file-handler')

let reader = handler.read('example/input.txt', {
  bufferSize: 1024 * 1024, // 1M Default
  encoding: 'utf8' // Default
})
let writer = handler.write('example/output.txt', {
  cacheLines: 1000 // Cache some lines before writing to the file
})
for (let line of reader) {
  writer.writeLine(line)
}
writer.close()