[Ramda] Filter, Reject and Partition
and filter partition Ramda
2023-09-14 09:00:53 时间
We'll learn how to get a subset of an array by specifying items to include with filter, or items to exclude using reject. We'll also look at how to get the results from both filter and reject, neatly separated with partition.
// we don't need to require in Plunker! //const R = require('ramda') const pets = [ {name: 'Spike', type: 'dog'}, {name: 'Mittens', type: 'cat'}, {name: 'Rover', type: 'dog'}, {name: 'Fluffy', type: 'cat'}, {name: 'Fido', type: 'dog'} ] const dogCheck = pet => pet.type == 'dog' // const result = R.filter(dogCheck, pets) // const result = R.reject(dogCheck, pets) const result = R.partition(dogCheck, pets) console.log(result) document.getElementById('output').innerHTML = `${JSON.stringify(result)}`
/* [
[{"name":"Spike","type":"dog"},{"name":"Rover","type":"dog"},
{"name":"Fido","type":"dog"}],
[{"name":"Mittens","type":"cat"},{"name":"Fluffy","type":"cat"}]
] */
相关文章
- [AWS DA] AWS Monitoring & Audit: CloudWatch, X-Ray and CloudTrail
- [Rust] Load a WebAssembly Function Written in Rust and Invoke it from JavaScript
- [Angular2 Form] Create and Submit an Angular 2 Form using ngForm
- [Ramda] Filter, Reject and Partition
- [Javascript] Chaining the Array map and filter methods
- [RxJS] Use filter and partition for conditional logic
- [Typescript] Dictionary map, filter and reduce
- [Typescript] Dynamic types: Use TypeScript's Mapped Types and Template Literal Types Together
- [CSS] Use CSS pseudo-elements and mix-blend-mode to Create a Duotone Style Effect
- [ES2019] Use JavaScript ES2019 flatMap to Map and Filter an Array
- [CSS] Manipulate Images Using CSS Filter and Blend Modes
- [Hapi.js] POST and PUT request payloads
- OPA start up and wait for
- SAP CRM Fiori Report paramter and filter source
- Observe and check how filter works in HANA live report
- Atitit jpql ast总结v2 t025.docx 目录 1.1. 多select字段 1 1.2. 多个and条件 (ok) 2 1.3. Select 字段函数(聚合等) 2 1.4. [
- Atitit.struts排除url 的设计and 原理 自定义filter 排除特定url
- 【Codeforces Round #635 (Div. 2) E】Kaavi and Magic Spell
- 【codeforces 46C】Hamsters and Tigers
- TimeInterval value and value2 determination in SalesPipeline
- 论文解读一代GCN《Spectral Networks and Locally Connected Networks on Graphs》
- hdu 5055 Bob and math problem
- C/C++学习笔记十二 Input and Output (I/O)(2)