2.0.0 • Published 4 years ago

merge-stream v2.0.0

Weekly downloads
15,770,256
License
MIT
Repository
github
Last release
4 years ago

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

execajest-worker@webx/gulp@jadex/webx-core@jadex/webx-gulpvuedragdropuploadimages@animalus/gulp-dev-toolsreact-native-bluetooth2killi8n-react-native-fast-imagetestcafe-hammerhead-with-prrn-send-sms@rock-kit/ui-icons-buildlkutsenok-web-lab3specify-importsbabel-specify-imports@icanpm/api-masterprotocol-theme-teststartydinde@arisageha/react-lazyloadabota-buildbm_scaffold_async_router_testkirpi@mygooder/semantic@satche/workflowreact-native-template-rfbasedebox-web-corecloud-archive-s3vinus3vinus4@passageid/passage-js@nodecorejs/preset-built-inairscanairscan-exampledas-buildbb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-moduletzar-core@frxf/frxfdeneme323112agree-ss-clientagree-te-client-testqgy@texttree/demo-bsa-reference-rcl@fundefund/funde_ck@ntt_app/react-native-custom-notification@spothero/acereact-native-custom-text-hwjames@temporg/ui-icons-buildjoyerreact-native-covid-sdkgql_din_mod@wctools/polymer-project-builderbitget@src-works/npm-ts-gulpreact-native-thanh-toast-librarychoerodon-hap-front-boot@jttechnic/interpreter@thanhnguyen14797/react-native-thanh-toast-library@wellbye/metro@whalecloud/fish-cli@webtides/tasks@winfe/preset-built-vmiacetone@z1399/zeta-packer@z1399/zeta-packer-betaBuildBoxEventFieldGulp-TasksFrontend-starter@zebracompany/f_editor@zilue/aspnetcore.mvc.ui@xupengfly2061/boot@xandme-protocol/coreairbagsais-sp-js-deploymentalfamt-cars-logotypesaldo-react-component-gulp-tasks@yak-spirit/yak-swap-ui@xswap/token-listsBMFE_scaffoldYworkshell@yproximite/yprox-cliah-veeva-exporter@iobroker-community-adapters/iobroker.device-watchergulp-pipeline@olivervorasai/slidermysql-formatreact-native-printer-brothersrefresh-vinyl-fsrn-pdf-reader-offlinetools-packcbmis-ai-toolboxant-design-draggable-modal-4ant-design-draggable-modal-fixant-design-draggable-modal-fix-2backtemplateandromeda-astorefomantic-ui-semeia@newhorizon-tech/dd-npm-package-templatereact-native-shekhar-bridge-test
2.0.0

4 years ago

1.0.1

6 years ago

1.0.0

7 years ago

0.1.8

7 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

9 years ago

0.0.1

9 years ago

0.1.0

9 years ago

0.0.0

9 years ago