Skip to content

Commit

Permalink
Updating Read Me
Browse files Browse the repository at this point in the history
  • Loading branch information
seantomburke committed Jul 29, 2022
1 parent 5bd8b45 commit cbc1f0a
Showing 1 changed file with 49 additions and 71 deletions.
120 changes: 49 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,27 @@ Parse through a sitemaps xml to get all the urls for your crawler.

## Version 4

Version 4.0.0 introduces breaking changes and supports ECMAScript Modules (ESM)
> Version 4.0.0 introduces breaking changes and supports ECMAScript Modules (ESM)
If upgrading to 4.0.0 you will not be able to use require() to import the dependency.
You must use import() to import the dependencies.
You will also need to upgrade to Node version >=14.16

## Version 3



## Version 2
You will also need to upgrade to `Node >= 14.16`

### Installation
```bash
npm install sitemapper --save
npm install sitemapper@latest --save
```

### Simple Example
```javascript
const Sitemapper = require('sitemapper');
import Sitemapper from 'sitemapper';

const sitemap = new Sitemapper();

sitemap.fetch('https://wp.seantburke.com/sitemap.xml').then(function(sites) {
console.log(sites);
});

```
### Examples in ES6
```javascript
import Sitemapper from 'sitemapper';

(async () => {
const Google = new Sitemapper({
url: 'https://www.google.com/work/sitemap.xml',
timeout: 15000, // 15 seconds
});

try {
const { sites } = await Google.fetch();
const { sites } = await sitemap.fetch('https://wp.seantburke.com/sitemap.xml');
console.log(sites);
} catch (error) {
console.log(error);
}
})();

// or

const sitemapper = new Sitemapper();
sitemapper.timeout = 5000;

sitemapper.fetch('https://wp.seantburke.com/sitemap.xml')
.then(({ url, sites }) => console.log(`url:${url}`, 'sites:', sites))
.catch(error => console.log(error));
```

# Options

You can add options on the initial Sitemapper object when instantiating it.
Expand Down Expand Up @@ -113,56 +79,68 @@ const sitemapper = new Sitemapper({

```

### Examples in ES5
### Examples in ESM
```javascript
var Sitemapper = require('sitemapper');

var Google = new Sitemapper({
url: 'https://www.google.com/work/sitemap.xml',
timeout: 15000 //15 seconds
});
import Sitemapper from 'sitemapper';

Google.fetch()
.then(function (data) {
console.log(data);
})
.catch(function (error) {
console.log(error);
(async () => {
const Google = new Sitemapper({
url: 'https://www.google.com/work/sitemap.xml',
timeout: 15000, // 15 seconds
});

try {
const { sites } = await Google.fetch();
console.log(sites);
} catch (error) {
console.log(error);
}
})();

// or


var sitemapper = new Sitemapper();

const sitemapper = new Sitemapper();
sitemapper.timeout = 5000;
sitemapper.fetch('https://wp.seantburke.com/sitemap.xml')
.then(function (data) {
console.log(data);
})
.catch(function (error) {
console.log(error);
});

sitemapper.fetch('https://wp.seantburke.com/sitemap.xml')
.then(({ url, sites }) => console.log(`url:${url}`, 'sites:', sites))
.catch(error => console.log(error));
```

## Version 1

## Version 3

> Works for `Node 10.X` to `Node 12.X`
### Installation
```bash
npm install sitemapper@1.1.1 --save
npm install sitemapper@3.2 --save
```

### Simple Example
```javascript
const Sitemapper = require('sitemapper');

const sitemap = new Sitemapper();

sitemap.fetch('https://wp.seantburke.com/sitemap.xml').then(function(sites) {
console.log(sites);
});

### Example in JS
```javascript
var Sitemapper = require('sitemapper');
var sitemapper = new Sitemapper();

sitemapper.getSites('https://wp.seantburke.com/sitemap.xml', function(err, sites) {
if (!err) {
console.log(sites);
}
var Google = new Sitemapper({
url: 'https://www.google.com/work/sitemap.xml',
timeout: 15000 //15 seconds
});
```
Google.fetch()
.then(function (data) {
console.log(data);
})
.catch(function (error) {
console.log(error);
});

0 comments on commit cbc1f0a

Please sign in to comment.