Skip to content

Commit

Permalink
Fix API examples
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).
  • Loading branch information
khawkins98 committed Jan 8, 2024
1 parent 4009fa9 commit 2916749
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 2916749

Please sign in to comment.