In this lesson, we'll filter a list of objects based on multiple conditions and we'll use Ramda's allPass function to create a joint predicate from multiple, individual predicate functions.

const R = require('ramda');

const { allPass, propEq, lte, propSatisfies, filter } = R;

const cars = [
{
name: 'suv',
doors: 4,
mpg: 19
},
{
name: 'sedan',
doors: 4,
mpg: 30
},
{
name: 'hybrid',
doors: 4,
mpg: 37
},
{
name: 'compact',
doors: 2,
mpg: 32
}
]; const mpgLte30 = propSatisfies(lte(R.__, 30), 'mpg');
const fourDoors = propEq('doors', 4);
const preds = allPass([
mpgLte30,
fourDoors
]);
const result = filter(preds)(cars);
console.log(result);

[Ramda] Filter an Array Based on Multiple Predicates with Ramda's allPass Function的更多相关文章

  1. [Ramda] Create an Array From a Seed Value with Ramda's unfold

    In this lesson we'll look at how you can use Ramda's unfold function to generate a list of values ba ...

  2. Wideband Direction of Arrival Estimation Based on Multiple Virtual Extension Arrays

    基于多重虚拟扩展阵列的宽带信号DOA估计[1]. 宽带DOA估计是阵列信号处理领域的一个重要研究方向.在DOAs估计的实际应用中,信号总是会被噪声破坏,在某些情况下,源信号的数量大于传感器的数量,因此 ...

  3. Resource Access Based on Multiple Credentials

    A collection of multiple user credentials each associated with one of multiple different users is ob ...

  4. [Ramda] Filter, Reject and Partition

    We'll learn how to get a subset of an array by specifying items to include with filter, or items to ...

  5. [ES2019] Use JavaScript ES2019 flatMap to Map and Filter an Array

    ES2019 introduces the Array.prototype.flatMap method. In this lesson, we'll investigate a common use ...

  6. [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 ...

  7. [Ramda] Create a Query String from an Object using Ramda's toPairs function

    In this lesson, we'll use Ramda's toPairs function, along with map, join, concatand compose to creat ...

  8. [Compose] 16. Apply multiple functors as arguments to a function (Applicatives)

    We find a couple of DOM nodes that may or may not exist and run a calculation on the page height usi ...

  9. BLESS学习笔记

    BLESS全称:Bloom-filter-based Error Correction Solution for High-throughput Sequencing Reads,即基于布隆过滤器的高 ...

随机推荐

  1. 【Codeforces Round #452 (Div. 2) A】 Splitting in Teams

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 贪心 1优先和2组队. 如果1没有了 就结束. 如果1还有多余的. 那么就自己3个3个组队 [代码] #include <bi ...

  2. 可执行EXE在windows调用过程

    举例图中, 一个C#编写的测试程序, 输出两句话分别 : Hello, GoodBye, 介绍其在windows上CLR的调用过程. 1.在执行Main方法之前, CLR会检测出Main的代码引用的所 ...

  3. CF #261 div2 D. Pashmak and Parmida&#39;s problem (树状数组版)

    Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants he ...

  4. Activity Test1

    源代码下载(免积分) :下载 Acitivty測试的API的父类是InstrumentationTestCase.这个类可以获取Instrumentation.来操作Activity. 对于acti ...

  5. A glance on VDBI

    Just like other thing in data transfter, a resource should have themselves description. And the reso ...

  6. 转 openssl 建立服务器证书

    openssl 建立服务器证书 ##  1,建立目录和文件     set path=D:/openssl/bin     D:     cd D:/openssl/conf/     ren ope ...

  7. 【Codeforces Round #429 (Div. 1) B】Leha and another game about graph

    [链接]点击打开链接 [题意] 给出一个连通图,并给每个点赋一个d值0或1或-1,要求选出一个边的集合,使得所有的点i要么d[i] == -1,要么  dgree[i] % 2 == d[i],dgr ...

  8. Session丢失原因与解决方案

    win2003 server下的IIS6默认设置下对每个运行在默认应用池中的工作者进程都会经过20多个小时后自动回收该进程,   造成保存在该进程中的session丢失. 因为Session,Appl ...

  9. winform最大化后不遮挡任务栏

    在窗体初始化后添加一句代码 this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;

  10. 写给自己的TypeScript 入门小纲

    前几日,在知乎上写了一些技术类的文章,有人私信问我,是不是要找一份工作,有没有想过要跳槽,然后我回到,你们公司都是用的什么框架什么技术,他罗列了一堆,其中就包含了TypeScript,我甚至不知道有这 ...