source: trip-planner-front/node_modules/merge2/README.md@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.7 KB
Line 
1# merge2
2
3Merge multiple streams into one stream in sequence or parallel.
4
5[![NPM version][npm-image]][npm-url]
6[![Build Status][travis-image]][travis-url]
7[![Downloads][downloads-image]][downloads-url]
8
9## Install
10
11Install with [npm](https://npmjs.org/package/merge2)
12
13```sh
14npm install merge2
15```
16
17## Usage
18
19```js
20const gulp = require('gulp')
21const merge2 = require('merge2')
22const concat = require('gulp-concat')
23const minifyHtml = require('gulp-minify-html')
24const ngtemplate = require('gulp-ngtemplate')
25
26gulp.task('app-js', function () {
27 return merge2(
28 gulp.src('static/src/tpl/*.html')
29 .pipe(minifyHtml({empty: true}))
30 .pipe(ngtemplate({
31 module: 'genTemplates',
32 standalone: true
33 })
34 ), gulp.src([
35 'static/src/js/app.js',
36 'static/src/js/locale_zh-cn.js',
37 'static/src/js/router.js',
38 'static/src/js/tools.js',
39 'static/src/js/services.js',
40 'static/src/js/filters.js',
41 'static/src/js/directives.js',
42 'static/src/js/controllers.js'
43 ])
44 )
45 .pipe(concat('app.js'))
46 .pipe(gulp.dest('static/dist/js/'))
47})
48```
49
50```js
51const stream = merge2([stream1, stream2], stream3, {end: false})
52//...
53stream.add(stream4, stream5)
54//..
55stream.end()
56```
57
58```js
59// equal to merge2([stream1, stream2], stream3)
60const stream = merge2()
61stream.add([stream1, stream2])
62stream.add(stream3)
63```
64
65```js
66// merge order:
67// 1. merge `stream1`;
68// 2. merge `stream2` and `stream3` in parallel after `stream1` merged;
69// 3. merge 'stream4' after `stream2` and `stream3` merged;
70const stream = merge2(stream1, [stream2, stream3], stream4)
71
72// merge order:
73// 1. merge `stream5` and `stream6` in parallel after `stream4` merged;
74// 2. merge 'stream7' after `stream5` and `stream6` merged;
75stream.add([stream5, stream6], stream7)
76```
77
78```js
79// nest merge
80// equal to merge2(stream1, stream2, stream6, stream3, [stream4, stream5]);
81const streamA = merge2(stream1, stream2)
82const streamB = merge2(stream3, [stream4, stream5])
83const stream = merge2(streamA, streamB)
84streamA.add(stream6)
85```
86
87## API
88
89```js
90const merge2 = require('merge2')
91```
92
93### merge2()
94
95### merge2(options)
96
97### merge2(stream1, stream2, ..., streamN)
98
99### merge2(stream1, stream2, ..., streamN, options)
100
101### merge2(stream1, [stream2, stream3, ...], streamN, options)
102
103return a duplex stream (mergedStream). streams in array will be merged in parallel.
104
105### mergedStream.add(stream)
106
107### mergedStream.add(stream1, [stream2, stream3, ...], ...)
108
109return the mergedStream.
110
111### mergedStream.on('queueDrain', function() {})
112
113It 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.
114
115#### stream
116
117*option*
118Type: `Readable` or `Duplex` or `Transform` stream.
119
120#### options
121
122*option*
123Type: `Object`.
124
125* **end** - `Boolean` - if `end === false` then mergedStream will not be auto ended, you should end by yourself. **Default:** `undefined`
126
127* **pipeError** - `Boolean` - if `pipeError === true` then mergedStream will emit `error` event from source streams. **Default:** `undefined`
128
129* **objectMode** - `Boolean` . **Default:** `true`
130
131`objectMode` and other options(`highWaterMark`, `defaultEncoding` ...) is same as Node.js `Stream`.
132
133## License
134
135MIT © [Teambition](https://www.teambition.com)
136
137[npm-url]: https://npmjs.org/package/merge2
138[npm-image]: http://img.shields.io/npm/v/merge2.svg
139
140[travis-url]: https://travis-ci.org/teambition/merge2
141[travis-image]: http://img.shields.io/travis/teambition/merge2.svg
142
143[downloads-url]: https://npmjs.org/package/merge2
144[downloads-image]: http://img.shields.io/npm/dm/merge2.svg?style=flat-square
Note: See TracBrowser for help on using the repository browser.