Skip to content

Commit

Permalink
feat(alias): add .throws as alias to .raises, close #75
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Sep 12, 2016
1 parent 641a522 commit 8cd3154
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion dist/check-more-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,10 @@ return /******/ (function(modules) { // webpackBootstrap
rgb.test(value)
}

/** Checks if given function raises an error
/** Checks if given function raises an error. Alias "throws"
@method raises
@alias throws
*/
function raises (fn, errorValidator) {
verify(low.fn(fn), 'expected function that raises')
Expand Down Expand Up @@ -715,6 +716,7 @@ return /******/ (function(modules) { // webpackBootstrap
odd: odd,
oneOf: curry2(oneOf, true),
raises: raises,
throws: raises,
sameLength: sameLength,
startsWith: startsWith,
type: curry2(type),
Expand Down
14 changes: 7 additions & 7 deletions dist/check-more-types.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/mid-level-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ describe('check-more-types mid-level predicates', function () {
}

la(check.raises(foo))
// has "throws" alias
la(check.throws(foo), 'use throws alias')
la(!check.raises(bar))
la(check.raises(foo, isValidError))
la(!check.raises(foo, isInvalid))
Expand Down
4 changes: 3 additions & 1 deletion src/mid-level.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ function hexRgb (value) {
rgb.test(value)
}

/** Checks if given function raises an error
/** Checks if given function raises an error. Alias "throws"
@method raises
@alias throws
*/
function raises (fn, errorValidator) {
verify(low.fn(fn), 'expected function that raises')
Expand Down Expand Up @@ -190,6 +191,7 @@ module.exports = {
odd: odd,
oneOf: curry2(oneOf, true),
raises: raises,
throws: raises,
sameLength: sameLength,
startsWith: startsWith,
type: curry2(type),
Expand Down

0 comments on commit 8cd3154

Please sign in to comment.