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. thinkphp 整合 swiftmailer 实现邮件发送

    thinkphp swiftmailer(phpmailer) 文件夹结构 图 1 swiftmailer-phpmailer 将swiftmailer整合到thinkphp中.如上图 1 我下载的版 ...

  2. cocos2d-x嵌入移动MM短代支付IAP2.4的SDK,点击支付崩溃的解决的方法

    凡是用IAP2.4,调用purchase.order 游戏崩溃.logcat报错是: 06-16 18:43:42.944: E/AndroidRuntime(8526): FATAL EXCEPTI ...

  3. bitmap2drawable-两者的转化实现

    先来看今天遇到的一个问题,是关于mms报错的.后来发现报的地方如下 Bitmap deleteBitMap = ((BitmapDrawable)mChipDelete).getBitmap(); D ...

  4. Android时间对话框TimePickerDialog介绍

    目前网上流行着很多对“时间对话框TimePickerDialog”的讲解文章,但感觉都不是很详细.这里详细对该方面的知识进行介绍,旨在帮助初学者能够快速掌握该项技术. 首先要做的是声明一个日历类的对象 ...

  5. docker网络访问

    一 docker网络访问 描述: 在启动容器的时候,如果不指定对应的参数,在容器外部是无法通过网络来访问容器内的网络应用和服务的.当容器中运行一些网络应用,要让外部访问这些应用时,可以通过-P或者-p ...

  6. Android BuildConfig:Gradle自定义你的BuildConfig

    在很早之前我发布了这篇博客Android BuildConfig.DEBUG的妙用, 提到了Eclipse中通过BuildConfig.DEBUG字段用来调试Log非常好用,但是殊不知在Android ...

  7. upf1

    创建supply net,两种方法 1. creat_supply_net VDD -domain PD_B 2. creat_supply_net VDD

  8. CSS两列布局——左侧宽度固定,右侧宽度自适应的3种方法

    1.左侧绝对定位法 直接看代码: <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  9. vs2008,2010,2012安装包下载

    近期在csdn学院当老师啦.把自己以学到的东西总结一下,录个视频给大家,也当发一下福利.这些以后都是自己无形的財产.哈哈. 安装与下载编程工具 Vs2008下载地址:http://pan.baidu. ...

  10. linux 查看 *.a *.so 符号表(zt)

    objdump -tT libName.so | grep symbel symbolName nm -D libName.so | grep symbel symbolName 很多非常熟悉wind ...