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

@saber2pr/fp

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saber2pr/fp

> functional programing in async & sync.

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@saber2pr/fp

npm

functional programing in async | sync | lazy.

# from npm
npm install @saber2pr/fp

# from github
git clone https://github.com/Saber2pr/fp.git

Why

If you often program with node.js, there will be some bad cases in async, like this:

const contents = await Promise.all(
  ['./1.txt', './2.txt'].map(async file_name => ({
    content1: await readFile(file_name).then(buffer => buffer.toString()),
    content2: await readFile(file_name).then(buffer => buffer.toString())
  }))
)

then you get a bad result, the contents.content1 and contents.content2 is a Promise

How to deal with it?

Now, there is a function named async_map to it:

const contents = async_map(['./1.txt', './2.txt'], async file_name => ({
  content1: await readFile(file_name).then(buffer => buffer.toString()),
  content2: await readFile(file_name).then(buffer => buffer.toString())
}))

you will get a result and the contents.content1 and contents.content2 is the correct type "string".

what's more...

API

compose

pipe

setter

async_reduce

async_reduceRight

async_compose

async_pipe

async_setter

async_forEach

async_filter

async_intercept

async_map

*range

*map

*filter

*reduce

toIt

from


start

npm install
npm start

npm test

Author: saber2pr


develope and test

you should write ts in /src

you should make test in /src/test

export your core in /src/index.ts!

Keywords

FAQs

Package last updated on 21 Jun 2019

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