1.4.1 • Published 4 years ago

merge2 v1.4.1

Weekly downloads
13,602,134
License
MIT
Repository
github
Last release
4 years ago

merge2

Merge multiple streams into one stream in sequence or parallel.

NPM version Build Status Downloads

Install

Install with npm

npm install merge2

Usage

const gulp = require('gulp')
const merge2 = require('merge2')
const concat = require('gulp-concat')
const minifyHtml = require('gulp-minify-html')
const ngtemplate = require('gulp-ngtemplate')

gulp.task('app-js', function () {
  return merge2(
      gulp.src('static/src/tpl/*.html')
        .pipe(minifyHtml({empty: true}))
        .pipe(ngtemplate({
          module: 'genTemplates',
          standalone: true
        })
      ), gulp.src([
        'static/src/js/app.js',
        'static/src/js/locale_zh-cn.js',
        'static/src/js/router.js',
        'static/src/js/tools.js',
        'static/src/js/services.js',
        'static/src/js/filters.js',
        'static/src/js/directives.js',
        'static/src/js/controllers.js'
      ])
    )
    .pipe(concat('app.js'))
    .pipe(gulp.dest('static/dist/js/'))
})
const stream = merge2([stream1, stream2], stream3, {end: false})
//...
stream.add(stream4, stream5)
//..
stream.end()
// equal to merge2([stream1, stream2], stream3)
const stream = merge2()
stream.add([stream1, stream2])
stream.add(stream3)
// merge order:
//   1. merge `stream1`;
//   2. merge `stream2` and `stream3` in parallel after `stream1` merged;
//   3. merge 'stream4' after `stream2` and `stream3` merged;
const stream = merge2(stream1, [stream2, stream3], stream4)

// merge order:
//   1. merge `stream5` and `stream6` in parallel after `stream4` merged;
//   2. merge 'stream7' after `stream5` and `stream6` merged;
stream.add([stream5, stream6], stream7)
// nest merge
// equal to merge2(stream1, stream2, stream6, stream3, [stream4, stream5]);
const streamA = merge2(stream1, stream2)
const streamB = merge2(stream3, [stream4, stream5])
const stream = merge2(streamA, streamB)
streamA.add(stream6)

API

const merge2 = require('merge2')

merge2()

merge2(options)

merge2(stream1, stream2, ..., streamN)

merge2(stream1, stream2, ..., streamN, options)

merge2(stream1, stream2, stream3, ..., streamN, options)

return a duplex stream (mergedStream). streams in array will be merged in parallel.

mergedStream.add(stream)

mergedStream.add(stream1, stream2, stream3, ..., ...)

return the mergedStream.

mergedStream.on('queueDrain', function() {})

It will emit 'queueDrain' when all streams merged. If you set end === false in options, this event give you a notice that should add more streams to merge or end the mergedStream.

stream

option Type: Readable or Duplex or Transform stream.

options

option Type: Object.

  • end - Boolean - if end === false then mergedStream will not be auto ended, you should end by yourself. Default: undefined

  • pipeError - Boolean - if pipeError === true then mergedStream will emit error event from source streams. Default: undefined

  • objectMode - Boolean . Default: true

objectMode and other options(highWaterMark, defaultEncoding ...) is same as Node.js Stream.

License

MIT © Teambition

fast-glob@violetx/buildarchetype-librarycomponennentteasy-select-rnvuedragdropuploadimageslpbtreact-native-bluetooth2killi8n-react-native-fast-imagefix-fast-glob-nftcheckit-hub-ui@angrymonkeycloud/cloudmaterube-toolsdw-mx-packing-tools@velopert/practice@satche/workflowairscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfdeneme323112mlamp-icons@texttree/demo-bsa-reference-rcl@fundefund/funde_ckshulan_tools@ntt_app/react-native-custom-notificationdr-comp-packagereact-native-covid-sdkgql_din_modgulp-useref-replace@saeon/ol-react@saeon/quick-formpropeller-schema-model@olivervorasai/slidermysql-formatreact-native-printer-brothersssr-base-yf@byteinspire/cli@cliffdotai/atomic-toolsreact-native-shekhar-bridge-testonlinex-ui-toolscogoportutilsuncoded-connect@reversodev/oceanic-fleetlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29wilscanner@khalitovadel/abstract-repository@oiti/documentoscopy-react-nativejs4cytoscape@mink-opn/build-tokensquoc-testunblock-block-save-variables@prodam/prodam-typescclibyarntest@saaspe/componentshyperpass-sdkexpand-react-bridgeopea-bootstraapluminos-ui-corelit-tailwind-poc-2sklif-ui-kitsklif-apits-handyjawwy-sdkjawwy_gamification_release@314oner_npm/universal-components-library@deepakorg/test@deepak757/testreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgplus.webclient.buildp149-table@rabailriaz/hisaab-web-portalsklif-uimachinebeemrcapsrcf-tea-testnet@mediakular/svelte-data-gridreact-native-jawwy_samplemx-toolsmxmilsmyui5librarychenmyui5librarymobomyzallng-search-dropdownng1-template-gulpnka-gantt-task-reactmtva-teleport-tool
1.4.1

4 years ago

1.4.0

4 years ago

1.3.0

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

0.3.7

8 years ago

1.0.0

8 years ago

0.3.6

9 years ago

0.3.5

9 years ago

0.3.4

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago