[Ramda] Declaratively Map Data Transformations to Object Properties Using Ramda evolve
We don't always control the data we need in our applications, and that means we often find ourselves massaging and transforming our data. In this lesson, we'll learn how to transform objects in a declarative way using ramda's evolve function.
Assume we have this object:
const product = {
name: 'cog',
price: ,
details: {
shippingInfo: {
weight: ,
method: 'ups'
}
}
}
Let's say we have to do
- Uppcase for name
- Double price
- Change weight to 8
Using Ramda's evolve:
const product = {
name: 'cog',
price: ,
details: {
shippingInfo: {
weight: ,
method: 'ups'
}
}
} const transformation = {
name: R.toUpper,
price: R.multiply(),
details: {
shippingInfo: {
weight: R.inc
}
}
};
const adjustProduct = R.evolve(transformation);
const result = adjustProduct(product)
[Ramda] Declaratively Map Data Transformations to Object Properties Using Ramda evolve的更多相关文章
- [Ramda] Declaratively Map Predicates to Object Properties Using Ramda where
Sometimes you need to filter an array of objects or perform other conditional logic based on a combi ...
- [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] R.project -- Select a Subset of Properties from a Collection of Objects in Ramda
In this lesson we'll take an array of objects and map it to a new array where each object is a subse ...
- Manipulating Data from Oracle Object Storage to ADW with Oracle Data Integrator (ODI)
0. Introduction and Prerequisites This article presents an overview on how to use Oracle Data Integr ...
- [Javascript Crocks] Safely Access Object Properties with `prop`
In this lesson, we’ll use a Maybe to safely operate on properties of an object that could be undefin ...
- [Ramda] Convert a QueryString to an Object using Function Composition in Ramda
In this lesson we'll use a handful of Ramda's utility functions to take a queryString full of name/v ...
- [Angular 2] Passing data to components with 'properties'
Besides @Input(), we can also use properties on the @Component, to pass the data. import {Component, ...
- 重构改善既有代码设计--重构手法19:Replace Data Value with Object (以对象取代数据值)
你有一笔数据项(data item),需要额外的数据和行为. 将这笔数据项变成一个对象. class Order... private string customer; ==> class Or ...
- html5 嵌入元素 img map areaiframe embed meter object meter
<img src="路径"> src 路径可以是img.jpg 也可以是 绝对和相对路径+img.jpg <img src="路径 ...
随机推荐
- 使用Multiplayer Networking做一个简单的多人游戏例子-1/2
原文地址: http://blog.csdn.net/cocos2der/article/details/51006463 本文主要讲述了如何使用Multiplayer Networking开发多人游 ...
- xcode6.3 模版位置
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templ ...
- 79.cgi硬盘查询个人信息
运行截图: 把cgi编码转为char*类型 //把cgi编码转为char*类型 char* change(char *str) { //分配内存 ); //x是tempstr的下标,y是str的下标 ...
- css 0.5px
1. 利用css3新属性scale(好用推荐) 其实现的关键就是利用before或after伪元素,宽高同时设为200%,然后再缩放0.5,自然就是0.5px了 代码如下: div { positon ...
- 【习题 6-5 UVA-1600】Patrol Robot
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 设dis[x][y][z]表示到(x,y)连续走了z个墙的最短路 bfs一下就ok [代码] /* 1.Shoud it use l ...
- vuepress折腾记
由于格式比较乱,所以直接拿图片粘贴过来了,详情请看原文链接https://lewiscutey.github.io/blog/blog/vuepress-theme-toos.html
- POJ 1852 Ants || UVA 10881 - Piotr's Ants 经典的蚂蚁问题
两题很有趣挺经典的蚂蚁问题. 1.n只蚂蚁以1cm/s的速度在长为L的竿上爬行,当蚂蚁爬到竿子的端点就会掉落.当两只蚂蚁相撞时,只能各自反向爬回去.对于每只蚂蚁,给出距离左端的距离xi,但不知道它的朝 ...
- Webpack学习手册
多端阅读<Webpack官方文档>: 在PC/MAC上查看:下载w3cschool客户端,进入客户端后通过搜索当前教程手册的名称并下载,就可以查看当前离线教程文档.下载Webpack官方文 ...
- 【Codeforces Round #301 (Div. 2) E】Infinite Inversions
[链接] 我是链接,点我呀:) [题意] 给你一个无限长的序列1,2,3,4... 然后给你n个操作. 每个操作ai,bi; 表示调换位置为ai和位置为bi的数的位置. (ai,bi<=10^9 ...
- java和 javaw 以及 javaws的区别
http://blog.csdn.net/topwqp/article/details/8595936