2022-03-23 09:24:50 -04:00
|
|
|
function getAPId (object: string | { id: string }) {
|
|
|
|
if (typeof object === 'string') return object
|
|
|
|
|
|
|
|
return object.id
|
|
|
|
}
|
|
|
|
|
2022-03-24 08:36:47 -04: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 09:24:50 -04:00
|
|
|
export {
|
2022-03-24 08:36:47 -04:00
|
|
|
getAPId,
|
|
|
|
getActivityStreamDuration,
|
|
|
|
getDurationFromActivityStream
|
2022-03-23 09:24:50 -04:00
|
|
|
}
|