@espressif/rainmaker-base-cdf
    Preparing search index...

    Function compareArrays

    • Compares two arrays of objects and checks if all objects in array1 exist in array2

      Type Parameters

      • T extends Record<string, any>

      Parameters

      • array1: T[]

        First array to compare

      • array2: T[]

        Second array to compare against

      • Optionalkey: keyof T

        Optional key to use for faster comparison instead of full object comparison

      Returns boolean

      True if all objects in array1 exist in array2, false otherwise

      // With key comparison
      compareArrays([{id: 1}, {id: 2}], [{id: 1}, {id: 2}, {id: 3}], 'id') // true

      // With full object comparison
      compareArrays([{x: 1}, {x: 2}], [{x: 1}, {x: 2}, {x: 3}]) // true