Novices Performing Miracles

    read-chunk
    TypeScript icon, indicating that this package has built-in type declarations

    4.0.2 • Public • Published

    read-chunk

    Read a chunk from a file

    Because the built-in way requires way too much boilerplate.

    Install

    $ npm install read-chunk
    

    Usage

    import {readChunk} from 'read-chunk';
    
    // foo.txt => hello
    
    await readChunk('foo.txt', {length: 3, startPosition: 1});
    //=> 'ell'

    API

    readChunk(filePath, {length, startPosition})

    Returns a Promise<Buffer> with the read chunk.

    readChunkSync(filePath, {length, startPosition})

    Returns a Buffer with the read chunk.

    filePath

    Type: string

    length

    Type: number

    The number of bytes to read.

    startPosition

    Type: number

    The poosition to start reading from.

    Install

    npm i read-chunk

    DownloadsWeekly Downloads

    842,534

    Version

    4.0.2

    License

    MIT

    Unpacked Size

    4.61 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus