2022-03-23 14:24:50 +01:00
|
|
|
function getAPId (object: string | { id: string }) {
|
|
|
|
if (typeof object === 'string') return object
|
|
|
|
|
|
|
|
return object.id
|
|
|
|
}
|
|
|
|
|
2022-03-24 13:36:47 +01:00
|
|
|
function getActivityStreamDuration (duration: number) {
|
|
|
|
// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
|
|
|
|
return 'PT' + duration + 'S'
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDurationFromActivityStream (duration: string) {
|
|
|
|
return parseInt(duration.replace(/[^\d]+/, ''))
|
|
|
|
}
|
|
|
|
|
2022-03-23 14:24:50 +01:00
|
|
|
export {
|
2022-03-24 13:36:47 +01:00
|
|
|
getAPId,
|
|
|
|
getActivityStreamDuration,
|
|
|
|
getDurationFromActivityStream
|
2022-03-23 14:24:50 +01:00
|
|
|
}
|