Socket
Book a DemoInstallSign in
Socket

stream-from-iterator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-from-iterator

Create streams from ES2015 iterators

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
22
120%
Maintainers
1
Weekly downloads
 
Created
Source

stream-from-iterator Dependencies Status Image Build Status Image Coverage Status XO code style

Create streams from ECMAScript® 2015 Iterators.

Install

npm install stream-from-iterator --save

Usage

As long as Iterators are not available in Node:

npm install es6-iterator

Stream iterating over String | Buffers

import StreamFromIterator from 'stream-from-iterator';
import Iterator from 'es6-iterator';

new StreamFromIterator(new Iterator(['some', ' ', 'strings']))
  .pipe(process.stdout); // output: some strings

new StreamFromIterator(new Iterator([new Buffer('some'), ' mixed ', new Buffer('strings')]))
  .pipe(process.stdout); // output: some mixed strings

Stream iterating over (arbitrary) Javascript Values

import StreamFromIterator from 'stream-from-iterator';
import Iterator from 'es6-iterator';

var i = 0;
StreamFromIterator.obj(new Iterator(['some', 42, 'mixed', 'array', () => {}]))
  .on('data', data => {
    console.log(i++ + ': ' + typeof data);
    /* outputs:
      0: string
      1: number
      2: string
      3: string
      4: function
    */
  });

API

Class: StreamFromIterator

StreamFromIterators are Readable streams.

new StreamFromIterator(iterator, [options])

  • iterator Iterator ES2015 Iterator iterating over arbitrary Javascript values like numbers, strings, objects, functions, ...
  • options Object passed through new Readable([options])

Note: The new operator can be omitted.

StreamFromIterator#obj(iterator, [options])

A convenience wrapper for new StreamFromIterator(iterator, {objectMode: true, ...}).

  • stream-from: Create streams from promises, iterators, factories and arbitrary Javascript values like functions, arrays, etc.

License

MIT © Michael Mayer

Keywords

readable

FAQs

Package last updated on 25 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts