From cbc1f0a2de42e5756d3c31174c39f9c8f8425e13 Mon Sep 17 00:00:00 2001 From: Sean Thomas Burke Date: Thu, 28 Jul 2022 23:26:37 -0700 Subject: [PATCH] Updating Read Me --- README.md | 120 ++++++++++++++++++++++-------------------------------- 1 file changed, 49 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index d6c3d4d..f4e2438 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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); + }); +