This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/papercraft/openjscad/node_modules/most/lib/combinator/observe.js

37 lines
1.1 KiB
JavaScript

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.observe = observe;
exports.drain = drain;
var _runSource = require('../runSource');
var _transform = require('./transform');
/**
* Observe all the event values in the stream in time order. The
* provided function `f` will be called for each event value
* @param {function(x:T):*} f function to call with each event value
* @param {Stream<T>} stream stream to observe
* @return {Promise} promise that fulfills after the stream ends without
* an error, or rejects if the stream ends with an error.
*/
/** @license MIT License (c) copyright 2010-2016 original author or authors */
/** @author Brian Cavalier */
/** @author John Hann */
function observe(f, stream) {
return drain((0, _transform.tap)(f, stream));
}
/**
* "Run" a stream by creating demand and consuming all events
* @param {Stream<T>} stream stream to drain
* @return {Promise} promise that fulfills after the stream ends without
* an error, or rejects if the stream ends with an error.
*/
function drain(stream) {
return (0, _runSource.withDefaultScheduler)(stream.source);
}