Skip to content

Commit 8da63ff

Browse files
committed
Account for when msg is undefined and opts is defined
1 parent c4ddb2e commit 8da63ff

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ module.exports = assert
55

66
function assert (value, status, msg, opts) {
77
if (value) return
8-
if (msg === undefined) {
9-
throw createError(status)
10-
} else if (opts === undefined) {
11-
throw createError(status, msg)
12-
} else {
13-
throw createError(status, msg, opts)
14-
}
8+
var args = [status]
9+
if (msg !== undefined) args.push(msg)
10+
if (opts !== undefined) args.push(opts)
11+
throw createError.apply(null, args)
1512
}
1613

1714
assert.fail = function (status, msg, opts) {

0 commit comments

Comments
 (0)