Skip to content

Commit 8023a93

Browse files
committed
v6.0.0rc4
- Add default value to all keys
1 parent ba5bdee commit 8023a93

File tree

8 files changed

+97
-83
lines changed

8 files changed

+97
-83
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# feed-reader
22

3-
Load and parse ATOM/RSS/JSON data from given feed url.
3+
To read & normalize RSS/ATOM/JSON feed data.
44

55
[![NPM](https://badge.fury.io/js/feed-reader.svg)](https://badge.fury.io/js/feed-reader)
66
![CI test](https://github.com/ndaidong/feed-reader/workflows/ci-test/badge.svg)

dist/cjs/feed-reader.js

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// feed-reader@6.0.0rc3, by @ndaidong - built with esbuild at 2022-07-28T09:42:29.894Z - published under MIT license
1+
// feed-reader@6.0.0rc4, by @ndaidong - built with esbuild at 2022-07-28T10:42:35.368Z - published under MIT license
22
var __create = Object.create;
33
var __defProp = Object.defineProperty;
44
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -14602,23 +14602,19 @@ var toISODateString = (dstr) => {
1460214602
};
1460314603
var buildDescription = (val) => {
1460414604
const { descriptionMaxLen } = getReaderOptions();
14605-
const stripped = (0, import_bellajs4.stripTags)(val);
14605+
const stripped = (0, import_bellajs4.stripTags)(String(val));
1460614606
return (0, import_bellajs4.truncate)(stripped, descriptionMaxLen).replace(/\n+/g, " ");
1460714607
};
1460814608

1460914609
// src/utils/parseJsonFeed.js
14610-
var transform = (item) => {
14610+
var transform = (item, includeFullContent, convertPubDateToISO) => {
1461114611
const {
14612-
includeFullContent,
14613-
convertPubDateToISO
14614-
} = getReaderOptions();
14615-
const {
14616-
title,
14617-
url: link,
14618-
date_published: pubDate,
14619-
summary,
14620-
content_html: htmlContent,
14621-
content_text: textContent
14612+
title = "",
14613+
url: link = "",
14614+
date_published: pubDate = "",
14615+
summary = "",
14616+
content_html: htmlContent = "",
14617+
content_text: textContent = ""
1462214618
} = item;
1462314619
const published = convertPubDateToISO ? toISODateString(pubDate) : pubDate;
1462414620
const entry = {
@@ -14641,14 +14637,20 @@ var parseJson = (data) => {
1464114637
items: item = []
1464214638
} = data;
1464314639
const items = (0, import_bellajs5.isArray)(item) ? item : [item];
14640+
const {
14641+
includeFullContent,
14642+
convertPubDateToISO
14643+
} = getReaderOptions();
1464414644
return {
1464514645
title,
1464614646
link: homepageUrl,
1464714647
description,
1464814648
language,
1464914649
published: "",
1465014650
generator: "",
14651-
entries: items.map(transform)
14651+
entries: items.map((item2) => {
14652+
return transform(item2, includeFullContent, convertPubDateToISO);
14653+
})
1465214654
};
1465314655
};
1465414656
var parseJsonFeed_default = (data) => {
@@ -14657,16 +14659,12 @@ var parseJsonFeed_default = (data) => {
1465714659

1465814660
// src/utils/parseRssFeed.js
1465914661
var import_bellajs6 = __toESM(require_bella(), 1);
14660-
var transform2 = (item) => {
14661-
const {
14662-
includeFullContent,
14663-
convertPubDateToISO
14664-
} = getReaderOptions();
14662+
var transform2 = (item, includeFullContent, convertPubDateToISO) => {
1466514663
const {
14666-
title,
14667-
link,
14668-
pubDate,
14669-
description
14664+
title = "",
14665+
link = "",
14666+
pubDate = "",
14667+
description = ""
1467014668
} = item;
1467114669
const published = convertPubDateToISO ? toISODateString(pubDate) : pubDate;
1467214670
const entry = {
@@ -14691,14 +14689,20 @@ var parseRss = (data) => {
1469114689
item = []
1469214690
} = data.rss.channel;
1469314691
const items = (0, import_bellajs6.isArray)(item) ? item : [item];
14692+
const {
14693+
includeFullContent,
14694+
convertPubDateToISO
14695+
} = getReaderOptions();
1469414696
return {
1469514697
title,
1469614698
link,
1469714699
description,
1469814700
language,
1469914701
generator,
1470014702
published: toISODateString(lastBuildDate),
14701-
entries: items.map(transform2)
14703+
entries: items.map((item2) => {
14704+
return transform2(item2, includeFullContent, convertPubDateToISO);
14705+
})
1470214706
};
1470314707
};
1470414708
var parseRssFeed_default = (data) => {
@@ -14724,19 +14728,15 @@ var getLink = (val = [], id = "") => {
1472414728
};
1472514729
return (0, import_bellajs7.isString)(val) ? getText(val) : (0, import_bellajs7.isObject)(val) && (0, import_bellajs7.hasProperty)(val, "href") ? getText(val.href) : (0, import_bellajs7.isObject)(val) && (0, import_bellajs7.hasProperty)(val, "@_href") ? getText(val["@_href"]) : (0, import_bellajs7.isObject)(val) && (0, import_bellajs7.hasProperty)(val, "_attributes") ? getText(val._attributes.href) : (0, import_bellajs7.isArray)(val) ? getEntryLink(val) : null;
1472614730
};
14727-
var transform3 = (item) => {
14731+
var transform3 = (item, includeFullContent, convertPubDateToISO) => {
1472814732
const {
14729-
includeFullContent,
14730-
convertPubDateToISO
14731-
} = getReaderOptions();
14732-
const {
14733-
id,
14734-
title,
14735-
updated,
14736-
published,
14737-
link,
14738-
summary,
14739-
content
14733+
id = "",
14734+
title = "",
14735+
updated = "",
14736+
published = "",
14737+
link = "",
14738+
summary = "",
14739+
content = ""
1474014740
} = item;
1474114741
const pubDate = updated || published;
1474214742
const htmlContent = getText(content);
@@ -14753,7 +14753,7 @@ var transform3 = (item) => {
1475314753
};
1475414754
var parseAtom = (data) => {
1475514755
const {
14756-
id,
14756+
id = "",
1475714757
title = "",
1475814758
link = "",
1475914759
subtitle = "",
@@ -14763,14 +14763,20 @@ var parseAtom = (data) => {
1476314763
entry: item = []
1476414764
} = data.feed;
1476514765
const items = (0, import_bellajs7.isArray)(item) ? item : [item];
14766+
const {
14767+
includeFullContent,
14768+
convertPubDateToISO
14769+
} = getReaderOptions();
1476614770
return {
1476714771
title: getText(title),
1476814772
link: getLink(link, id),
1476914773
description: subtitle,
1477014774
language,
1477114775
generator,
1477214776
published: toISODateString(updated),
14773-
entries: items.map(transform3)
14777+
entries: items.map((item2) => {
14778+
return transform3(item2, includeFullContent, convertPubDateToISO);
14779+
})
1477414780
};
1477514781
};
1477614782
var parseAtomFeed_default = (data) => {

dist/cjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "feed-reader-cjs",
3-
"version": "6.0.0rc3",
3+
"version": "6.0.0rc4",
44
"main": "./feed-reader.js"
55
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"version": "6.0.0rc3",
2+
"version": "6.0.0rc4",
33
"name": "feed-reader",
4-
"description": "Load and parse ATOM/RSS data from given feed url",
4+
"description": "To read and normalize RSS/ATOM/JSON feed data",
55
"homepage": "https://www.npmjs.com/package/feed-reader",
66
"repository": {
77
"type": "git",
@@ -17,7 +17,7 @@
1717
"scripts": {
1818
"lint": "standard .",
1919
"pretest": "npm run lint",
20-
"test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage=true --unhandled-rejections=strict --detectOpenHandles",
20+
"test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage=true",
2121
"build": "node build src/main.js",
2222
"eval": "node eval",
2323
"eval:cjs": "node cjs-eval",

src/utils/normalizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export const toISODateString = (dstr) => {
1717

1818
export const buildDescription = (val) => {
1919
const { descriptionMaxLen } = getReaderOptions()
20-
const stripped = stripTags(val)
20+
const stripped = stripTags(String(val))
2121
return truncate(stripped, descriptionMaxLen).replace(/\n+/g, ' ')
2222
}

src/utils/parseAtomFeed.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,15 @@ const getLink = (val = [], id = '') => {
4141
: isArray(val) ? getEntryLink(val) : null
4242
}
4343

44-
const transform = (item) => {
44+
const transform = (item, includeFullContent, convertPubDateToISO) => {
4545
const {
46-
includeFullContent,
47-
convertPubDateToISO
48-
} = getReaderOptions()
49-
50-
const {
51-
id,
52-
title,
53-
updated,
54-
published,
55-
link,
56-
summary,
57-
content
46+
id = '',
47+
title = '',
48+
updated = '',
49+
published = '',
50+
link = '',
51+
summary = '',
52+
content = ''
5853
} = item
5954

6055
const pubDate = updated || published
@@ -73,7 +68,7 @@ const transform = (item) => {
7368

7469
const parseAtom = (data) => {
7570
const {
76-
id,
71+
id = '',
7772
title = '',
7873
link = '',
7974
subtitle = '',
@@ -85,14 +80,21 @@ const parseAtom = (data) => {
8580

8681
const items = isArray(item) ? item : [item]
8782

83+
const {
84+
includeFullContent,
85+
convertPubDateToISO
86+
} = getReaderOptions()
87+
8888
return {
8989
title: getText(title),
9090
link: getLink(link, id),
9191
description: subtitle,
9292
language,
9393
generator,
9494
published: toISODateString(updated),
95-
entries: items.map(transform)
95+
entries: items.map((item) => {
96+
return transform(item, includeFullContent, convertPubDateToISO)
97+
})
9698
}
9799
}
98100

src/utils/parseJsonFeed.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,18 @@ import {
1111

1212
import { getReaderOptions } from '../config.js'
1313

14-
const transform = (item) => {
14+
const transform = (item, includeFullContent, convertPubDateToISO) => {
1515
const {
16-
includeFullContent,
17-
convertPubDateToISO
18-
} = getReaderOptions()
19-
20-
const {
21-
title,
22-
url: link,
23-
date_published: pubDate,
24-
summary,
25-
content_html: htmlContent,
26-
content_text: textContent
16+
title = '',
17+
url: link = '',
18+
date_published: pubDate = '',
19+
summary = '',
20+
content_html: htmlContent = '',
21+
content_text: textContent = ''
2722
} = item
2823

2924
const published = convertPubDateToISO ? toISODateString(pubDate) : pubDate
25+
3026
const entry = {
3127
title,
3228
link,
@@ -50,14 +46,21 @@ const parseJson = (data) => {
5046

5147
const items = isArray(item) ? item : [item]
5248

49+
const {
50+
includeFullContent,
51+
convertPubDateToISO
52+
} = getReaderOptions()
53+
5354
return {
5455
title,
5556
link: homepageUrl,
5657
description,
5758
language,
5859
published: '',
5960
generator: '',
60-
entries: items.map(transform)
61+
entries: items.map((item) => {
62+
return transform(item, includeFullContent, convertPubDateToISO)
63+
})
6164
}
6265
}
6366

src/utils/parseRssFeed.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ import { purify as purifyUrl } from './linker.js'
1313

1414
import { getReaderOptions } from '../config.js'
1515

16-
const transform = (item) => {
16+
const transform = (item, includeFullContent, convertPubDateToISO) => {
1717
const {
18-
includeFullContent,
19-
convertPubDateToISO
20-
} = getReaderOptions()
21-
22-
const {
23-
title,
24-
link,
25-
pubDate,
26-
description
18+
title = '',
19+
link = '',
20+
pubDate = '',
21+
description = ''
2722
} = item
2823

2924
const published = convertPubDateToISO ? toISODateString(pubDate) : pubDate
25+
3026
const entry = {
3127
title,
3228
link: purifyUrl(link),
@@ -52,14 +48,21 @@ const parseRss = (data) => {
5248

5349
const items = isArray(item) ? item : [item]
5450

51+
const {
52+
includeFullContent,
53+
convertPubDateToISO
54+
} = getReaderOptions()
55+
5556
return {
5657
title,
5758
link,
5859
description,
5960
language,
6061
generator,
6162
published: toISODateString(lastBuildDate),
62-
entries: items.map(transform)
63+
entries: items.map((item) => {
64+
return transform(item, includeFullContent, convertPubDateToISO)
65+
})
6366
}
6467
}
6568

0 commit comments

Comments
 (0)