UNPKG

feedsmith

Version:

Fast, all‑in‑one feed parser and generator for RSS, Atom, RDF, and JSON Feed, with support for Podcast, iTunes, Dublin Core, and OPML files.

28 lines (27 loc) 942 B
import { generateNumber, generatePlainString, generateRfc3339Date, isObject, trimArray, trimObject } from "../../../common/utils.js"; //#region src/namespaces/thr/generate/utils.ts const generateInReplyTo = (inReplyTo) => { if (!isObject(inReplyTo)) return; return trimObject({ "@ref": generatePlainString(inReplyTo.ref), "@href": generatePlainString(inReplyTo.href), "@type": generatePlainString(inReplyTo.type), "@source": generatePlainString(inReplyTo.source) }); }; const generateLink = (link) => { if (!isObject(link)) return; return trimObject({ "@thr:count": generateNumber(link.count), "@thr:updated": generateRfc3339Date(link.updated) }); }; const generateItem = (item) => { if (!isObject(item)) return; return trimObject({ "thr:total": generateNumber(item.total), "thr:in-reply-to": trimArray(item.inReplyTos, generateInReplyTo) }); }; //#endregion export { generateInReplyTo, generateItem, generateLink };