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.
34 lines (33 loc) • 1.29 kB
JavaScript
const require_config = require("./config.cjs");
const require_utils = require("./utils.cjs");
const require_index = require("../feeds/atom/detect/index.cjs");
const require_index$1 = require("../feeds/atom/parse/index.cjs");
const require_index$2 = require("../feeds/json/detect/index.cjs");
const require_index$3 = require("../feeds/json/parse/index.cjs");
const require_index$4 = require("../feeds/rdf/detect/index.cjs");
const require_index$5 = require("../feeds/rdf/parse/index.cjs");
const require_index$6 = require("../feeds/rss/detect/index.cjs");
const require_index$7 = require("../feeds/rss/parse/index.cjs");
//#region src/common/parse.ts
const parse = (value, options) => {
if (require_index$6.detect(value)) return {
format: "rss",
feed: require_index$7.parse(value, options)
};
if (require_index.detect(value)) return {
format: "atom",
feed: require_index$1.parse(value, options)
};
if (require_index$4.detect(value)) return {
format: "rdf",
feed: require_index$5.parse(value, options)
};
const json = require_utils.parseJsonObject(value);
if (require_index$2.detect(json)) return {
format: "json",
feed: require_index$3.parse(json, options)
};
throw new Error(require_config.locales.unrecognizedFeedFormat);
};
//#endregion
exports.parse = parse;