podcast-xml-parser
Advanced tools
Comparing version 3.0.0-beta.6 to 3.0.0-beta.7
@@ -7,4 +7,4 @@ /// <reference types="node" /> | ||
* @returns An array of feed URLs extracted from the OPML data. | ||
* @throws {Error} If the source type is invalid or no feed is available to parse. | ||
* @throws If the source type is invalid or no feed is available to parse. | ||
*/ | ||
export declare const podcastOpmlParser: (source: URL | string) => Promise<string[]>; |
@@ -20,3 +20,3 @@ "use strict"; | ||
* @returns An array of feed URLs extracted from the OPML data. | ||
* @throws {Error} If the source type is invalid or no feed is available to parse. | ||
* @throws If the source type is invalid or no feed is available to parse. | ||
*/ | ||
@@ -23,0 +23,0 @@ const podcastOpmlParser = (source) => __awaiter(void 0, void 0, void 0, function* () { |
/// <reference types="node" /> | ||
import { Config, Podcast, Episode, Itunes } from "../types"; | ||
/** | ||
* Parses a podcast feed from various source types and returns podcast and episodes data, along with iTunes information if available. | ||
* Parses a podcast feed from various source types and returns podcast and episodes data, | ||
* along with iTunes information if available. | ||
* | ||
* @param source - A URL, iTunes ID, or XML string representing the podcast feed. | ||
* @param config - Optional configuration object for parsing options. | ||
* @returns An object containing the podcast and episodes data, along with iTunes information if available. | ||
* @throws {Error} If the source type is invalid, the feed URL cannot be retrieved from iTunes, or no feed is available to parse. | ||
* @throws If the source type is invalid, the feed URL cannot be retrieved from iTunes, or no feed is available to parse. | ||
*/ | ||
@@ -10,0 +12,0 @@ export declare const podcastXmlParser: (source: URL | number | string, config?: Config) => Promise<{ |
@@ -17,7 +17,9 @@ "use strict"; | ||
/** | ||
* Parses a podcast feed from various source types and returns podcast and episodes data, along with iTunes information if available. | ||
* Parses a podcast feed from various source types and returns podcast and episodes data, | ||
* along with iTunes information if available. | ||
* | ||
* @param source - A URL, iTunes ID, or XML string representing the podcast feed. | ||
* @param config - Optional configuration object for parsing options. | ||
* @returns An object containing the podcast and episodes data, along with iTunes information if available. | ||
* @throws {Error} If the source type is invalid, the feed URL cannot be retrieved from iTunes, or no feed is available to parse. | ||
* @throws If the source type is invalid, the feed URL cannot be retrieved from iTunes, or no feed is available to parse. | ||
*/ | ||
@@ -24,0 +26,0 @@ const podcastXmlParser = (source_1, ...args_1) => __awaiter(void 0, [source_1, ...args_1], void 0, function* (source, config = {}) { |
@@ -5,6 +5,8 @@ import { Itunes } from "../types"; | ||
* Optionally, matches the result with a provided feed URL. | ||
* @param source The iTunes ID (number) or search term (string) of the podcast. | ||
* @param feedUrl Optional feed URL to match with the search results. | ||
* | ||
* @param source - The iTunes ID (number) or search term (string) of the podcast. | ||
* @param feedUrl - Optional feed URL to match with the search results. | ||
* @returns A promise that resolves to the podcast data. | ||
* @throws If the fetch request fails or no matching result is found. | ||
*/ | ||
export declare function fetchItunes(source: number | string, feedUrl?: string): Promise<Itunes | undefined>; |
@@ -17,5 +17,7 @@ "use strict"; | ||
* Optionally, matches the result with a provided feed URL. | ||
* @param source The iTunes ID (number) or search term (string) of the podcast. | ||
* @param feedUrl Optional feed URL to match with the search results. | ||
* | ||
* @param source - The iTunes ID (number) or search term (string) of the podcast. | ||
* @param feedUrl - Optional feed URL to match with the search results. | ||
* @returns A promise that resolves to the podcast data. | ||
* @throws If the fetch request fails or no matching result is found. | ||
*/ | ||
@@ -22,0 +24,0 @@ function fetchItunes(source, feedUrl) { |
@@ -5,9 +5,8 @@ /// <reference types="node" /> | ||
* Fetches the podcast content from the provided URL. | ||
* @param url The URL of the podcast. | ||
* @param config Optional configuration object for the fetch request. | ||
* - requestHeaders: Headers to include in the fetch request. | ||
* - requestSize: The maximum size of the response in bytes. If specified, | ||
* the response is truncated to this size and any incomplete XML is fixed. | ||
* | ||
* @param url - The URL of the podcast. | ||
* @param config - Optional configuration object for the fetch request. | ||
* @returns A promise that resolves to the text content of the podcast response. | ||
* @throws If the fetch request fails. | ||
*/ | ||
export declare function fetchPodcast(url: URL, config?: Config): Promise<string>; |
@@ -17,3 +17,4 @@ "use strict"; | ||
* the original XML data is returned unmodified. | ||
* @param xmlData The XML data that may be incomplete. | ||
* | ||
* @param xmlData - The XML data that may be incomplete. | ||
* @returns The fixed XML data with properly closed tags. | ||
@@ -37,8 +38,7 @@ */ | ||
* Fetches the podcast content from the provided URL. | ||
* @param url The URL of the podcast. | ||
* @param config Optional configuration object for the fetch request. | ||
* - requestHeaders: Headers to include in the fetch request. | ||
* - requestSize: The maximum size of the response in bytes. If specified, | ||
* the response is truncated to this size and any incomplete XML is fixed. | ||
* | ||
* @param url - The URL of the podcast. | ||
* @param config - Optional configuration object for the fetch request. | ||
* @returns A promise that resolves to the text content of the podcast response. | ||
* @throws If the fetch request fails. | ||
*/ | ||
@@ -51,3 +51,3 @@ function fetchPodcast(url, config) { | ||
} | ||
const response = yield fetch(url.toString(), { headers }); | ||
const response = yield fetch(url.toString(), { headers, redirect: "follow" }); | ||
if (!response.ok) { | ||
@@ -54,0 +54,0 @@ throw new Error(response.statusText); |
/** | ||
* Transforms parsed OPML XML data into an array of feed URLs. | ||
* @param xmlText The OPML XML data as a string. | ||
* | ||
* @param xmlText - The OPML XML data as a string. | ||
* @returns An array of feed URLs extracted from the OPML data. | ||
* @throws {Error} If the expected XML structure is not found. | ||
* @throws If the expected XML structure is not found. | ||
*/ | ||
export declare function transformOpml(xmlText: string): string[]; |
@@ -7,5 +7,6 @@ "use strict"; | ||
* Transforms parsed OPML XML data into an array of feed URLs. | ||
* @param xmlText The OPML XML data as a string. | ||
* | ||
* @param xmlText - The OPML XML data as a string. | ||
* @returns An array of feed URLs extracted from the OPML data. | ||
* @throws {Error} If the expected XML structure is not found. | ||
* @throws If the expected XML structure is not found. | ||
*/ | ||
@@ -12,0 +13,0 @@ function transformOpml(xmlText) { |
import { Episode, Podcast } from "../types"; | ||
/** | ||
* Retrieves the value of a specified attribute from an object or an array of objects. | ||
* | ||
* @param obj - The object or array of objects to search. | ||
* @param path - The path to the attribute, separated by dots. | ||
* @param defaultValue - The default value to return if the attribute is not found. | ||
* @returns The value of the attribute, or the default value if not found. | ||
*/ | ||
export declare function getAttribute(obj: any, path: string, defaultValue?: string): string; | ||
/** | ||
* Ensures that the input is an array. If the input is not an array, it is wrapped in an array. | ||
* If the input is null or undefined, an empty array is returned. | ||
* | ||
* @param item - The input to ensure as an array. | ||
* @returns An array containing the input, or an empty array if the input is null or undefined. | ||
*/ | ||
export declare function ensureArray(item: any): any[]; | ||
/** | ||
* Transforms parsed XML data into a Podcast object. | ||
* @param parsedXML The parsed XML data as an XmlDocument. | ||
* | ||
* @param parsedXML - The parsed XML data as an XmlDocument. | ||
* @returns An object containing the transformed podcast and episodes data. | ||
@@ -8,0 +24,0 @@ * @throws An error if the expected XML structure is not found. |
@@ -6,2 +6,10 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
/** | ||
* Retrieves the value of a specified attribute from an object or an array of objects. | ||
* | ||
* @param obj - The object or array of objects to search. | ||
* @param path - The path to the attribute, separated by dots. | ||
* @param defaultValue - The default value to return if the attribute is not found. | ||
* @returns The value of the attribute, or the default value if not found. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -25,2 +33,9 @@ function getAttribute(obj, path, defaultValue = "") { | ||
exports.getAttribute = getAttribute; | ||
/** | ||
* Ensures that the input is an array. If the input is not an array, it is wrapped in an array. | ||
* If the input is null or undefined, an empty array is returned. | ||
* | ||
* @param item - The input to ensure as an array. | ||
* @returns An array containing the input, or an empty array if the input is null or undefined. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -36,3 +51,4 @@ function ensureArray(item) { | ||
* Transforms parsed XML data into a Podcast object. | ||
* @param parsedXML The parsed XML data as an XmlDocument. | ||
* | ||
* @param parsedXML - The parsed XML data as an XmlDocument. | ||
* @returns An object containing the transformed podcast and episodes data. | ||
@@ -39,0 +55,0 @@ * @throws An error if the expected XML structure is not found. |
/** | ||
* Parses the provided XML text into a JavaScript object. | ||
* @param xmlText The XML text to parse. | ||
* | ||
* @param xmlText - The XML text to parse. | ||
* @returns A JavaScript object representation of the XML. | ||
*/ | ||
export declare function parseXml(xmlText: string): unknown; |
@@ -11,3 +11,4 @@ "use strict"; | ||
* Parses the provided XML text into a JavaScript object. | ||
* @param xmlText The XML text to parse. | ||
* | ||
* @param xmlText - The XML text to parse. | ||
* @returns A JavaScript object representation of the XML. | ||
@@ -14,0 +15,0 @@ */ |
{ | ||
"name": "podcast-xml-parser", | ||
"version": "3.0.0-beta.6", | ||
"version": "3.0.0-beta.7", | ||
"description": "🎙 Parse podcast feeds in browsers, React Native, or Node.js environments.", | ||
@@ -44,2 +44,3 @@ "main": "lib/index.js", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-tsdoc": "^0.2.17", | ||
"husky": "^9.0.11", | ||
@@ -46,0 +47,0 @@ "jest": "^29.7.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49627
826
15