consume-stream-async

1.1.1 • Public • Published

consume-stream-async

Apply async handler to stream easily

import { consumeStreamAsync } from "../";
 
const stream = fs
    .createReadStream("super-big-file.csv")
    .pipe(csv.createStream());
 
const processedItemsCount = await consumeStreamAsync(
    // Any readable stream. Can be a database cursor, for example
    stream,
    // Process by portions of this items count
    10000,
    // Your async handler
    async csvItems => {
        // Your async side-effect handler here that will be applied to portions of data
 
        await getRepository(MyCollection).insert(csvItems);
    }
);

/consume-stream-async/

    Package Sidebar

    Install

    npm i consume-stream-async

    Weekly Downloads

    1

    Version

    1.1.1

    License

    none

    Unpacked Size

    3.34 kB

    Total Files

    7

    Last publish

    Collaborators

    • alex0007