1.1.1 • Published 6 years ago

consume-stream-async v1.1.1

Weekly downloads
12
License
-
Repository
-
Last release
6 years ago

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);
    }
);
1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago