MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / joinArraysNoDuplicates

Function joinArraysNoDuplicates

lib/utils.ts:566–576  ·  view source on GitHub ↗
(
  arr1: T[],
  arr2: T[],
  uniqueKey: keyof T,
)

Source from the content-addressed store, hash-verified

564}
565
566export function joinArraysNoDuplicates<T extends Record<string, any>>(
567 arr1: T[],
568 arr2: T[],
569 uniqueKey: keyof T,
570): T[] {
571 // Joins two arrays of objects, removing duplicates based on the uniqueKey
572 if (arr1.length === 0) return arr2;
573 if (arr2.length === 0) return arr1;
574 const ids = new Set(arr1.map((d) => d[uniqueKey]));
575 return [...arr1, ...arr2.filter((d) => !ids.has(d[uniqueKey]))];
576}
577
578export function snakeToCamel(str: string): string {
579 return str.replace(/(_\w)/g, function (m: string): string {

Callers 2

filterActionsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected