From 68102188f70a8f3cb95383cc883e5d151c177b89 Mon Sep 17 00:00:00 2001 From: Bas Huis Date: Wed, 20 Oct 2021 13:53:12 +0200 Subject: [PATCH] Improve PatroonError example --- README.md | 17 +++++++++++------ README.mz | 10 ++++++---- tape-test | 5 +++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 16e9b47..c07780f 100644 --- a/README.md +++ b/README.md @@ -419,11 +419,16 @@ UnevenArgumentCountError: Patroon should have an even amount of arguments. #### PatroonError -All error patroon produces can be matched against the PatroonError using `instanceof`. +All errors patroon produces can be matched against the PatroonError using `instanceof`. -```js -assert.equal(new NoMatchError() instanceof PatroonError, true) -assert.equal(new UnevenArgumentCountError() instanceof PatroonError, true) +```js ./tape-test +const isPatroonError = patroon(PatroonError, 'patroon is causing an error') + +isPatroonError(new NoMatchError()) +isPatroonError(new UnevenArgumentCountError()) +``` +``` +patroon is causing an error ``` ## Tests @@ -445,7 +450,7 @@ npx nyc npm t | npx tap-nyc npx nyc check-coverage ``` ``` - > patroon@0.1.5 test + > patroon@0.2.0 test > tape ./src/index.test.js -------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s @@ -459,7 +464,7 @@ npx nyc check-coverage total: 5 passing: 5 - duration: 2.2s + duration: 7ms ``` diff --git a/README.mz b/README.mz index c1159d1..7a3c3fb 100644 --- a/README.mz +++ b/README.mz @@ -320,11 +320,13 @@ patroon(1) #### PatroonError -All error patroon produces can be matched against the PatroonError using `instanceof`. +All errors patroon produces can be matched against the PatroonError using `instanceof`. -```js -assert.equal(new NoMatchError() instanceof PatroonError, true) -assert.equal(new UnevenArgumentCountError() instanceof PatroonError, true) +```js ./tape-test +const isPatroonError = patroon(PatroonError, 'patroon is causing an error') + +isPatroonError(new NoMatchError()) +isPatroonError(new UnevenArgumentCountError()) ``` ## Tests diff --git a/tape-test b/tape-test index b11ef80..bde2a83 100755 --- a/tape-test +++ b/tape-test @@ -1,13 +1,14 @@ #!/usr/bin/env bash cat <(echo ' -const assert = require("assert") const { _, typed, ref, patroon, - NoMatchError + NoMatchError, + UnevenArgumentCountError, + PatroonError } = require("./src/index")