New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flat-map

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat-map

flat map implementation for streams1

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
782
decreased by-3.34%
Maintainers
1
Weekly downloads
 
Created
Source

#flat-map Build Status

A flat map implementation for node streams

##Installation npm install flat-map

##Usage

When the callback data is already flat passes it maps it normally:

  var es = require('event-stream');
  var flatMap = require('flat-map');
  es.readArray([1, 2, 3, 4, 5])
    .pipe(flatMap(function(data, callback) { callback(null, data.split(/\s/); }));
  // [1, 2, 3, 4, 5]    

When the callback data is an array it flattens and maps it accordingly:

  var es = require('event-stream');
  var flatMap = require('flat-map');
  es.readArray('one two', 'three', 'four five')
    .pipe(flatMap(function(data, callback) { callback(null, data.split(/\s/); });
  // ['one', 'two', 'three', 'four', 'five']    

When the callback data is a stream it flattens and maps it accordingly:

  var es = require('event-stream');
  var flatMap = require('flat-map');
  es.readArray('one two', 'three', 'four five')
    .pipe(flatMap(function(data, callback) { callback(null, es.readArray(data.split(/\s+/))) });
  // ['one', 'two', 'three', 'four', 'five']    

When the callback data is a promise it flattens and maps it accordingly:

  var es = require('event-stream');
  var flatMap = require('flat-map');
  es.readArray('one two', 'three', 'four five')
      .pipe(flatMap(function(data, callback) {
        callback(null, new Promise(function(resolve) { resolve(data); }))
      }));
  // ['one', 'two', 'three', 'four', 'five']

Keywords

FAQs

Package last updated on 15 Dec 2017

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc