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