Javascript 以rxjs方式删除对象的一部分

Javascript 以rxjs方式删除对象的一部分,javascript,angular,typescript,rxjs,Javascript,Angular,Typescript,Rxjs,我的目标如下: const myObject = { items:[ { name: 'John', age: 35, children: [ { child: 'Eric', age: 10, sex: 'M' }, { child: 'Andrea', age: 4, sex:

我的目标如下:

const myObject = {
  items:[
    {
      name: 'John',
      age: 35,
      children: [
        {
          child: 'Eric',
          age: 10,
          sex: 'M'
        },
        {
          child: 'Andrea',
          age: 4,
          sex: 'F'
        }
      ]
    },
    {
      name: 'Bob',
      age: 23,
      children: [
        {
          child: 'Oscar',
          age: 1,
          sex: 'M'
        }
      ]
    }
  ]
}
我通过添加以下内容过滤结果:

const source = of(myObject).pipe(
  map(x => x.items),
  map(x => {
    return x.filter(y => {
      return y.children.find(y => y.sex === 'M');
    })
  })
);

source.subscribe(x => console.log(x));
按性别筛选确实有效,但我想从json中删除女性孩子。在这种情况下,应将Andrea从对象中移除


也许我缺少关于我可以使用的另一个操作符的知识?

您也需要对它进行过滤

const source=ofmyObject.pipe mapx=>x.items, mapx=>{ 返回x.filtery=>{ 返回y.children.somey=>y.sex=='M'; }; }, mapx=>{ 返回x.mapy=>{ 返回{ Y 儿童:y.children.filterc=>c.sex=='M'; }; }; }, ; source.subscribex=>console.logx;
你也需要过滤它

const source=ofmyObject.pipe mapx=>x.items, mapx=>{ 返回x.filtery=>{ 返回y.children.somey=>y.sex=='M'; }; }, mapx=>{ 返回x.mapy=>{ 返回{ Y 儿童:y.children.filterc=>c.sex=='M'; }; }; }, ; source.subscribex=>console.logx;