Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flatmap-fast

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatmap-fast

A fast and modern flatMap for node. Monads for the win!

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Gitpod ready-to-code

flatmap-fast

The fastest flatMap this side of node.

Takes two arguments:

  1. An array.
  2. A callback function (optional).
const flatMap = require("flatmap-fast");

const testArr = ['Hi', 'World'];
const splitWord = (word) => word.split('');

flatMap(testArr, splitWord);

// => ['H', 'i', 'W', 'o', 'r', 'l', 'd']

flatMap([1, 2, 3, 4], (x) => [x, x * 2]);

// => [1, 2, 2, 4, 3, 6, 4, 8]

Run npm test to test this flatMap against other flatMaps.

$ node --version
v12.18.3
$ yarn test
yarn run v1.22.4
$ node test.js
// => flatMapFast took: 650.86651 milliseconds.
[
  'H', 'i', 'W',
  'o', 'r', 'l',
  'd'
]
// => flatmapjs took: 667.361729 milliseconds.
[
  'H', 'i', 'W',
  'o', 'r', 'l',
  'd'
]
// => flatMapFast took: 517.463478 milliseconds.
[
  1, 2, 2, 4,
  3, 6, 4, 8
]
// => flatmapjs took: 676.208413 milliseconds.
[
  1, 2, 2, 4,
  3, 6, 4, 8
]
Done in 2.74s.

Keywords

FAQs

Package last updated on 29 Jan 2021

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