xast-util-feed
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "xast-util-feed", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "xast utility to build feeds (rss, atom)", | ||
@@ -28,15 +28,19 @@ "license": "MIT", | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"main": "./index.mjs", | ||
"module": "./index.mjs", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"lib/", | ||
"index.mjs" | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"@types/xast": "^1.0.0", | ||
"bcp-47-normalize": "^1.0.0", | ||
"unist-builder": "^2.0.0", | ||
"xastscript": "^2.0.0" | ||
"unist-builder": "^3.0.0", | ||
"xastscript": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/tape": "^4.0.0", | ||
"c8": "^7.0.0", | ||
@@ -48,11 +52,16 @@ "concat-stream": "^2.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"xast-util-to-xml": "^2.0.0", | ||
"xo": "^0.37.0" | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xast-util-to-xml": "^3.0.0", | ||
"xo": "^0.39.0" | ||
}, | ||
"scripts": { | ||
"prepack": "npm run build && npm run format", | ||
"build": "rimraf \"{lib/**,}*.d.ts\" && tsc && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"test-api": "node test.mjs", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node --experimental-modules test.mjs", | ||
"test": "npm run format && npm run test-coverage" | ||
"test-api": "node test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
}, | ||
@@ -69,6 +78,2 @@ "prettier": { | ||
"prettier": true, | ||
"esnext": false, | ||
"extensions": [ | ||
"mjs" | ||
], | ||
"rules": { | ||
@@ -83,3 +88,5 @@ "complexity": "off", | ||
], | ||
"no-eq-null": "off" | ||
"no-eq-null": "off", | ||
"no-var": "off", | ||
"prefer-arrow-callback": "off" | ||
} | ||
@@ -91,3 +98,8 @@ }, | ||
] | ||
}, | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"strict": true | ||
} | ||
} |
@@ -28,7 +28,7 @@ # xast-util-feed | ||
Note that this package is ESM only: Node 12+ is required to use it and it must | ||
be imported instead of required. | ||
## Install | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): | ||
Node 12+ is needed to use it and it must be `import`ed instead of `require`d. | ||
[npm][]: | ||
@@ -42,33 +42,33 @@ | ||
Say we have the following module, `example.mjs` | ||
Say we have the following module, `example.js` | ||
```js | ||
import {rss} from 'xast-util-feed' | ||
import toXml from 'xast-util-to-xml' | ||
import {atom, rss} from 'xast-util-feed' | ||
import {toXml} from 'xast-util-to-xml' | ||
var tree = rss( | ||
var channel = { | ||
title: 'NYT > Top Stories', | ||
url: 'https://www.nytimes.com', | ||
feedUrl: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml', | ||
lang: 'en', | ||
author: 'The New York Times Company' | ||
} | ||
var data = [ | ||
{ | ||
title: 'NYT > Top Stories', | ||
url: 'https://www.nytimes.com', | ||
feedUrl: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml', | ||
lang: 'en', | ||
author: 'The New York Times Company' | ||
}, | ||
[ | ||
{ | ||
title: 'Senate Balances Impeachment Trial With an Incoming President', | ||
url: | ||
'https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html', | ||
description: 'Senate leaders etc etc etc.', | ||
author: 'Nicholas Fandos and Catie Edmondson', | ||
published: 'Fri, 15 Jan 2021 01:18:49 +0000', | ||
tags: ['Senate', 'Murkowski, Lisa', 'Trump, Donald J'] | ||
} | ||
] | ||
) | ||
title: 'Senate Balances Impeachment Trial With an Incoming President', | ||
url: | ||
'https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html', | ||
descriptionHtml: '<p>Senate leaders etc etc etc.</p>', | ||
author: 'Nicholas Fandos and Catie Edmondson', | ||
published: 'Fri, 15 Jan 2021 01:18:49 +0000', | ||
tags: ['Senate', 'Murkowski, Lisa', 'Trump, Donald J'] | ||
} | ||
] | ||
console.log(toXml(tree)) | ||
console.log(toXml(rss(channel, data))) | ||
console.log(toXml(atom(channel, data))) | ||
``` | ||
Now, running `node example.mjs` yields (pretty printed): | ||
Now, running `node example.js` yields (pretty printed): | ||
@@ -82,5 +82,5 @@ ```xml | ||
<link>https://www.nytimes.com/</link> | ||
<lastBuildDate>Fri, 15 Jan 2021 11:38:12 GMT</lastBuildDate> | ||
<dc:date>2021-01-15T11:38:12.052Z</dc:date> | ||
<atom:link href="https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" rel="self" type="application/rss+xml" /> | ||
<lastBuildDate>Sun, 17 Jan 2021 09:00:54 GMT</lastBuildDate> | ||
<dc:date>2021-01-17T09:00:54.781Z</dc:date> | ||
<atom:link href="https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" rel="self" type="application/rss+xml"></atom:link> | ||
<language>en</language> | ||
@@ -100,3 +100,3 @@ <dc:language>en</dc:language> | ||
<category>Trump, Donald J</category> | ||
<description>Senate leaders etc etc etc.</description> | ||
<description><p>Senate leaders etc etc etc.</p></description> | ||
</item> | ||
@@ -107,4 +107,36 @@ </channel> | ||
```xml | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> | ||
<title>NYT > Top Stories</title> | ||
<subtitle></subtitle> | ||
<link>https://www.nytimes.com/</link> | ||
<id>https://www.nytimes.com/</id> | ||
<updated>Sun, 17 Jan 2021 09:00:54 GMT</updated> | ||
<link href="https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" rel="self" type="application/atom+xml"></link> | ||
<rights>© 2021 The New York Times Company</rights> | ||
<author> | ||
<name>The New York Times Company</name> | ||
</author> | ||
<category term="Senate"></category> | ||
<category term="Murkowski, Lisa"></category> | ||
<category term="Trump, Donald J"></category> | ||
<entry> | ||
<title>Senate Balances Impeachment Trial With an Incoming President</title> | ||
<author> | ||
<name>Nicholas Fandos and Catie Edmondson</name> | ||
</author> | ||
<link href="https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html"></link> | ||
<id>https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html</id> | ||
<published>2021-01-15T01:18:49.000Z</published> | ||
<content type="html"><p>Senate leaders etc etc etc.</p></content> | ||
</entry> | ||
</feed> | ||
``` | ||
## API | ||
This package exports the following identifiers: `atom`, `rss`. | ||
There is no default export. | ||
### `rss(channel, data)` | ||
@@ -234,3 +266,3 @@ | ||
— Full URL to the resource | ||
* `length` (`number`, example: `24986239`) | ||
* `size` (`number`, example: `24986239`) | ||
— Resource size in bytes | ||
@@ -237,0 +269,0 @@ * `type` (`string`, example: `'audio/mpeg'`) |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
32879
13
577
348
4
13
1
+ Added@types/xast@^1.0.0
+ Addedunist-builder@3.0.1(transitive)
+ Addedxastscript@3.1.1(transitive)
- Removedunist-builder@2.0.3(transitive)
- Removedxastscript@2.1.1(transitive)
Updatedunist-builder@^3.0.0
Updatedxastscript@^3.0.0