Skip to content

Commit

Permalink
docs: Fix API examples (#587)
Browse files Browse the repository at this point in the history
The API examples in the README.md seemed to stop working as of v2. I've updated them (hopefully correctly).

Co-authored-by: Justin Beckwith <[email protected]>
  • Loading branch information
khawkins98 and JustinBeckwith authored Jun 2, 2024
1 parent 862d89e commit 2ce7188
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ Constructor method that can be used to create a new `LinkChecker` instance. Thi
#### Simple example

```js
const link = require('linkinator');
import { LinkChecker } from 'linkinator';
async function simple() {
const results = await link.check({
const checker = new LinkChecker();
const results = await checker.check({
path: 'http://example.com'
});
Expand Down Expand Up @@ -277,11 +278,11 @@ simple();
In most cases you're going to want to respond to events, as running the check command can kinda take a long time.

```js
const link = require('linkinator');
import { LinkChecker } from 'linkinator';

async function complex() {
// create a new `LinkChecker` that we'll use to run the scan.
const checker = new link.LinkChecker();
const checker = new LinkChecker();

// Respond to the beginning of a new page being scanned
checker.on('pagestart', url => {
Expand Down

0 comments on commit 2ce7188

Please sign in to comment.