read-chunks

1.1.0 • Public • Published

read-chunks

Uses read-chunk to read files in chunks.

Usage

import readChunks from "read-chunks"
 
// read a file with chunk size of 6 bytes
readChunks(__dirname + "/test.input", 6, (e) => {
    // do something with chunk
    // call readNextChunk when
    // you are done processing the chunk.
    let line = e.chunk.toString("utf-8")
    line = line.split("\n").join("")
 
    let percentage = (e.percentage * 100).toFixed(2)
 
    console.log("[" + percentage + "%] Got chunk: " + line)
 
    // read next chunk after
    // a second has passed
    if (e.readNextChunk) {
        setTimeout(e.readNextChunk, 1000)
    }
})
.then(() => {
    console.log("Done")
})
.catch((error) => {
    console.log("Woops..", error)
})

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i read-chunks

    Weekly Downloads

    0

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    11.2 kB

    Total Files

    12

    Last publish

    Collaborators

    • dthreel