How to create new array from existing array with different structure

I want to reformat the existing array, how can i do it using Javascript or typescript

first array

pdfData: [
         { 
           Id: 1, 
           path:'https//path/pdf1'
         },
         { 
           Id: 1, 
           path:'https//path/pdf2'
         },
         { 
           Id: 2, 
           path:'https//path/pdf1'
         },
         { 
           Id: 2, 
           path:'https//path/pdf2'
         },
        ]

I want to convert this array to following one

data: [
        { 
           Id: 1, 
           links:['https//path/pdf1','https//path/pdf2']
         },
         { 
           Id: 2, 
           links:['https//path/pdf1','https//path/pdf2']
         },

  ]