Skip to content

Commit

Permalink
Improve PatroonError example
Browse files Browse the repository at this point in the history
  • Loading branch information
bas080 committed Oct 20, 2021
1 parent 48b70bc commit 6810218
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -459,7 +464,7 @@ npx nyc check-coverage
total: 5
passing: 5
duration: 2.2s
duration: 7ms
```

Expand Down
10 changes: 6 additions & 4 deletions README.mz
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tape-test
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 6810218

Please sign in to comment.