Socket
Socket
Sign inDemoInstall

gulp-flatmap

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-flatmap


Version published
Weekly downloads
12K
decreased by-24.48%
Maintainers
1
Install size
271 kB
Created
Weekly downloads
 

Readme

Source

gulp-flatmap

map each file in a stream into multiple files that are piped out

Install

$ npm install --save-dev gulp-flatmap

Usage

var gulp = require('gulp');
var flatmap = require('gulp-flatmap');
var uglify = require('gulp-uglify');
var path = require('path');
var concat = require('gulp-concat');

gulp.task('default', function () {
  return gulp.src('*.json')
    .pipe(flatmap(function(stream, file){
      var contents = JSON.parse(file.contents.toString('utf8'));
      //contents.files is an array
      return gulp.src(contents.files)
        //uglify each file individually
        .pipe(uglify())
        //combine the files
        .pipe(concat(path.basename(file.path)));
    }))
    .pipe(gulp.dest('dist'));
});

API

The flatmap method takes one argument, a function. This function is called once for each file piped to flatmap and is passed a stream as its first argument and the vinyl file as its second argument. The stream contains only one file.

You can now pipe this stream through as many steps as you want, before returning it from the function. All the streams returned from flatmap will be combined and their contents will be emited by flatmap.

License

MIT © Marius Gundersen

Keywords

FAQs

Last updated on 10 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc