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

xast-util-feed

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xast-util-feed - npm Package Compare versions

Comparing version 1.2.3 to 2.0.0

12

index.d.ts

@@ -1,6 +0,6 @@

export {rss} from './lib/rss.js'
export {atom} from './lib/atom.js'
export type Author = import('./lib/types.js').Author
export type Enclosure = import('./lib/types.js').Enclosure
export type Channel = import('./lib/types.js').Channel
export type Entry = import('./lib/types.js').Entry
export { rss } from "./lib/rss.js";
export { atom } from "./lib/atom.js";
export type Author = import('./lib/types.js').Author;
export type Channel = import('./lib/types.js').Channel;
export type Enclosure = import('./lib/types.js').Enclosure;
export type Entry = import('./lib/types.js').Entry;
/**
* @typedef {import('./lib/types.js').Author} Author
* @typedef {import('./lib/types.js').Channel} Channel
* @typedef {import('./lib/types.js').Enclosure} Enclosure
* @typedef {import('./lib/types.js').Channel} Channel
* @typedef {import('./lib/types.js').Entry} Entry

@@ -6,0 +6,0 @@ */

@@ -9,14 +9,11 @@ /**

* @param {Array<Entry> | null | undefined} [data]
* List of entries.
* List of entries (optional).
* @returns {Root}
* Atom feed.
*/
export function atom(
channel: Channel,
data?: Array<Entry> | null | undefined
): Root
export type Element = import('xast').Element
export type Root = import('xast').Root
export type Author = import('./types.js').Author
export type Channel = import('./types.js').Channel
export type Entry = import('./types.js').Entry
export function atom(channel: Channel, data?: Array<Entry> | null | undefined): Root;
export type Element = import('xast').Element;
export type Root = import('xast').Root;
export type Author = import('./types.js').Author;
export type Channel = import('./types.js').Channel;
export type Entry = import('./types.js').Entry;

