34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.flatMap = flatMap;
|
||
|
exports.join = join;
|
||
|
|
||
|
var _mergeConcurrently = require('./mergeConcurrently');
|
||
|
|
||
|
/**
|
||
|
* Map each value in the stream to a new stream, and merge it into the
|
||
|
* returned outer stream. Event arrival times are preserved.
|
||
|
* @param {function(x:*):Stream} f chaining function, must return a Stream
|
||
|
* @param {Stream} stream
|
||
|
* @returns {Stream} new stream containing all events from each stream returned by f
|
||
|
*/
|
||
|
function flatMap(f, stream) {
|
||
|
return (0, _mergeConcurrently.mergeMapConcurrently)(f, Infinity, stream);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Monadic join. Flatten a Stream<Stream<X>> to Stream<X> by merging inner
|
||
|
* streams to the outer. Event arrival times are preserved.
|
||
|
* @param {Stream<Stream<X>>} stream stream of streams
|
||
|
* @returns {Stream<X>} new stream containing all events of all inner streams
|
||
|
*/
|
||
|
/** @license MIT License (c) copyright 2010-2016 original author or authors */
|
||
|
/** @author Brian Cavalier */
|
||
|
/** @author John Hann */
|
||
|
|
||
|
function join(stream) {
|
||
|
return (0, _mergeConcurrently.mergeConcurrently)(Infinity, stream);
|
||
|
}
|