Skip to content

Commit 05dc91c

Browse files
authored
Merge pull request #176 from extractus/3.2.0
v3.2.0
2 parents 90b5f67 + e643c18 commit 05dc91c

File tree

22 files changed

+87
-7792
lines changed

22 files changed

+87
-7792
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ coverage.lcov
1515
yarn.lock
1616
pnpm-lock.yaml
1717
package-lock.json
18+
deno.lock

README.md

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,9 @@
44
Extract oEmbed content from given URL.
55

66
[![NPM](https://badge.fury.io/js/@extractus%2Foembed-extractor.svg)](https://badge.fury.io/js/@extractus%2Foembed-extractor)
7+
![CodeQL](https://github.com/extractus/oembed-extractor/workflows/CodeQL/badge.svg)
78
[![CI test](https://github.com/extractus/oembed-extractor/workflows/ci-test/badge.svg)](https://github.com/extractus/oembed-extractor/actions)
89
[![Coverage Status](https://coveralls.io/repos/github/extractus/oembed-extractor/badge.svg)](https://coveralls.io/github/extractus/oembed-extractor)
9-
![CodeQL](https://github.com/extractus/oembed-extractor/workflows/CodeQL/badge.svg)
10-
11-
## Intro
12-
13-
*oembed-extractor* is a part of tool sets for content builder:
14-
15-
- [feed-extractor](https://github.com/extractus/feed-extractor): extract & normalize RSS/ATOM/JSON feed
16-
- [article-extractor](https://github.com/extractus/article-extractor): extract main article from given URL
17-
- [oembed-extractor](https://github.com/extractus/oembed-extractor): extract oEmbed data from supported providers
18-
19-
You can use one or combination of these tools to build news sites, create automated content systems for marketing campaign or gather dataset for NLP projects...
20-
21-
### Attention
22-
23-
`oembed-parser` has been renamed to `@extractus/oembed-extractor` since v3.1.5
24-
2510

2611
## Demo
2712

@@ -73,7 +58,7 @@ console.log(result)
7358
### Browser
7459

7560
```ts
76-
import { extract } from 'https://unpkg.com/@extractus/oembed-extractor@latest/dist/oembed-extractor.esm.js'
61+
import { extract } from "https://esm.sh/@extractus/oembed-extractor@latest"
7762
```
7863

7964
Please check [the examples](examples) for reference.
@@ -115,6 +100,13 @@ Please see the provider's oEmbed API docs carefully for exact information.
115100

116101
##### `fetchOptions` *optional*
117102

103+
`fetchOptions` is an object that can have the following properties:
104+
105+
- `headers`: to set request headers
106+
- `proxy`: another endpoint to forward the request to
107+
- `agent`: a HTTP proxy agent
108+
- `signal`: AbortController signal or AbortSignal timeout to terminate the request
109+
118110
You can use this param to set request headers to fetch.
119111

120112
For example:
@@ -173,6 +165,36 @@ console.log(oembed)
173165

174166
For more info about [https-proxy-agent](https://www.npmjs.com/package/https-proxy-agent), check [its repo](https://github.com/TooTallNate/proxy-agents).
175167

168+
By default, there is no request timeout. You can use the option `signal` to cancel request at the right time.
169+
170+
The common way is to use AbortControler:
171+
172+
```js
173+
const controller = new AbortController()
174+
175+
// stop after 5 seconds
176+
setTimeout(() => {
177+
controller.abort()
178+
}, 5000)
179+
180+
const oembed = await extract(url, null, {
181+
signal: controller.signal,
182+
})
183+
```
184+
185+
A newer solution is AbortSignal's `timeout()` static method:
186+
187+
```js
188+
// stop after 5 seconds
189+
const oembed = await extract(url, null, {
190+
signal: AbortSignal.timeout(5000),
191+
})
192+
```
193+
194+
For more info:
195+
196+
- [AbortController constructor](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
197+
- [AbortSignal: timeout() static method](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static)
176198

177199

178200
### `.setProviderList()`

build.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

build.test.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

cjs-eval.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

dist/cjs/index.d.ts

Lines changed: 0 additions & 161 deletions
This file was deleted.

0 commit comments

Comments
 (0)