Skip to content

Latest commit

 

History

History
 
 

03_enthusiast

npm version npm download dependencies license

What is the Enthusiast?

Enthusiast is a stream library implementation that utilizes generator functions to make streams work in functional way.

Additionally, as a library, Enthusiast is completely tree-shanking-friendly. Your favorite module bundler can easily inline the functionality you need with no extra configuration, instead of bundling the whole Enthusiast package.

Quick start

Execute npm install enthusiast to install enthusiast and its dependencies into your project directory.

Usage of modules

Reading a stream

import fromNodeStream from 'enthusiast/lib/fromNodeStream';
import iterate from 'evangelist/lib/iterate';
import * as fs from 'fs';

iterate(
    // open file and read 512 bytes buffer on each generator call
    fromNodeStream(fs.createReadStream('./test.txt'), 512),
    item => {
        console.log(item.data.toString('utf8'));
    },
);

Writing to a stream

import toNodeStream from 'enthusiast/lib/toNodeStream';
import compose from 'evangelist/lib/compose';
import * as fs from 'fs';

const logFormatter = (logEntry) => `${Date.now()} ${logEntry}\n`;

const writeLog = compose(
    logFormatter,
    toNodeStream(fs.createWriteStream(./logFile’)),
);

writeLog('a sample log entry');

Transforming a stream

import fromNodeStream from 'enthusiast/lib/fromNodeStream';
import toNodeStream from 'enthusiast/lib/toNodeStream';
import iterate from 'evangelist/lib/iterate';
import compose from 'evangelist/lib/compose';
import * as fs from 'fs';

iterate(
    // open file and read 512 bytes buffer on each generator call
    fromNodeStream(fs.createReadStream('./test.txt'), 512),
    compose(
        gzip(),
        toNodeStream(fs.createWriteStream('./test.txt.gz')),
    ),
);

Todo List

See GitHub Projects for more.

Requirements

License

Apache 2.0, for further details, please see LICENSE file

Contributing

See contributors.md

It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome.

  • To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
  • To report a bug: If something does not work, please report it using GitHub Issues.

To Support

Visit my patreon profile at patreon.com/eserozvataf