Skip to content

Commit 29bf27c

Browse files
authored
docs: improve README.md
1 parent a09a23f commit 29bf27c

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
# Extract domain name from URL
22

33
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JDQMB6MRJXQE&source=url)
4-
![Travis](https://travis-ci.org/bjarneo/extract-domain.svg?branch=master)
54

6-
Performant domain name extraction. No regex or array magic.
5+
This package provides a performant way to extract domain names from URLs without using regular expressions or array manipulations.
76

8-
[What is an URL](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL)
7+
Learn more about [What is a URL](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL)
98

10-
However. This package will also remove the sub domain, and unless the TLD option is used, anything other than the domain and second level domain (so www.example.co.uk would return co.uk)
119

1210
## Supports
1311

14-
Browser and Node.
12+
Both the browser and nodejs.
1513

1614
## Usage
1715

16+
### Installation
1817
```bash
1918
$ npm i --save extract-domain
2019
```
2120

22-
- urls = string|array
23-
- returns string|array
21+
### API
22+
- urls: A string or an array of URLs.
23+
- options { tld: true }: If it should take TLD domains to consideration (i.e. .co.uk)
24+
- returns: A string representing the extracted domain name or an array of domain names.
2425

2526
```js
26-
extractDomain(urls);
27+
extractDomain(urls, options);
2728
```
2829

29-
ES6
30-
30+
ES6 Import
3131
```js
3232
import extractDomain from 'extract-domain';
3333
```
3434

35+
CommonJS Require
3536
```js
3637
const extractDomain = require('extract-domain');
3738
```
3839

40+
Examples
3941
```js
4042
const urls = [
4143
'https://www.npmjs.com/package/extract-domain',
@@ -54,9 +56,9 @@ extractDomain(urls); // [ 'npmjs.com', 'example.com', 'example.com', 'npmjs.com'
5456

5557
## TLD support
5658

57-
TLD support require optional dependency to [`psl` library](https://www.npmjs.com/package/psl).
59+
TLD support requires the optional dependency of the [`psl` library](https://www.npmjs.com/package/psl).
5860

59-
To use the code with the PSL support, you have to wrap in in either an async function, or use it is a promise.
61+
To use the code with the PSL support, you have to wrap it in either an async function or use it as a promise.
6062

6163
Examples
6264

@@ -78,7 +80,7 @@ extractDomain(url, { tld: true }).then(console.log);
7880
// example.co.uk
7981
```
8082

81-
However, using the tld flag will slow down the process by many seconds. Benchmark:
83+
Please note that using the tld flag may significantly slow down the process. Benchmark results:
8284

8385
```
8486
# extract domain 10,000 times

0 commit comments

Comments
 (0)