Stream 吞咽分流,使用两个目的地(溪流)
我有一条小溪在吞咽,但我想把小溪分成两部分,一半放在一个目的地,另一半放在另一个目的地 我的想法是,我需要将流分叉两次,过滤每个新流,对每个流使用Stream 吞咽分流,使用两个目的地(溪流),stream,gulp,Stream,Gulp,我有一条小溪在吞咽,但我想把小溪分成两部分,一半放在一个目的地,另一半放在另一个目的地 我的想法是,我需要将流分叉两次,过滤每个新流,对每个流使用gulp.dest,然后将它们合并回gulp 我现在有密码 function dumpCpuProfiles(profileDirectory) { const _ = require('highland'); const stream = _(); const cpuProfiles = stream .fork() .
gulp.dest
,然后将它们合并回gulp
我现在有密码
function dumpCpuProfiles(profileDirectory) {
const _ = require('highland');
const stream = _();
const cpuProfiles = stream
.fork()
.pipe(filter('*.cpuprofile'))
.pipe(gulp.dest(profileDirectory));
const noCpuProfiles = _(cpuProfiles).filter(() => false);
const otherFiles = stream
.fork()
.pipe(filter(['**', '!**/*.cpuprofile']));
return _([noCpuProfiles, otherFiles]).merge();
}
但是,我得到了错误
TypeError: src.pull is not a function
at /home/user/project/node_modules/highland/lib/index.js:3493:17
at Array.forEach (native)
at pullFromAllSources (/home/user/project/node_modules/highland/lib/index.js:3492:15)
at Stream._generator (/home/user/project/node_modules/highland/lib/index.js:3449:13)
at Stream._runGenerator (/home/user/project/node_modules/highland/lib/index.js:949:10)
at Stream.resume (/home/user/project/node_modules/highland/lib/index.js:811:22)
at Stream._checkBackPressure (/home/user/project/node_modules/highland/lib/index.js:713:17)
at Stream.resume (/home/user/project/node_modules/highland/lib/index.js:806:29)
at Stream.pipe (/home/user/project/node_modules/highland/lib/index.js:895:7)
at Gulp.<anonymous> (/home/user/project/gulpfile.js:189:6)
TypeError:src.pull不是函数
at/home/user/project/node_modules/highland/lib/index.js:3493:17
at Array.forEach(本机)
在pullFromAllSources(/home/user/project/node\u modules/highland/lib/index.js:3492:15)
正在运行。_生成器(/home/user/project/node_modules/highland/lib/index.js:3449:13)
正在运行。_runGenerator(/home/user/project/node\u modules/highland/lib/index.js:949:10)
在Stream.resume(/home/user/project/node_modules/highland/lib/index.js:811:22)
正在运行。_检查背压(/home/user/project/node_modules/highland/lib/index.js:713:17)
在Stream.resume(/home/user/project/node_modules/highland/lib/index.js:806:29)
在Stream.pipe(/home/user/project/node_modules/highland/lib/index.js:895:7)
狼吞虎咽。(/home/user/project/gulpfile.js:189:6)
输出是一个流,所以我不太确定错误是关于什么的。任何帮助都会非常有用!谢谢 我用这个小把戏来实现它
Object.prototype.fork = function(_fn) {
_fn(this);
return this;
};
Stream是唯一的事件发射器,pipe方法不会返回旧的流,而是返回一个新的流,所以您可以非常轻松地构建fork功能。我使用这个小小的monkeypatching技巧来实现它
Object.prototype.fork = function(_fn) {
_fn(this);
return this;
};
流是唯一的事件发射器,管道方法不返回旧的流,而是返回一个新的流,所以您可以非常轻松地构建fork功能