Basically, I want to convert this array of objects:
[
  { type: 'heading-one', children: [{ text: 'Introduction' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By creating ' }],
  },
  { type: 'heading-one', children: [{ text: 'The Challenge' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By .' }],
  },
  { type: 'heading-one', children: [{ text: 'The result' }] },
  {
    type: 'image',
    image: 'https://mani62/2021-10-19T16:36:45.514Z-tkabg-background-png.png',
    children: [{ text: '' }],
  },
  {
    type: 'image',
    image: 'https://mankground-png.png',
    children: [{ text: '' }],
  },
  {
    type: 'image',
    image: 'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
    children: [{ text: '' }],
  },
  { type: 'heading-one', children: [{ text: 'Conclusion' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By creating an Ac.' }],
  },
];
To this array of objects:
[
  { type: 'heading-one', children: [{ text: 'Introduction' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By creating ' }],
  },
  { type: 'heading-one', children: [{ text: 'The Challenge' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By .' }],
  },
  { type: 'heading-one', children: [{ text: 'The result' }] },
  {
    type: 'image',
    images: [
      'https://mani62/2021-10-19T16:36:45.514Z-tkabg-background-png.png',
      'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
      'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
    ],
  },
  { type: 'heading-one', children: [{ text: 'Conclusion' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By creating an Ac.' }],
  },
];
As you can see, the:
{
  type: 'image',
  image: 'https://mani62/2021-10-19T16:36:45.514Z-tkabg-background-png.png',
  children: [{ text: '' }],
},
{
  type: 'image',
  image: 'https://mankground-png.png',
  children: [{ text: '' }],
},
{
  type: 'image',
  image: 'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
  children: [{ text: '' }],
},
It's replaced with:
{
  type: 'image',
  images: [
    'https://mani62/2021-10-19T16:36:45.514Z-tkabg-background-png.png',
    'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
    'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
  ],
},
So, I'd like to know what's the best way to take all the objects that have type: image and join them to one object with an array of these images... Also, in this example, there's just one group of type: image images, but maybe could exist something like this; Where there are many type: image objects...
[
  { type: 'heading-one', children: [{ text: 'Introduction' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By creating ' }],
  },
  { type: 'heading-one', children: [{ text: 'The Challenge' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By .' }],
  },
  { type: 'heading-one', children: [{ text: 'The result' }] },
  {
    type: 'image',
    image: 'https://mani62/2021-10-19T16:36:45.514Z-tkabg-background-png.png',
    children: [{ text: '' }],
  },
  {
    type: 'image',
    image: 'https://mankground-png.png',
    children: [{ text: '' }],
  },
  {
    type: 'image',
    image: 'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
    children: [{ text: '' }],
  },
  { type: 'heading-one', children: [{ text: 'Conclusion' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By creating an Ac.' }],
  },
  {
    type: 'image',
    image: 'https://mankground-png.png',
    children: [{ text: '' }],
  },
  {
    type: 'image',
    image: 'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
    children: [{ text: '' }],
  },
];
Which, the solution would be something like this:
[
  { type: 'heading-one', children: [{ text: 'Introduction' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By creating ' }],
  },
  { type: 'heading-one', children: [{ text: 'The Challenge' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By .' }],
  },
  { type: 'heading-one', children: [{ text: 'The result' }] },
  {
    type: 'image',
    images: [
      'https://mani62/2021-10-19T16:36:45.514Z-tkabg-background-png.png',
      'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
      'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
    ],
  },
  { type: 'heading-one', children: [{ text: 'Conclusion' }] },
  {
    type: 'paragraph',
    children: [{ text: 'By creating an Ac.' }],
  },
  {
    type: 'image',
    images: [
      'https://mankground-png.png',
      'https://manife6ce052d62/2021-10-19T16:36:45.517Z-1wwvq-background-png.png',
    ],
  },
];
 
     
     
    