-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathfeed.ts
More file actions
41 lines (35 loc) · 968 Bytes
/
feed.ts
File metadata and controls
41 lines (35 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import type { PredictMarket } from '../types';
import { isCryptoUpDown } from './cryptoUpDown';
export function isStandaloneMarket(market: PredictMarket): boolean {
const { parentMarketId } = market;
return (
parentMarketId === undefined ||
parentMarketId === null ||
String(parentMarketId).trim() === ''
);
}
export function filterStandaloneMarkets(
markets: PredictMarket[],
): PredictMarket[] {
return markets.filter(isStandaloneMarket);
}
/**
* Keeps only the first occurrence of each Crypto Up/Down series slug.
* Non-Up/Down markets pass through unchanged.
*/
export function deduplicateSeriesMarkets(
markets: PredictMarket[],
): PredictMarket[] {
const seenSlugs = new Set<string>();
return markets.filter((market) => {
if (!isCryptoUpDown(market)) {
return true;
}
const { slug } = market.series;
if (seenSlugs.has(slug)) {
return false;
}
seenSlugs.add(slug);
return true;
});
}