[Ramda] Compose lenses
We can compose lenses to get value:
const addrs = [{street: '99 Walnut Dr.', zip: '04821'}, {street: '2321 Crane Way', zip: '08082'}]
const user = {id: 3, name: 'Charles Bronson', addresses: addrs}
const addresses = R.lensProp('addresses')
const street = R.lensProp('street')
const first = R.lensIndex(0)
const firstStreet = R.compose(addresses, first, street)
const res = R.view(firstStreet, user)
console.log(res) // '99 Walnut Dr.'
[Ramda] Compose lenses的更多相关文章
- [Ramda] Compose and Curry
Curry: The idea of Curry is to spreate the data from the function. Using Curry to define the functio ...
- [React] Update Component State in React With Ramda Lenses
In this lesson, we'll refactor a React component to use Ramda lenses to update our component state. ...
- [Ramda] Refactor to Point Free Functions with Ramda using compose and converge
In this lesson we'll take some existing code and refactor it using some functions from the Ramda lib ...
- [Ramda] Change Object Properties with Ramda Lenses
In this lesson we'll learn the basics of using lenses in Ramda and see how they enable you to focus ...
- [Ramda] Simple log function for debugging Compose function
const log = function(x){ console.log(x); return x; } const get = R.curry(function(prop, obj){ return ...
- [Ramda] Simple log function for debugging Compose function / Using R.tap for logging
const log = function(x){ console.log(x); return x; } const get = R.curry(function(prop, obj){ return ...
- [Ramda] Curry, Compose and Pipe examples
const curry = R.curry((fns, ary) => R.ap(fns, ary)); ), R.add()]); ,,]); console.log(res); //[2, ...
- 函数式编程-compose与pipe
函数式编程中有一种模式是通过组合多个函数的功能来实现一个组合函数.一般支持函数式编程的工具库都实现了这种模式,这种模式一般被称作compose与pipe.以函数式著称的Ramda工具库为例. cons ...
- [转] Ramda 函数库参考教程
学习函数式编程的过程中,我接触到了 Ramda.js. 我发现,这是一个很重要的库,提供了许多有用的方法,每个 JavaScript 程序员都应该掌握这个工具. 你可能会问,Underscore 和 ...
随机推荐
- Android控件开发之Gallery3D效果
package xiaosi.GalleryFlow; import android.app.Activity; import android.os.Bundle; public class Gall ...
- 自定义控件学习——仿qq侧滑栏
效果 主要步骤: 1. 在xml布局里摆放内容. include 2. 在自定义ViewGroup里, 进行measure测量, layout布局 3. 响应用户的触摸事件 4. i ...
- Linux下PortSentry的配置
Linux下PortSentry的配置 前年写过<IDS与IPS功能分析>一文,受到广大读者关注,现将近期有关IDS配置的文章和大家分享. Internet上的服务器一般 ...
- centos7 Another app is currently holding the yum lock; waiting for it to exit...
解决方法:rm -rf /var/run/yum.pid 来强行解除锁定,然后你的yum就可以运行了
- 洛谷 P1014 Cantor表
P1014 Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 ...
- 地图上显示div点位
功能核心: 地理坐标转屏幕坐标 用到的插件:jquery animo动画插件 核心代码: var point = new Point(lon, lat, map.spatialReference) ...
- DBLINK做系统集
过度使用DBLINK做系统集成会带来的问题 过度使用DBLINK做系统集成会带来很多问题,问题主要由以下几点: 1. 大量消耗数据库资源: 本地系统每通过DBLINK链接远端系统一次,都会生成一个本地 ...
- 81.内存模式实现cgi查询
创建全局的二级指针 char ** g_pp;//全局的二级指针 获取数据有多少行 //获取行数 int getimax() { ; FILE *pf = fopen(path, "r&qu ...
- subline Text3 安装及汉化
因为自己的subline 有问题 所以决心重新改一下了. 三步: http://www.sublimetext.com/3 官网下载subline3 https://www.imjeff. ...
- Java Web学习总结(3)——Servlet详解
一.ServletConfig讲解 1.1.配置Servlet初始化参数 在Servlet的配置文件web.xml中,可以使用一个或多个<init-param>标签为servlet配置一些 ...