Modules@robinpath/feed
feed

@robinpath/feed

0.1.1Node.jsPublic

RSS, Atom, and JSON Feed creation, parsing, manipulation, and auto-detection

Feed

RSS, Atom, and JSON Feed creation, parsing, manipulation, and auto-detection

Package: @robinpath/feed | Category: Web | Type: Utility

Authentication

No authentication required. All functions are available immediately.

Use Cases

Use the feed module when you need to:

  • Create RSS 2.0 feed -- Use feed.createRss to perform this operation
  • Create Atom feed -- Use feed.createAtom to perform this operation
  • Create JSON Feed -- Use feed.createJson to perform this operation
  • Parse RSS feed -- Use feed.parseRss to perform this operation
  • Parse Atom feed -- Use feed.parseAtom to perform this operation

Quick Reference

FunctionDescriptionReturns
createRssCreate RSS 2.0 feedRSS XML
createAtomCreate Atom feedAtom XML
createJsonCreate JSON FeedJSON Feed string
parseRssParse RSS feed{type, title, link, items[]}
parseAtomParse Atom feed{type, title, link, items[]}
parseJsonParse JSON Feed{type, title, link, items[]}
detectDetect feed format`rss
parseAuto-detect and parse any feed{type, title, link, items[]}
addItemAdd item to feed configUpdated config
removeItemRemove item by guidUpdated config
sortItemsSort items by dateSorted items
filterItemsFilter items by field regexMatching items
mergeFeedsMerge multiple feedsMerged feed config
fetchFetch and parse feed from URL{ok, status, feed}

Functions

createRss

Create RSS 2.0 feed

Module: feed | Returns: string -- RSS XML

feed.createRss {"title": "My Blog", "link": "https://example.com", "items": [...]}
ParameterTypeRequiredDescription
configobjectYes{title, link, description, language, items[]}

createAtom

Create Atom feed

Module: feed | Returns: string -- Atom XML

feed.createAtom {"title": "My Blog", "link": "https://example.com", "items": [...]}
ParameterTypeRequiredDescription
configobjectYes{title, link, description, items[]}

createJson

Create JSON Feed

Module: feed | Returns: string -- JSON Feed string

feed.createJson {"title": "My Blog", "items": [...]}
ParameterTypeRequiredDescription
configobjectYes{title, link, description, items[]}

parseRss

Parse RSS feed

Module: feed | Returns: object -- {type, title, link, items[]}

feed.parseRss $xml
ParameterTypeRequiredDescription
xmlstringYesRSS XML

parseAtom

Parse Atom feed

Module: feed | Returns: object -- {type, title, link, items[]}

feed.parseAtom $xml
ParameterTypeRequiredDescription
xmlstringYesAtom XML

parseJson

Parse JSON Feed

Module: feed | Returns: object -- {type, title, link, items[]}

feed.parseJson $json
ParameterTypeRequiredDescription
jsonstringYesJSON Feed

detect

Detect feed format

Module: feed | Returns: string -- rss | atom | json | unknown

feed.detect $content
ParameterTypeRequiredDescription
contentstringYesFeed content

parse

Auto-detect and parse any feed

Module: feed | Returns: object -- {type, title, link, items[]}

feed.parse $content
ParameterTypeRequiredDescription
contentstringYesFeed content

addItem

Add item to feed config

Module: feed | Returns: object -- Updated config

feed.addItem $config {"title": "New Post", "link": "..."}
ParameterTypeRequiredDescription
configobjectYesFeed config
itemobjectYes{title, link, description, pubDate, ...}

removeItem

Remove item by guid

Module: feed | Returns: object -- Updated config

feed.removeItem $config "https://example.com/old-post"
ParameterTypeRequiredDescription
configobjectYesFeed config
guidstringYesItem GUID or link

sortItems

Sort items by date

Module: feed | Returns: array -- Sorted items

feed.sortItems $items
ParameterTypeRequiredDescription
itemsarrayYesFeed items
descendingbooleanNoNewest first (default true)

filterItems

Filter items by field regex

Module: feed | Returns: array -- Matching items

feed.filterItems $items "title" "javascript"
ParameterTypeRequiredDescription
itemsarrayYesFeed items
fieldstringYesField name
patternstringYesRegex pattern

mergeFeeds

Merge multiple feeds

Module: feed | Returns: object -- Merged feed config

feed.mergeFeeds [$feed1, $feed2]
ParameterTypeRequiredDescription
feedsarrayYesArray of feed configs

fetch

Fetch and parse feed from URL

Module: feed | Returns: object -- {ok, status, feed}

feed.fetch "https://example.com/feed.xml"
ParameterTypeRequiredDescription
urlstringYesFeed URL

Error Handling

All functions throw on failure. Common errors:

ErrorCause
(standard errors)Check function parameters and authentication
@desc "Create rss and validate result"
do
  set $result as feed.createRss {"title": "My Blog", "link": "https://example.com", "items": [...]}
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. Create a new item with createRss

Create a new resource and capture the result.

set $result as feed.createRss {"title": "My Blog", "link": "https://example.com", "items": [...]}
print "Created: " + $result

2. Multi-step Feed workflow

Chain multiple feed operations together.

@desc "Create rss, create atom, and more"
do
  set $r_createRss as feed.createRss {"title": "My Blog", "link": "https://example.com", "items": [...]}
  set $r_createAtom as feed.createAtom {"title": "My Blog", "link": "https://example.com", "items": [...]}
  set $r_createJson as feed.createJson {"title": "My Blog", "items": [...]}
  print "All operations complete"
enddo

3. Safe createRss with validation

Check results before proceeding.

@desc "Create rss and validate result"
do
  set $result as feed.createRss {"title": "My Blog", "link": "https://example.com", "items": [...]}
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/feed

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size6.9 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

web