]>
Commit | Line | Data |
---|---|---|
1 | function getAPId (object: string | { id: string }) { | |
2 | if (typeof object === 'string') return object | |
3 | ||
4 | return object.id | |
5 | } | |
6 | ||
7 | function getActivityStreamDuration (duration: number) { | |
8 | // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration | |
9 | return 'PT' + duration + 'S' | |
10 | } | |
11 | ||
12 | function getDurationFromActivityStream (duration: string) { | |
13 | return parseInt(duration.replace(/[^\d]+/, '')) | |
14 | } | |
15 | ||
16 | export { | |
17 | getAPId, | |
18 | getActivityStreamDuration, | |
19 | getDurationFromActivityStream | |
20 | } |