Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

podcast-xml-parser

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

podcast-xml-parser - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

17

lib/transform/transformPodcast.d.ts

@@ -10,3 +10,4 @@ import { Episode, Podcast } from "../types";

*/
export declare function getAttribute(obj: any, path: string, defaultValue?: string): string | number;
export declare function getAttribute(obj: any, // eslint-disable-line @typescript-eslint/no-explicit-any
path: string, defaultValue?: string | boolean | number): string | boolean | number;
/**

@@ -21,2 +22,16 @@ * Ensures that the input is an array. If the input is not an array, it is wrapped in an array.

/**
* Converts a string to a boolean value. Handles case-insensitive "Yes" and "No" strings.
*
* @param value - The string value to convert.
* @returns A boolean representation of the value.
*/
export declare function toBoolean(value: string | boolean): boolean;
/**
* Converts a string to a number. Returns null if the conversion fails or if the string contains non-numeric characters.
*
* @param value - The string value to convert.
* @returns A number representation of the value, or null if the conversion fails or contains non-numeric characters.
*/
export declare function toNumber(value: string): number | null;
/**
* Transforms parsed XML data into a Podcast object.

@@ -23,0 +38,0 @@ *

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformPodcast = exports.ensureArray = exports.getAttribute = void 0;
exports.transformPodcast = exports.toNumber = exports.toBoolean = exports.ensureArray = exports.getAttribute = void 0;
const constants_1 = require("../constants");

@@ -14,4 +14,4 @@ const utils_1 = require("../utils");

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getAttribute(obj, path, defaultValue = "") {
function getAttribute(obj, // eslint-disable-line @typescript-eslint/no-explicit-any
path, defaultValue = "") {
const value = path.split(".").reduce((acc, part) => acc && acc[part], obj);

@@ -49,2 +49,34 @@ let returnValue = defaultValue;

/**
* Converts a string to a boolean value. Handles case-insensitive "Yes" and "No" strings.
*
* @param value - The string value to convert.
* @returns A boolean representation of the value.
*/
function toBoolean(value) {
if (typeof value === "boolean")
return value;
if (typeof value === "string") {
const lowerValue = value.toLowerCase();
if (lowerValue === "yes")
return true;
if (lowerValue === "no")
return false;
}
return false;
}
exports.toBoolean = toBoolean;
/**
* Converts a string to a number. Returns null if the conversion fails or if the string contains non-numeric characters.
*
* @param value - The string value to convert.
* @returns A number representation of the value, or null if the conversion fails or contains non-numeric characters.
*/
function toNumber(value) {
if (/^\d+$/.test(value)) {
return parseInt(value, 10);
}
return null;
}
exports.toNumber = toNumber;
/**
* Transforms parsed XML data into a Podcast object.

@@ -79,4 +111,4 @@ *

itunesAuthor: getAttribute(channel, "itunes:author"),
itunesCategory: getAttribute(channel, "itunes:category"),
itunesExplicit: getAttribute(channel, "itunes:explicit"),
itunesCategory: getAttribute(channel, "itunes:category.@_text"),
itunesExplicit: toBoolean(getAttribute(channel, "itunes:explicit", false)),
itunesImage: getAttribute(channel, "itunes:image.@_href"),

@@ -104,7 +136,7 @@ itunesOwner: {

itunesDuration: (0, utils_1.getDuration)(getAttribute(item, "itunes:duration")),
itunesEpisode: getAttribute(item, "itunes:episode"),
itunesEpisode: toNumber(getAttribute(item, "itunes:episode")),
itunesEpisodeType: getAttribute(item, "itunes:episodeType"),
itunesExplicit: getAttribute(item, "itunes:explicit"),
itunesExplicit: toBoolean(getAttribute(item, "itunes:explicit", "false")),
itunesImage: getAttribute(item, "itunes:image.@_href"),
itunesSeason: getAttribute(item, "itunes:season"),
itunesSeason: toNumber(getAttribute(item, "itunes:season")),
itunesSubtitle: getAttribute(item, "itunes:subtitle"),

@@ -111,0 +143,0 @@ itunesSummary: getAttribute(item, "itunes:summary"),

6

lib/types/Episode.d.ts

@@ -12,7 +12,7 @@ export interface Episode {

itunesDuration: number;
itunesEpisode: number;
itunesEpisode: number | null;
itunesEpisodeType: string;
itunesExplicit: string;
itunesExplicit: boolean;
itunesImage: string;
itunesSeason: number;
itunesSeason: number | null;
itunesSubtitle: string;

@@ -19,0 +19,0 @@ itunesSummary: string;

@@ -13,3 +13,3 @@ export interface Podcast {

itunesCategory: string;
itunesExplicit: string;
itunesExplicit: boolean;
itunesImage: string;

@@ -16,0 +16,0 @@ itunesOwner: {

{
"name": "podcast-xml-parser",
"version": "3.0.0",
"version": "3.1.0",
"description": "🎙 Parse podcast feeds in browsers, React Native, or Node.js environments.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -292,3 +292,3 @@ <!-- HIDE_SECTION_START -->

itunesCategory: string;
itunesExplicit: string;
itunesExplicit: boolean;
itunesImage: string;

@@ -322,7 +322,7 @@ itunesOwner: {

itunesDuration: number;
itunesEpisode: number;
itunesEpisode: number | null;
itunesEpisodeType: string;
itunesExplicit: string;
itunesExplicit: boolean;
itunesImage: string;
itunesSeason: number;
itunesSeason: number | null;
itunesSubtitle: string;

@@ -329,0 +329,0 @@ itunesSummary: string;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc