How to use the scramjet.StringStream.fromArray function in scramjet

To help you get started, we’ve selected a few scramjet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github signicode / scramjet / samples / so-examples / word-count.js View on Github external
const {StringStream} = require('scramjet');
    const wordcount = require('wordcount');
    const fetch = require('node-fetch');
    const htmlToText = require('html-to-text');
    const {promisify} = require('util');

    StringStream.fromArray(["https://stackoverflow.com/", "https://caolan.github.io/async/docs.html#eachLimit"])
        .setOptions({maxParallel: 4})
        .parse(async url => ({
            url,
            response: await fetch(url)
        }))
        .map(async ({url, response}) => {
            const html = await response.text();
            const text = htmlToText.fromString(html);
            const count = wordcount(text);

            return {
                url,
                count
            };
        })
        .each(console.log)

scramjet

Lightweight and real-time data functional stream programming framework like event-stream, written in ES6 using async await with multi-threading and typescript support

MIT
Latest version published 8 months ago

Package Health Score

62 / 100
Full package analysis