From 2ce71883cb598c845fb397369d72e6f5699a0ec9 Mon Sep 17 00:00:00 2001 From: Ken Hawkins Date: Sun, 2 Jun 2024 17:58:40 +0200 Subject: [PATCH] docs: Fix API examples (#587) 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 --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ed3cab4..9d6bcf1 100644 --- a/README.md +++ b/README.md @@ -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' }); @@ -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 => {