( arr1: T[], arr2: T[], uniqueKey: keyof T, )
| 564 | } |
| 565 | |
| 566 | export 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 | |
| 578 | export function snakeToCamel(str: string): string { |
| 579 | return str.replace(/(_\w)/g, function (m: string): string { |
no outgoing calls
no test coverage detected