用 JavaScript 进行函数式编程 fpEs

码农软件 · 软件分类 · 常用JavaScript包 · 2019-04-04 15:13:30

软件介绍

fpEs 是一个 JavaScript 库,可让你使用 EcmaScript(Javascript) 进行函数式编程。

作者表示,之所以开发这个项目是因为自己需要使用 Optional & Rx-like & PubSub 这些功能的一些特性,如果同时引入它们,项目又会变得很重。因此他的这个实现只包含核心功能,并且使用起来更加清晰。

用法

引入整个库

import fpEs from 'fpEs';

该库包含了 5 个模块,可以单独引用它们:

  • Facades:

    • maybe

    • monadio

    • publisher

  • FP functions:

    • fp

    • pattern

只需引用你需要的东西:

import Maybe from "fpEs";
// or this one:
/*
import Maybe from "fpEs/maybe";
*/

var m = Maybe.just(1); // It works

or

import {
  compose, curry,
} from "fpEs";

or

import {
  compose, curry,
} from "fpEs/fp";

Common FP (Compose, Curry)

import {
  compose, curry,
} from "fpEs/fp";

// compose

console.log(compose((x)=>x-8, (x)=>x+10, (x)=>x*10)(4)) // 42
console.log(compose((x)=>x+2, (x,y)=>x*y)(4,10)) // 42

// curry

console.log(curry((x, y, z) => x + y + z)(1,2,3)) // 6
console.log(curry((x, y, z) => x + y + z)(1)(2,3)) // 6
console.log(curry((x, y, z) => x + y + z)(1,2)(3)) // 6
console.log(curry((x, y, z) => x + y + z)(1)(2)(3)) // 6

本文地址:https://codercto.com/soft/d/2848.html

Beginning iPhone and iPad Web Apps

Beginning iPhone and iPad Web Apps

Chris Apers、Daniel Paterson / Apress / 2010-12-15 / USD 39.99

It seems that everyone and her sister has developed an iPhone App—everyone except you, the hard-working web professional. And now with the introduction of the iPad, you may even feel farther behind. B......一起来看看 《Beginning iPhone and iPad Web Apps》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具