Comparing version 4.0.2 to 4.0.3
41
index.js
'use strict' | ||
const assert = require('assert') | ||
const { parse } = require('parse-function')() | ||
const messageArgumentIndex = { | ||
// assert(value[, message]) | ||
undefined: 1, | ||
// assert.deepEqual(actual, expected[, message]) | ||
deepEqual: 2, | ||
// assert.deepStrictEqual(actual, expected[, message]) | ||
deepStrictEqual: 2, | ||
// assert.doesNotThrow(block[, error][, message]) | ||
doesNotThrow: 2, | ||
// assert.equal(actual, expected[, message]) | ||
equal: 2, | ||
// Ignoring "fail" expecting message as third argument | ||
// assert.fail(message) | ||
// assert.fail(actual, expected[, message[, operator[, stackStartFunction]]]) | ||
fail: 0, | ||
// assert.ifError(value) | ||
ifError: Infinity, | ||
// assert.notDeepEqual(actual, expected[, message]) | ||
notDeepEqual: 2, | ||
// assert.notDeepStrictEqual(actual, expected[, message]) | ||
notDeepStrictEqual: 2, | ||
// assert.notEqual(actual, expected[, message]) | ||
notEqual: 2, | ||
// assert.notStrictEqual(actual, expected[, message]) | ||
notStrictEqual: 2, | ||
// assert.ok(value[, message]) | ||
ok: 1, | ||
// assert.strictEqual(actual, expected[, message]) | ||
strictEqual: 2, | ||
// assert.throws(block[, error][, message]) | ||
throws: 2, | ||
const getMessageIndex = fn => { | ||
const { args } = parse(fn) | ||
return args.indexOf('message') | ||
} | ||
@@ -40,3 +13,3 @@ | ||
return function (...args) { | ||
try { fn(...args) } | ||
try { return fn(...args) } | ||
catch (e) { | ||
@@ -56,4 +29,4 @@ /** | ||
*/ | ||
const index = messageArgumentIndex[methodName] | ||
const message = index && args[index] | ||
const index = getMessageIndex(fn) | ||
const message = args[index] | ||
if (message) throw message | ||
@@ -60,0 +33,0 @@ throw e |
{ | ||
"name": "avow", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "Proxy for assert that accepts custom Errors", | ||
@@ -30,3 +30,6 @@ "engines": { | ||
"eslint": "^3.18.0" | ||
}, | ||
"dependencies": { | ||
"parse-function": "^5.0.7" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117950
7
1
39
1
+ Addedparse-function@^5.0.7
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/types@7.26.0(transitive)
+ Addedarrify@2.0.1(transitive)
+ Addedparse-function@5.6.10(transitive)