The best way to control Claude Code, Codex and more from any computer or phone
| 1 | // Offset pagination can return the same token on two pages when the list |
| 2 | // shifts between fetches; keep the first occurrence of each id. |
| 3 | export const uniqueTokens = <T extends { id?: string | null }>(tokens: ReadonlyArray<T>): T[] => { |
| 4 | const seen = new Set<string>(); |
| 5 | return tokens.filter((token) => { |
| 6 | if (!token.id) return true; |
| 7 | if (seen.has(token.id)) return false; |
| 8 | seen.add(token.id); |
| 9 | return true; |
| 10 | }); |
| 11 | }; |