Functional programming Immutable.JS筛选深度嵌套集合筛选器中的集合

Functional programming Immutable.JS筛选深度嵌套集合筛选器中的集合,functional-programming,immutable.js,Functional Programming,Immutable.js,我正在使用Immutable.JS并尝试过滤嵌套在父集合中的列表,而不使用变量 这里有一个汽车收藏的例子: { { 1 => { id:'1', licencePlateNumber: 'BT 226 FQ', passengers: ['John', 'Marie', 'Edward'], }, { 2 => { id:'2', lice... ... }, } 爱德华很沮丧,不想再在周末和我们一起去了,这是我想

我正在使用Immutable.JS并尝试过滤嵌套在父集合中的列表,而不使用变量

这里有一个汽车收藏的例子:

{
  { 1 => {
    id:'1',
    licencePlateNumber: 'BT 226 FQ',
    passengers: ['John', 'Marie', 'Edward'],
  },

  { 2 => {
    id:'2', 
    lice...
    ...
  },
}
爱德华很沮丧,不想再在周末和我们一起去了,这是我想要的新系列

{
  { 1 => {
    id:'1',
    licencePlateNumber: 'BT 226 FQ',
    passengers: ['John', 'Marie'],
  },

  { 2 => {
    id:'2',  
    lice...
    ...
  },
}
为了做到这一点,我可以写:

const removePassenger = (carsCollection, carId, removedPassenger) => {
    const passengers = carsCollection
      .getIn([carId, 'passengers'])
      .filter(pName => pName !== removedPassenger)

    return (carsCollection.setIn([carId, 'passengers'], passengers))
}
作为一个函数式程序员,我觉得这很难看。相反,我更喜欢使用这样的函数“filterIn”

const removePassenger = (carsCollection, carId, removedPassenger) => {

    return (carsCollection
      .filterIn([carId, 'passengers'], pName => pName !== removedPassenger)
}
这样的函数存在吗?在医生里找不到这样的东西