Socket
Socket
Sign inDemoInstall

@extractus/feed-extractor

Package Overview
Dependencies
12
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.2.4 to 6.3.0

8

eval.js

@@ -8,6 +8,8 @@ // eval.js

try {
const art = await read(url)
console.log(art)
console.time('extract-feed')
const feed = await read(url)
console.log(feed)
console.timeEnd('extract-feed')
} catch (err) {
console.trace(err)
console.log(err.message)
}

@@ -14,0 +16,0 @@ }

@@ -83,2 +83,7 @@ // Type definitions

agent?: object;
/**
* signal to terminate request
* default: null
*/
signal?: object;
}

@@ -85,0 +90,0 @@

{
"version": "6.2.4",
"version": "6.3.0",
"name": "@extractus/feed-extractor",

@@ -13,7 +13,2 @@ "description": "To read and normalize RSS/ATOM/JSON feed data",

"type": "module",
"exports": {
"types": "./index.d.ts",
"import": "./src/main.js",
"require": "./dist/cjs/feed-extractor.js"
},
"imports": {

@@ -27,3 +22,3 @@ "cross-fetch": "./src/deno/cross-fetch.js"

"engines": {
"node": ">= 14"
"node": ">= 15"
},

@@ -36,3 +31,2 @@ "scripts": {

"eval": "node eval",
"build": "node build",
"reset": "node reset"

@@ -47,3 +41,2 @@ },

"devDependencies": {
"esbuild": "^0.18.11",
"eslint": "^8.44.0",

@@ -50,0 +43,0 @@ "https-proxy-agent": "^7.0.0",

@@ -177,6 +177,11 @@ # feed-extractor

You can use this param to set request headers to fetch.
`fetchOptions` is an object that can have the following properties:
For example:
- `headers`: to set request headers
- `proxy`: another endpoint to forward the request to
- `agent`: a HTTP proxy agent
- `signal`: AbortController signal or AbortSignal timeout to terminate the request
For example, you can use this param to set request headers to fetch as below:
```js

@@ -238,3 +243,34 @@ import { extract } from '@extractus/feed-extractor'

By default, there is no request timeout. You can use the option `signal` to cancel request at the right time.
The common way is to use AbortControler:
```js
const controller = new AbortController()
// stop after 5 seconds
setTimeout(() => {
controller.abort()
}, 5000)
const data = await extract(url, null, {
signal: controller.signal,
})
```
A newer solution is AbortSignal's `timeout()` static method:
```js
// stop after 5 seconds
const data = await extract(url, null, {
signal: AbortSignal.timeout(5000),
})
```
For more info:
- [AbortController constructor](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
- [AbortSignal: timeout() static method](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static)
### `extractFromJson()`

@@ -241,0 +277,0 @@

@@ -5,3 +5,4 @@ // utils -> retrieve

const profetch = async (url, proxy = {}) => {
const profetch = async (url, options = {}) => {
const { proxy = {}, signal = null } = options
const {

@@ -13,2 +14,3 @@ target,

headers,
signal,
})

@@ -21,9 +23,10 @@ return res

headers = {
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0',
},
proxy = null,
agent = null,
signal = null,
} = options
const res = proxy ? await profetch(url, proxy) : await fetch(url, { headers, agent })
const res = proxy ? await profetch(url, { proxy, signal }) : await fetch(url, { headers, agent, signal })

@@ -30,0 +33,0 @@ const status = res.status

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc