How to use the iterable-to-stream.iterableToStream function in iterable-to-stream

To help you get started, we’ve selected a few iterable-to-stream 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 streetsidesoftware / cspell / packages / cspell-lib / src / file / fileWriter.ts View on Github external
export function writeToFileIterable(filename: string, data: Iterable): fs.WriteStream {
    const sourceStream = iterableToStream(data);
    const writeStream = fs.createWriteStream(filename);
    const zip = filename.match(/\.gz$/) ? zlib.createGzip() : new stream.PassThrough();
    return sourceStream.pipe(zip).pipe(writeStream);
}
github streetsidesoftware / cspell / packages / cspell-trie / src / app.ts View on Github external
return new Promise((resolve) => {
            iterableToStream(words.map(a => a + '\n')).pipe(outputStream).on('finish', () => resolve());
        });
    });
github streetsidesoftware / cspell / packages / cspell-trie / src / app.ts View on Github external
notify('Create Trie', !!outputFile);
        const pOutputStream = createWriteStream(outputFile);
        notify(`Generating...`, !!outputFile);
        const lines = await fileToLines(filename);
        const toLower = lowerCase ? (a: string) => a.toLowerCase() : (a: string) => a;

        const wordsRx = lines
            .map(toLower)
            .map(a => a.trim())
            .filter(a => !!a);

        notify('Processing Trie');
        const root = wordsRx.reduce((node: Trie.TrieNode, word: string) => Trie.insert(word, node), {} as Trie.TrieNode);

        notify('Export Trie');
        const serialStream = iterableToStream(Trie.serializeTrie(root, (base - 0) || 32));
        const outputStream = await pOutputStream;
        return new Promise((resolve) => {
            serialStream.pipe(outputStream).on('finish', () => resolve());
        });
    });

iterable-to-stream

Converts iterable objects into readable streams.

MIT
Latest version published 4 years ago

Package Health Score

47 / 100
Full package analysis

Popular iterable-to-stream functions