How to use the event-stream.map function in event-stream

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 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;
};

event-stream

construct pipes of streams of events

MIT
Latest version published 6 years ago

Package Health Score

61 / 100
Full package analysis