How to use event-stream - 10 common examples

To help you get started, we’ve selected a few event-stream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atomantic / undermore / gulp / tasks / undermore.js View on Github external
function cleanContent() {
    function transform(file, cb) {
        file.contents = new Buffer((function (src) {
            var lines = src.replace('_.mixin({\n','').split('\n'),
                last = lines.pop();
            // handle empty lines at the end of the file
            while(last===''){
                last = lines.pop();
            }
            return lines.join('\n');
        })(String(file.contents)));
        cb(null, file);
    }

    return require('event-stream').map(transform);
}
github flow-io / flow.io / lib / transform / index.js View on Github external
function getTransformer( func, clbk ) {
		if ( !arguments.length ) {
			throw new Error( 'getTransformer()::insufficient input arguments. Must provide a transformation function.' );
		}
		var stream = eventStream.map( function onData( data, callback ) {
			callback( null, func( data ) );
		});
		stream.on( 'error', function onError( error ) {
			if ( clbk ) {
				clbk( error );
				return;
			}
			console.error( error.stack );
		});
		return stream;
	} // end FUNCTION getTransformer()
github dominictarr / crdt / test / tcp.js View on Github external
function fromJSON(stream, name) {
  var split = es.split()
  split.pipe(es.log(name)).pipe(es.parse()).pipe(stream)
  return split
}
github laconalabs / elliptical-datetime / test / util.js View on Github external
function parse(phrase, langs, input, expectedDate, done) {
  function callback(err, data) {
    expect(data).to.have.length(3);
    expect(data[1].data.result.test).to.equalDate(expectedDate);
    expect(data[1].data.result.test).to.equalTime(expectedDate);
    done(null, data[1].data);
  }
  var parser = new lacona.Parser();
  parser.sentences = [phrase()];
  parser.langs = langs;

  es.readArray([input])
    .pipe(parser)
    .pipe(es.writeArray(callback));
}
github readthedocs / readthedocs.org / gulpfile.js View on Github external
gulp.task('build', function (done) {
    gulp_util.log('Building source files');

    es
        .merge(Object.keys(sources).map(function (n) {
            return build_app_sources(n, true);
        }))
        .pipe(es.wait(function (err, body) {
            gulp_util.log('Collecting static files');
            run('./manage.py collectstatic --noinput')
                .exec('', function (err) { done(err); });
        }));
});
github AccountGo / accountgo / src / WebAngular / gulpfile.js View on Github external
gulp.task('build-prod', ['build.lib'], function () {
    var tsProject = typescript.createProject('./tsconfig.json', { typescript: require('typescript') });
    var tsSrcInlined = gulp.src([webroot + '**/*.ts'], { base: webroot })
        .pipe(inlineNg2Template({ base: webroot }));
    return eventStream.merge(tsSrcInlined, gulp.src('Typings/**/*.ts'))
        .pipe(sourcemaps.init())
        .pipe(typescript(tsProject))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(webroot));
});
github Zeumo / datetime-picker / gulpfile.js View on Github external
var compileTemplate = function() {
  var transform = function(file, cb) {
    var name     = file.relative.replace(/\.html$/, '');
    var contents = file.contents.toString()
      .replace(/\"/g, '\\"')
      .replace(/\n/g, '');

    var content = 'templates["'+name+'"] = "'+contents+'";';

    file.contents = new Buffer(String(content));
    cb(null, file);
  };

  return eventStream.map(transform);
};
github Mallioch / Presentations / 2015_6_16__fwdnug_gulp / FWDNUG / FWDNUG / gulpfile.js View on Github external
function translate() {
    function transform(file, callback) {
        file.contents = new Buffer(file.contents.toString().replace('[$Yo$]', 'yo dawg'));

        callback(null, file);
    }
    return eventStream.map(transform);
}
github gulpjs / gulp / lib / createFileStream.js View on Github external
module.exports = function(path, opt) {
  if (!opt) opt = {};

  var file = {
    base: dirname(path),
    path: path
  };
  file.shortened = realBase(file.base, file.path);

  var stream = es.map(readFile);
  process.nextTick(function(){
    stream.write(file);
    stream.end();
  });
  return stream;
};
github kysonic / riot-mui / gulpfile.js View on Github external
gulp.task('bundle', function () {
    tagsStream = gulp.src('./src/**/*.tag')
        .pipe(riot({brackets:'{{ }}'}));
    es6Stream = gulp.src('./src/**/*.es6');
    eventStream.merge(tagsStream, es6Stream)
        .pipe(concat('riot-mui.js'))
        .pipe(babel({presets:['es2015']}))
        .pipe(minify())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./build/js'));
});

event-stream

construct pipes of streams of events

MIT
Latest version published 6 years ago

Package Health Score

61 / 100
Full package analysis