• Stars
    star
    212
  • Rank 186,122 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Merge multiple streams into one interleaved stream

merge-stream

Merge (interleave) a bunch of streams.

build status

Synopsis

var stream1 = new Stream();
var stream2 = new Stream();

var merged = mergeStream(stream1, stream2);

var stream3 = new Stream();
merged.add(stream3);
merged.isEmpty();
//=> false

Description

This is adapted from event-stream separated into a new module, using Streams3.

API

mergeStream

Type: function

Merges an arbitrary number of streams. Returns a merged stream.

merged.add

A method to dynamically add more sources to the stream. The argument supplied to add can be either a source or an array of sources.

merged.isEmpty

A method that tells you if the merged stream is empty.

When a stream is "empty" (aka. no sources were added), it could not be returned to a gulp task.

So, we could do something like this:

stream = require('merge-stream')();
// Something like a loop to add some streams to the merge stream
// stream.add(streamA);
// stream.add(streamB);
return stream.isEmpty() ? null : stream;

Gulp example

An example use case for merge-stream is to combine parts of a task in a project's gulpfile.js like this:

const gulp =          require('gulp');
const htmlValidator = require('gulp-w3c-html-validator');
const jsHint =        require('gulp-jshint');
const mergeStream =   require('merge-stream');

function lint() {
  return mergeStream(
    gulp.src('src/*.html')
      .pipe(htmlValidator())
      .pipe(htmlValidator.reporter()),
    gulp.src('src/*.js')
      .pipe(jsHint())
      .pipe(jsHint.reporter())
  );
}
gulp.task('lint', lint);

License

MIT

More Repositories

1

node-any-db

Thin and less-opinionated database abstraction layer for node.
JavaScript
211
star
2

js-shell-parse

parse bash, with javascript (UNMAINTAINED)
JavaScript
88
star
3

ts-react-loader

Automatic prop-types from TypeScript types
TypeScript
70
star
4

uri-template

TypeScript/Javascript implementation of RFC 6570 for URI-templates
TypeScript
42
star
5

js-capitalize

capitalize a string, or all words in a string
JavaScript
37
star
6

guacamole-auth-hmac

UNMAINTAINED! Create Guacamole configurations via (signed) URL query parameters
Java
18
star
7

npm-exec

UNMAINTAINED! npm run-script for arbitrary commands
JavaScript
11
star
8

node-any-db-pool

Connection pool used by any-db
JavaScript
8
star
9

node-any-db-transaction

JavaScript
8
star
10

otssh

One-time SSH daemon
Go
7
star
11

browserify-as-a-service

Prototype for creating browserified bundles on demand.
JavaScript
7
star
12

web-pockets

JavaScript
7
star
13

js-pockets

JavaScript
6
star
14

node-any-db-postgres

JavaScript
6
star
15

js-shell-frontend

Frontend for a posix shell, written in JavaScript
JavaScript
6
star
16

react-async-input

Inputs that behave properly with async set{State,Props} calls
JavaScript
5
star
17

parse-db-url

JavaScript
5
star
18

refify

Safe, cross-language JSON encoding/decoding of structures containing circular references
JavaScript
4
star
19

mmr

Add reminders for yourself in directories
Rust
4
star
20

xstate

Ruby port of https://github.com/davidkpiano/xstate
Ruby
4
star
21

node-any-db-adapter-spec

Specification and test suite for any-db database adapters
JavaScript
4
star
22

php-guacamole-url-builder

Create signed URLs for use with guacamole-auth-hmac in PHP.
PHP
4
star
23

pct-encode

Standards compliant percent-encoding
JavaScript
4
star
24

js-is-function

JavaScript
3
star
25

codd

Golang representation of relational algebra
Go
3
star
26

markdown-code-blocks

JavaScript
3
star
27

node-any-db-mysql

MySQL adapter for any-db
JavaScript
3
star
28

eav

Go
3
star
29

api-console

Elm
2
star
30

yafsm

Yet-another-finite-state-machine
JavaScript
2
star
31

js-compose-promise

JavaScript
2
star
32

guacamole-server-debian

Packaging scripts for building guacamole-server from source on debian
Shell
2
star
33

rtorrent-client

cross-platform, wxPython based rtorrent xmlrpc client that attempts to minimize network usage
Python
2
star
34

chocolate-rain

A Cocoa based rTorrent front end
Objective-C
2
star
35

semver-intersection

JavaScript
2
star
36

js-prat

promise aware transform streams
JavaScript
1
star
37

prepend-listener

JavaScript
1
star
38

dev-mode

JavaScript
1
star
39

awesome-configs

Awesome configuration
Lua
1
star
40

code_garden

An interactive source code visualizer
1
star
41

moose

orm to work with nodejs
JavaScript
1
star
42

autotagfs

A python FUSE module that automatically tags media files based on their path
Python
1
star
43

js-create-class

JavaScript
1
star
44

js-doto

A JavaScript version of Clojure's 'doto macro
JavaScript
1
star
45

library

Library system - SDO project
Ruby
1
star
46

dyno

Dynamic tagging module for the awesome wm
Lua
1
star
47

drone-kubernetes

Shell
1
star
48

js-fast-getter

JavaScript
1
star
49

json.pony

Simple JSON parser for Ponylang
1
star
50

create-dependency-stream

Creates a stream of dependency objects from a parsed package.json file.
JavaScript
1
star
51

node-any-db-sqlite3

JavaScript
1
star
52

node-argv2http

Easily create declarative CLI wrappers for HTTP API's
JavaScript
1
star
53

vdom-rs

Rust
1
star
54

js-pure-objects

JavaScript
1
star
55

Pass-StatusBar

A status bar password manager using GPG2 encrypted files.
Ruby
1
star
56

foreign-state

Attach hidden state to arbitrary objects in JavaScript (like jQuery.data() without the jQuery)
JavaScript
1
star
57

node-sqlite3-reflect

Database reflection for sqlite3
JavaScript
1
star
58

js-set-object-path

JavaScript
1
star
59

coffee-sphinx

Coffee Script domain and autodoc support for Sphinx
Python
1
star