首页 > 代码库 > [Ramda] allPass, propEq

[Ramda] allPass, propEq

const needs = [wifi, shower, laundry];const homes = [{  name: Home 1,  wifi: y,  shower: y,  laundry: y,  metro: n,  balcony: y,  fireplace: n,  pool: y}, {  name: Home 2,  wifi: n,  shower: y,  laundry: y,  metro: n,  balcony: n,  fireplace: n,  pool: n}, {  name: Home 3,  wifi: y,  shower: y,  laundry: y,  metro: n,  balcony: y,  fireplace: y,  pool: n}, {  name: Home 4,  wifi: y,  shower: y,  laundry: n,  metro: n,  balcony: n,  fireplace: n,  pool: n}];const propMatch = R.curry((toMatch, prop) => R.propEq(prop, toMatch));const needsCheck = R.map(propMatch(y), needs);const allNeedsMatch = R.allPass(needsCheck);const res = R.filter(allNeedsMatch, homes);console.log(res)

 

[Ramda] allPass, propEq