question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Theoretical question about forking a stream in gulp

See original GitHub issue

Hey there. I’m relatively new to gulp and streams but I have the following situation. I have two pipelines A and B where A and B both have 5 steps in the pipeline where the first 3 are the same. Theoretically and from an efficiency standpoint it would make sense to use the same pipeline for the first 3 steps and then fork the pipeline into two separate ones.

I’d think of something like this:

gulp.src('./src/*.js')
  .pipe(sharedOne())
  .pipe(sharedTwo())
  .pipe(sharedThree())
  .pipe(gulp.fork(function(a, b) {
    return eventStream.merge(
      a.pipe(aOne()).pipe(aTwo()),
      b.pipe(bOne()).pipe(bTwo())
    );
  }));

I’m sorry if I don’t make any sense or if there is already a known stream utility like this but as I sad I’m relatively new to this.

Any help would be much appreciated.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:30 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
heikkicommented, Feb 15, 2015

gulp-clone

var gulp = require('gulp');
var clone = require('gulp-clone');
var es = require('event-stream');
var concat = require('gulp-concat');
var rename = require('gulp-rename');

gulp.task('clone', function() {
    var all = gulp.src('src/**/*.js').pipe(concat('all.js'));
    var a = all.pipe(clone()).pipe(rename('browser.js'));
    var b = all.pipe(clone()).pipe(rename('common.js'));
    return es.merge(a, b).pipe(gulp.dest('dest'));
});

gulp-mirror

var gulp = require('gulp');
var mirror = require('gulp-mirror');
var concat = require('gulp-concat');
var rename = require('gulp-rename');

gulp.task('mirror', function() {
    return gulp.src('src/**/*.js')
        .pipe(concat('all.js'))
        .pipe(mirror(
            rename('browser.js'),
            rename('common.js')
        ))
        .pipe(gulp.dest('dest'));
});

–edit

Fixed gulp-mirror example (maybe)

1reaction
gionkunzcommented, Feb 15, 2015

A repository with a README containing known and useful streaming modules would be awesome… It’s so hard to find the right terminology for such abstract problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing a stream between two gulp tasks? - Stack Overflow
Very common pattern in gulp builds. patterns are gathered into a single paths variable; each task begins with a "src" plugin (very often...
Read more >
Node.js v19.3.0 Documentation
Creates and returns a new Blob containing a subset of this Blob objects data. The original Blob is not altered. blob.stream() #. Added...
Read more >
Writing my own build system: Coupling gulp concepts with ...
It's a nice concept in theory: something generates a stream of files, and one can add various processors to manipulate the stream and...
Read more >
@dash14/svg-pan-zoom - npm
JavaScript library for panning and zooming an SVG image from the mouse, touches and programmatically.. Latest version: 3.6.9, last published: 3 months ago....
Read more >
Node.js Interview Questions Examples With The Answers
js programming interview questions about work experience, focus on hands-on experience rather than theoretical education. That is, prioritize ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found