@santi100/assertion-lib
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,4 +0,18 @@ | ||
class AssertionError extends Error { | ||
constructor(expected: unknown, actual: unknown, operator: string): AssertionError; | ||
declare class AssertionError extends Error { | ||
constructor(expected: unknown, actual: unknown, operator: string); | ||
} | ||
declare interface AssertOptionalParams { | ||
/** | ||
* Expected value for the assertion. | ||
*/ | ||
expected: unknown; | ||
/** | ||
* Received value for the assertion. | ||
*/ | ||
actual: unknown; | ||
/** | ||
* Optional operator used for the assertion. | ||
*/ | ||
operator?: string; | ||
} | ||
/** | ||
@@ -9,5 +23,10 @@ * Asserts that ```condition``` is truthy. | ||
* @param {boolean} condition A boolean condition to assert. | ||
* @param {AssertOptionalParams} errorParams Parameters for the AssertionError that will be thrown | ||
* in case the condition is falsy. | ||
* @param {unknown} errorParams.expected Expected value for the assertion. | ||
* @param {unknown} errorParams.actual Received value for the assertion. | ||
* @param {string?} errorParams.operator Optional operator used for the assertion. | ||
* @returns {void} Nothing. | ||
*/ | ||
declare function assert(condition: boolean): void; | ||
declare function assert(condition: boolean, { expected, actual, operator }?: AssertOptionalParams): void; | ||
/** | ||
@@ -14,0 +33,0 @@ * Asserts that the type of ```val``` is ```expectedType```. |
@@ -7,3 +7,3 @@ class AssertionError extends Error { | ||
} | ||
function assert(condition, { expected, actual, operator }) { | ||
function assert(condition, { expected = null, actual = null, operator = null }) { | ||
if (!condition) throw new AssertionError(expected, actual, operator); | ||
@@ -10,0 +10,0 @@ } |
{ | ||
"name": "@santi100/assertion-lib", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "Other", |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
5372
8
87
1
30
1
80