@hapi/hoek
Advanced tools
Comparing version 10.0.1 to 11.0.0
'use strict'; | ||
const AssertError = require('./error'); | ||
const Errors = require('./errors'); | ||
const Stringify = require('./stringify'); | ||
@@ -9,3 +10,3 @@ | ||
module.exports = function (condition, ...args) { | ||
const assert = module.exports = function (condition, ...args) { | ||
@@ -22,3 +23,10 @@ if (condition) { | ||
throw new AssertError(args); | ||
const msgs = args | ||
.filter((arg) => arg !== '') | ||
.map((arg) => { | ||
return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg); | ||
}); | ||
throw new Errors.AssertError(msgs.join(' '), assert); | ||
}; |
@@ -344,2 +344,11 @@ /// <reference types="node" /> | ||
/** | ||
* Assertion Error as thrown from Hoek.assert(). | ||
*/ | ||
export class AssertError extends Error { | ||
name: 'AssertError'; | ||
} | ||
/** | ||
* A benchmarking timer, using the internal node clock for maximum accuracy. | ||
@@ -346,0 +355,0 @@ */ |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.AssertError = require('./errors').AssertError; | ||
exports.Bench = require('./bench'); | ||
@@ -18,4 +20,2 @@ | ||
exports.Error = require('./error'); | ||
exports.escapeHeaderAttribute = require('./escapeHeaderAttribute'); | ||
@@ -22,0 +22,0 @@ |
{ | ||
"name": "@hapi/hoek", | ||
"description": "General purpose node utilities", | ||
"version": "10.0.1", | ||
"version": "11.0.0", | ||
"repository": "git://github.com/hapijs/hoek", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
51604
1485
1
1