Skip to content

Commit

Permalink
Improve the deprecated message
Browse files Browse the repository at this point in the history
  • Loading branch information
bas080 committed Nov 10, 2021
1 parent ab8abb7 commit 237d812
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Patroon

Pattern matching in JavaScript without additional syntax
Pattern matching in JavaScript without additional syntax.

[![NPM](https://img.shields.io/npm/v/patroon?color=blue&style=flat-square)](https://www.npmjs.com/package/patroon)
[![NPM Downloads](https://img.shields.io/npm/dm/patroon?style=flat-square)](https://www.npmjs.com/package/patroon)
Expand Down Expand Up @@ -545,7 +545,7 @@ npx nyc check-coverage
total: 15
passing: 15
duration: 1.5s
duration: 703ms
```

Expand Down
10 changes: 4 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const deprecated = (fn, message) => (...args) => {

const typed = deprecated(function typed (Ctor, pattern) {
return every(Ctor, pattern)
}, 'replace "typed(Constructor, [pattern])" with "every(Constructor, pattern)"')
}, 'replace "typed" or "t" helpers with "every(Constructor, pattern)"')

const isRegExp = is(RegExp)

Expand Down Expand Up @@ -87,14 +87,12 @@ const patroon = (...list) => {

if (isNil(found)) { throw new NoMatchError(`Not able to match any pattern for value ${JSON.stringify(args)}`) }

const [, doFn] = found

return doFn(...args)
return found[1](...args)
}
}

function reference (fn) {
return (arg) => fn === arg
function reference (any) {
return value => any === value
}

module.exports = Object.assign(patroon, {
Expand Down

0 comments on commit 237d812

Please sign in to comment.