monkeeShark/src/remote/activitypub/renderer/ordered-collection.ts

22 lines
565 B
TypeScript
Raw Normal View History

/**
* Render OrderedCollection
* @param id URL of self
* @param totalItems Total number of items
* @param first URL of first page (optional)
* @param last URL of last page (optional)
2018-09-18 04:08:27 +00:00
* @param orderedItems attached objects (optional)
*/
export default function(id: string | null, totalItems: any, first?: string, last?: string, orderedItems?: object) {
const page: any = {
id,
type: 'OrderedCollection',
totalItems,
};
if (first) page.first = first;
if (last) page.last = last;
2018-09-18 04:08:27 +00:00
if (orderedItems) page.orderedItems = orderedItems;
return page;
}