One node.js End super easy to use file paging, read by line library

Time:2020-10-22

For the first time, it took a lot of effort to open source. Welcome to star~~

github: https://github.com/shisuiyou/query-lines-reader

npm: https://www.npmjs.com/package/query-lines-reader

1、 Purpose

Purpose of use

  • Read log

  • Search file content

Why powerful

  • Read range
  • It can be read in pagination
  • You can read it right now
  • You can read it backwards
  • Can search to read

Is it powerful and useful!

2、 How to use it

npm install query-lines-reader
let queryLinesReader = new QueryLinesReader(filePath, options);

//Read from top to bottom
queryLinesReader.queryLines({
    start: 0,
    end: 2
}).then(res => {
    res.lineList // ['xx', 'xxxx']
})

queryLinesReader.queryLines({
    pageSize: 10,
    currentPage: 0
}).then(res => {
    res.lineList // ['xx', 'xxxx']
})

//Read from bottom to top
queryLinesReader.queryLines({
    pageSize: 10,
    currentPage: 0,
    reverse: true
}).then(res => {
    res.lineList // ['xx', 'xxxx']
})

//Search for files
queryLinesReader.queryLines({
    pageSize: 10,
    currentPage: 0,
    reverse: true,
    include: String/RegExp
}).then(res => {
    res.lineList // ['xx', 'xxxx']
})

3、 Why efficient

  1. There are two built-in file reading schemes. Different file sizes and different concurrent read data will dynamically balance. Different schemes will be selected to process and return the results
  2. According to different platforms, different schemes are selected to read files

Recommended Today

Blog based on beego, go blog

Go Blog A beego based development, can quickly create personal blog, CMS system Include functions see Official website of go bloggo-blog.cn Demo siteleechan.online Update log time function January 23, 2020 New top post function February 2, 2020 New custom navigation function February 4, 2020 New site announcement function February 6, 2020 New link module February […]