Recursively filter array of objects

后端 未结 7 942
一个人的身影
一个人的身影 2020-11-29 00:00

Hitting a wall with this one, thought I would post it here in case some kind soul has come across a similar one. I have some data that looks something like this:

<         


        
7条回答
  •  鱼传尺愫
    2020-11-29 00:19

    Alternatively you can use _.filterDeep method from deepdash extension for lodash:

    var keyword = 'Hit';
    var foundHit = _.filterDeep(
      input,
      function(value) {
        return value.value.includes(keyword);
      },
      {
        tree: true,
        onTrue: { skipChildren: true },
      }
    );
    

    Here is a full test for your case

提交回复
热议问题