@@ -9,6 +9,5 @@ /**

import {URL} from 'node:url'
import {bcp47Normalize as normalize} from 'bcp-47-normalize'
import {u} from 'unist-builder'
import {x} from 'xastscript'
import {bcp47Normalize as normalize} from 'bcp-47-normalize'
import {toAuthor, toDate} from './util.js'

@@ -24,3 +23,3 @@

* @param {Array<Entry> | null | undefined} [data]
* List of entries.
* List of entries (optional).
* @returns {Root}

@@ -32,9 +31,9 @@ * Atom feed.

/** @type {Channel} */
const meta = channel || {title: null, url: null}
const meta = channel || {title: undefined, url: undefined}
if (meta.title === undefined || meta.title === null) {
if (meta.title === null || meta.title === undefined) {
throw new Error('Expected `channel.title` to be set')
}
if (meta.url === undefined || meta.url === null) {
if (meta.url === null || meta.url === undefined) {
throw new Error('Expected `channel.url` to be set')

@@ -46,3 +45,3 @@ }

x('title', String(meta.title)),
x('subtitle', String(meta.description || '') || null),
x('subtitle', String(meta.description || '') || undefined),
// `rel: 'alternate'` is the default.

@@ -113,7 +112,7 @@ x('link', url),

if (datum.published !== undefined && datum.published !== null) {
if (datum.published !== null && datum.published !== undefined) {
children.push(x('published', toDate(datum.published).toISOString()))
}
if (datum.modified !== undefined && datum.modified !== null) {
if (datum.modified !== null && datum.modified !== undefined) {
children.push(x('updated', toDate(datum.modified).toISOString()))

@@ -120,0 +119,0 @@ }

@@ -9,13 +9,10 @@ /**

* @param {Array<Entry> | null | undefined} [data]
* List of entries.
* List of entries (optional).
* @returns {Root}
* RSS feed.
*/
export function rss(
channel: Channel,
data?: Array<Entry> | null | undefined
): Root
export type Element = import('xast').Element
export type Root = import('xast').Root
export type Channel = import('./types.js').Channel
export type Entry = import('./types.js').Entry
export function rss(channel: Channel, data?: Array<Entry> | null | undefined): Root;
export type Element = import('xast').Element;
export type Root = import('xast').Root;
export type Channel = import('./types.js').Channel;
export type Entry = import('./types.js').Entry;

@@ -8,6 +8,5 @@ /**

import {URL} from 'node:url'
import {bcp47Normalize as normalize} from 'bcp-47-normalize'
import {u} from 'unist-builder'
import {x} from 'xastscript'
import {bcp47Normalize as normalize} from 'bcp-47-normalize'
import {toAuthor, toDate} from './util.js'

@@ -23,3 +22,3 @@

* @param {Array<Entry> | null | undefined} [data]
* List of entries.
* List of entries (optional).
* @returns {Root}

@@ -31,11 +30,11 @@ * RSS feed.

/** @type {Channel} */
const meta = channel || {title: null, url: null}
const meta = channel || {title: undefined, url: undefined}
/** @type {boolean} */
let atom = false
if (meta.title === undefined || meta.title === null) {
if (meta.title === null || meta.title === undefined) {
throw new Error('Expected `channel.title` to be set')
}
if (meta.url === undefined || meta.url === null) {
if (meta.url === null || meta.url === undefined) {
throw new Error('Expected `channel.url` to be set')

@@ -46,3 +45,3 @@ }

x('title', String(meta.title)),
x('description', String(meta.description || '') || null),
x('description', String(meta.description || '') || undefined),
x('link', new URL(meta.url).href),

@@ -120,3 +119,3 @@ // @ts-expect-error `toGTMString` is exactly what we need.

if (datum.published !== undefined && datum.published !== null) {
if (datum.published !== null && datum.published !== undefined) {
children.push(

@@ -129,3 +128,3 @@ // @ts-expect-error `toGTMString` is exactly what we need.

if (datum.modified !== undefined && datum.modified !== null) {
if (datum.modified !== null && datum.modified !== undefined) {
children.push(x('dc:modified', toDate(datum.modified).toISOString()))

@@ -132,0 +131,0 @@ }

@@ -5,17 +5,17 @@ /**

export type Author = {
/**
* Name (example: `'Acme, Inc.'` or `'Jane Doe'`).
*/
name: string
/**
* Email address (example: `john@example.org`).
*/
email?: string | null | undefined
/**
* URL to author (example: `'https://example.org/john'`).
*
* `url` is used in `atom`, not in `rss`.
*/
url?: string | null | undefined
}
/**
* Name (example: `'Acme, Inc.'` or `'Jane Doe'`).
*/
name: string;
/**
* Email address (example: `john@example.org`, optional).
*/
email?: string | null | undefined;
/**
* URL to author (example: `'https://example.org/john'`, optional).
*
* `url` is used in `atom`, not in `rss`.
*/
url?: string | null | undefined;
};
/**

@@ -25,16 +25,16 @@ * Media.

export type Enclosure = {
/**
* Full URL to the resource (example:
* `'http://dallas.example.com/joebob_050689.mp3'`).
*/
url: string
/**
* Resource size in bytes (example: `24986239`).
*/
size: number
/**
* Mime type of the resource (example: `'audio/mpeg'`).
*/
type: string
}
/**
* Full URL to the resource (example:
* `'http://dallas.example.com/joebob_050689.mp3'`).
*/
url: string;
/**
* Resource size in bytes (example: `24986239`).
*/
size: number;
/**
* Mime type of the resource (example: `'audio/mpeg'`).
*/
type: string;
};
/**

@@ -44,45 +44,45 @@ * Data on the feed (the group of items).

export type Channel = {
/**
* Title of the channel (required, example: `Zimbabwe | The Guardian`).
*/
title: string
/**
* Full URL to the site (required, example:
* `'https://www.theguardian.com/world/zimbabwe'`).
*/
url: string
/**
* Full URL to this channel (example:
* `'https://www.adweek.com/feed/'`).
*
* Make sure to pass different ones to `rss` and `atom`!
*
* You *should* define this.
*/
feedUrl?: string | null | undefined
/**
* Short description of the channel (example: `Album Reviews`).
*
* You *should* define this.
*/
description?: string | null | undefined
/**
* BCP 47 language tag representing the language of the whole channel (example:
* `'fr-BE'`).
*
* You *should* define this.
*/
lang?: string | null | undefined
/**
* Optional author of the whole channel.
*
* Either `string`, in which case it’s as passing `{name: string}`.
* Or an author object.
*/
author?: string | Author | null | undefined
/**
* Categories of the channel (example: `['JavaScript', 'React']`).
*/
tags?: Array<string> | null | undefined
}
/**
* Title of the channel (required, example: `Zimbabwe | The Guardian`).
*/
title: string;
/**
* Full URL to the site (required, example:
* `'https://www.theguardian.com/world/zimbabwe'`).
*/
url: string;
/**
* Full URL to this channel (example:
* `'https://www.adweek.com/feed/'`, optional).
*
* Make sure to pass different ones to `rss` and `atom`!
*
* You *should* define this.
*/
feedUrl?: string | null | undefined;
/**
* Short description of the channel (example: `Album Reviews`, optional).
*
* You *should* define this.
*/
description?: string | null | undefined;
/**
* BCP 47 language tag representing the language of the whole channel (example:
* `'fr-BE'`, optional).
*
* You *should* define this.
*/
lang?: string | null | undefined;
/**
* Optional author of the whole channel (optional).
*
* Either `string`, in which case it’s as passing `{name: string}`.
* Or an author object.
*/
author?: Author | string | null | undefined;
/**
* Categories of the channel (example: `['JavaScript', 'React']`, optional).
*/
tags?: Array<string> | null | undefined;
};
/**

@@ -92,59 +92,58 @@ * Data on a single item.

export type Entry = {
/**
* Title of the item (example: `'Playboi Carti: Whole Lotta Red'`).
*
* Either `title`, `description`, or `descriptionHtml` must be set.
*/
title?: string | null | undefined
/**
* Either the whole post or an excerpt of it (example: `'Lorem'`).
*
* Should be plain text.
* `descriptionHtml` is preferred over plain text `description`.
*
* Either `title`, `description`, or `descriptionHtml` must be set.
*/
description?: string | null | undefined
/**
* Either the whole post or an excerpt of it (example: `'<p>Lorem</p>'`).
*
* Should be serialized HTML.
* `descriptionHtml` is preferred over plain text `description`.
*
* Either `title`, `description`, or `descriptionHtml` must be set.
*/
descriptionHtml?: string | null | undefined
/**
* Entry version of `channel.author`.
*
* You *should* define this.
*
* For `atom`, it is required to either set `channel.author` or set `author`
* on all entries.
*/
author?: string | Author | null | undefined
/**
* Full URL of this entry on the *site* (example:
* `'https://pitchfork.com/reviews/albums/roberta-flack-first-take'`).
*/
url?: string | null | undefined
/**
* When the entry was first published (`Date` or value for `new Date(x)`,
* optional).
*/
published?: Date | number | string | null | undefined
/**
* When the entry was last modified (`Date` or value for `new Date(x)`,
* optional).
*/
modified?: Date | number | string | null | undefined
/**
* Categories of the entry (`Array<string>?`, example:
* `['laravel', 'debugging']`).
*/
tags?: Array<string> | null | undefined
/**
* Attached media.
*/
enclosure?: Enclosure | null | undefined
}
/**
* Title of the item (example: `'Playboi Carti: Whole Lotta Red'`, optional).
*
* Either `title`, `description`, or `descriptionHtml` must be set.
*/
title?: string | null | undefined;
/**
* Either the whole post or an excerpt of it (example: `'Lorem'`, optional).
*
* Should be plain text.
* `descriptionHtml` is preferred over plain text `description`.
*
* Either `title`, `description`, or `descriptionHtml` must be set.
*/
description?: string | null | undefined;
/**
* Either the whole post or an excerpt of it (example: `'<p>Lorem</p>'`,
* optional).
*
* Should be serialized HTML.
* `descriptionHtml` is preferred over plain text `description`.
*
* Either `title`, `description`, or `descriptionHtml` must be set.
*/
descriptionHtml?: string | null | undefined;
/**
* Entry version of `channel.author` (optional).
*
* You *should* define this.
*
* For `atom`, it is required to either set `channel.author` or set `author`
* on all entries.
*/
author?: Author | string | null | undefined;
/**
* Full URL of this entry on the *site* (example:
* `'https://pitchfork.com/reviews/albums/roberta-flack-first-take'`,
* optional).
*/
url?: string | null | undefined;
/**
* When the entry was first published (optional).
*/
published?: Date | number | string | null | undefined;
/**
* When the entry was last modified (optional).
*/
modified?: Date | number | string | null | undefined;
/**
* Categories of the entry (example: `['laravel', 'debugging']`, optional).
*/
tags?: Array<string> | null | undefined;
/**
* Attached media.
*/
enclosure?: Enclosure | null | undefined;
};

@@ -7,5 +7,5 @@ /**

* @property {string | null | undefined} [email]
* Email address (example: `john@example.org`).
* Email address (example: `john@example.org`, optional).
* @property {string | null | undefined} [url]
* URL to author (example: `'https://example.org/john'`).
* URL to author (example: `'https://example.org/john'`, optional).
*

@@ -33,3 +33,3 @@ * `url` is used in `atom`, not in `rss`.

* Full URL to this channel (example:
* `'https://www.adweek.com/feed/'`).
* `'https://www.adweek.com/feed/'`, optional).
*

@@ -40,3 +40,3 @@ * Make sure to pass different ones to `rss` and `atom`!

* @property {string | null | undefined} [description]
* Short description of the channel (example: `Album Reviews`).
* Short description of the channel (example: `Album Reviews`, optional).
*

@@ -46,7 +46,7 @@ * You *should* define this.

* BCP 47 language tag representing the language of the whole channel (example:
* `'fr-BE'`).
* `'fr-BE'`, optional).
*
* You *should* define this.
* @property {string | Author | null | undefined} [author]
* Optional author of the whole channel.
* @property {Author | string | null | undefined} [author]
* Optional author of the whole channel (optional).
*

@@ -56,3 +56,3 @@ * Either `string`, in which case it’s as passing `{name: string}`.

* @property {Array<string> | null | undefined} [tags]
* Categories of the channel (example: `['JavaScript', 'React']`).
* Categories of the channel (example: `['JavaScript', 'React']`, optional).
*

@@ -62,7 +62,7 @@ * @typedef Entry

* @property {string | null | undefined} [title]
* Title of the item (example: `'Playboi Carti: Whole Lotta Red'`).
* Title of the item (example: `'Playboi Carti: Whole Lotta Red'`, optional).
*
* Either `title`, `description`, or `descriptionHtml` must be set.
* @property {string | null | undefined} [description]
* Either the whole post or an excerpt of it (example: `'Lorem'`).
* Either the whole post or an excerpt of it (example: `'Lorem'`, optional).
*

@@ -74,3 +74,4 @@ * Should be plain text.

* @property {string | null | undefined} [descriptionHtml]
* Either the whole post or an excerpt of it (example: `'<p>Lorem</p>'`).
* Either the whole post or an excerpt of it (example: `'<p>Lorem</p>'`,
* optional).
*

@@ -81,4 +82,4 @@ * Should be serialized HTML.

* Either `title`, `description`, or `descriptionHtml` must be set.
* @property {string | Author | null | undefined} [author]
* Entry version of `channel.author`.
* @property {Author | string | null | undefined} [author]
* Entry version of `channel.author` (optional).
*

@@ -91,12 +92,10 @@ * You *should* define this.

* Full URL of this entry on the *site* (example:
* `'https://pitchfork.com/reviews/albums/roberta-flack-first-take'`).
* `'https://pitchfork.com/reviews/albums/roberta-flack-first-take'`,
* optional).
* @property {Date | number | string | null | undefined} [published]
* When the entry was first published (`Date` or value for `new Date(x)`,
* optional).
* When the entry was first published (optional).
* @property {Date | number | string | null | undefined} [modified]
* When the entry was last modified (`Date` or value for `new Date(x)`,
* optional).
* When the entry was last modified (optional).
* @property {Array<string> | null | undefined} [tags]
* Categories of the entry (`Array<string>?`, example:
* `['laravel', 'debugging']`).
* Categories of the entry (example: `['laravel', 'debugging']`, optional).
* @property {Enclosure | null | undefined} [enclosure]

@@ -103,0 +102,0 @@ * Attached media.

@@ -12,3 +12,3 @@ /**

*/
export function toAuthor(value: Author | string): Author
export function toAuthor(value: Author | string): Author;
/**

@@ -22,3 +22,3 @@ * Create a date object.

*/
export function toDate(value: Date | string | number): Date
export type Author = import('./types.js').Author
export function toDate(value: Date | string | number): Date;
export type Author = import('./types.js').Author;
{
"name": "xast-util-feed",
"version": "1.2.3",
"version": "2.0.0",
"description": "xast utility to build feeds (rss, atom)",

@@ -30,4 +30,3 @@ "license": "MIT",

"type": "module",
"main": "index.js",
"types": "index.d.ts",
"exports": "./index.js",
"files": [

@@ -39,11 +38,11 @@ "lib/",

"dependencies": {
"@types/xast": "^1.0.0",
"@types/xast": "^2.0.0",
"bcp-47-normalize": "^2.0.0",
"unist-builder": "^3.0.0",
"xastscript": "^3.0.0"
"unist-builder": "^4.0.0",
"xastscript": "^4.0.0"
},
"devDependencies": {
"@types/node": "^18.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"@types/node": "^20.0.0",
"c8": "^8.0.0",
"prettier": "^3.0.0",
"remark-cli": "^11.0.0",

@@ -53,4 +52,4 @@ "remark-preset-wooorm": "^9.0.0",

"typescript": "^5.0.0",
"xast-util-to-xml": "^3.0.0",
"xo": "^0.54.0"
"xast-util-to-xml": "^4.0.0",
"xo": "^0.55.0"
},

@@ -60,25 +59,18 @@ "scripts": {

"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false
},
"xo": {
"prettier": true,
"rules": {
"complexity": "off",
"unicorn/explicit-length-check": "off"
}
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
"remark-preset-wooorm"
]

@@ -89,4 +81,12 @@ },

"detail": true,
"ignoreCatch": true,
"strict": true
},
"xo": {
"prettier": true,
"rules": {
"complexity": "off",
"unicorn/explicit-length-check": "off"
}
}
}

@@ -11,3 +11,3 @@ # xast-util-feed

[xast][] utility to build (web) feeds ([RSS][rss-spec], [Atom][atom-spec]).
[xast][] utility to build (web) feeds ([RSS][], [Atom][]).

@@ -58,3 +58,3 @@ ## Contents

This package is [ESM only][esm].
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
In Node.js (version 16+), install with [npm][]:

@@ -68,3 +68,3 @@ ```sh

```js
import {atom, rss} from 'https://esm.sh/xast-util-feed@1'
import {atom, rss} from 'https://esm.sh/xast-util-feed@2'
```

@@ -76,3 +76,3 @@

<script type="module">
import {atom, rss} from 'https://esm.sh/xast-util-feed@1?bundle'
import {atom, rss} from 'https://esm.sh/xast-util-feed@2?bundle'
</script>

@@ -174,3 +174,3 @@ ```

This package exports the identifiers [`atom`][atom] and [`rss`][rss].
This package exports the identifiers [`atom`][api-atom] and [`rss`][api-rss].
There is no default export.

@@ -180,9 +180,9 @@

Build an [Atom][atom-spec] feed.
Build an [Atom][] feed.
###### Parameters
* `channel` ([`Channel`][channel])
* `channel` ([`Channel`][api-channel])
— data on the feed (the group of items)
* `data` ([`Array<Entry>`][entry], optional)
* `data` ([`Array<Entry>`][api-entry], optional)
— list of entries

@@ -196,9 +196,9 @@

Build an [RSS][rss-spec] feed.
Build an [RSS][] feed.
###### Parameters
* `channel` ([`Channel`][channel])
* `channel` ([`Channel`][api-channel])
— data on the feed (the group of items)
* `data` ([`Array<Entry>`][entry], optional)
* `data` ([`Array<Entry>`][api-entry], optional)
— list of entries

@@ -269,3 +269,3 @@

Optional author of the whole channel (`string` or [`Author`][author]).
Optional author of the whole channel (`string` or [`Author`][api-author]).

@@ -359,3 +359,3 @@ Either `string`, in which case it’s as passing `{name: string}`.

Attached media ([`Enclosure?`][enclosure]).
Attached media ([`Enclosure?`][api-enclosure]).

@@ -365,12 +365,17 @@ ## Types

This package is fully typed with [TypeScript][].
It exports the additional types [`Author`][author], [`Channel`][channel],
[`Enclosure`][enclosure], and [`Entry`][entry].
It exports the additional types [`Author`][api-author],
[`Channel`][api-channel],
[`Enclosure`][api-enclosure], and
[`Entry`][api-entry].
## Compatibility
Projects maintained by the unified collective are compatible with all maintained
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
As of now, that is Node.js 14.14+ and 16.0+.
Our projects sometimes work with older versions, but this is not guaranteed.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, `xast-util-feed@^2`,
compatible with Node.js 16.
## Security

@@ -417,5 +422,5 @@

[size-badge]: https://img.shields.io/bundlephobia/minzip/xast-util-feed.svg
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=xast-util-feed
[size]: https://bundlephobia.com/result?p=xast-util-feed
[size]: https://bundlejs.com/?q=xast-util-feed

@@ -456,18 +461,18 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[rss-spec]: https://www.rssboard.org/rss-specification
[rss]: https://www.rssboard.org/rss-specification
[atom-spec]: https://tools.ietf.org/html/rfc4287
[atom]: https://tools.ietf.org/html/rfc4287
[bcp47]: https://github.com/wooorm/bcp-47
[atom]: #atomchannel-data
[api-atom]: #atomchannel-data
[rss]: #rsschannel-data
[api-rss]: #rsschannel-data
[author]: #author
[api-author]: #author
[channel]: #channel
[api-channel]: #channel
[enclosure]: #enclosure
[api-enclosure]: #enclosure
[entry]: #entry
[api-entry]: #entry
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