@santi100/assertion-lib
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -26,1 +26,5 @@ # Changelog | ||
- Added `assertMatch` and `assertDefined`. | ||
## Version 2.0.2 | ||
- Fixed circular dependency bug with `assertTypeOf` and `assertOneOf`. |
@@ -1,2 +0,2 @@ | ||
export declare type Type = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function'; | ||
export type Type = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function'; | ||
export declare class AssertionError<E = unknown, A = unknown> extends Error implements AssertOptionalParams<E, A> { | ||
@@ -3,0 +3,0 @@ /** |
"use strict"; | ||
var assertTypeOf = require("./type-of"); | ||
/** Implementation */ | ||
@@ -16,7 +15,7 @@ function assertOneOf(arg, name, choices, comparator) { | ||
else if (typeof comparator !== 'function') | ||
assertTypeOf(comparator, 'function', 'comparator'); | ||
throw new TypeError("\"comparator\" must be of type \"function\". Got ".concat(comparator, " of type \"").concat(typeof comparator, "\".")); | ||
if (__indexOf(choices, arg) === -1) | ||
throw new TypeError("\"".concat(name, "\" must be one of \"").concat(choices.join(', '), "\". Got \"").concat(arg, "\" of type \"").concat(typeof arg, "\".")); | ||
throw new TypeError("\"".concat(name, "\" must be one of ").concat(choices.join(', '), ". Got \"").concat(arg, "\" of type \"").concat(typeof arg, "\".")); | ||
} | ||
assertOneOf.assertOneOf = assertOneOf; | ||
module.exports = assertOneOf; |
{ | ||
"name": "@santi100/assertion-lib", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"main": "cjs/index.js", | ||
@@ -30,8 +30,8 @@ "typings": "cjs/index.d.ts", | ||
"@typescript-eslint/eslint-plugin": "^6.2.1", | ||
"@typescript-eslint/parser": "^5.59.7", | ||
"eslint": "8.46.0", | ||
"@typescript-eslint/parser": "^6.4.0", | ||
"eslint": "8.47.0", | ||
"eslint-plugin-jest": "^27.2.1", | ||
"jest": "^29.5.0", | ||
"prettier": "^3.0.0", | ||
"typescript": "4.8.4" | ||
"typescript": "4.9.5" | ||
}, | ||
@@ -38,0 +38,0 @@ "scripts": { |
@@ -1,3 +0,1 @@ | ||
import assertTypeOf = require('./type-of'); | ||
/** | ||
@@ -57,8 +55,10 @@ * Asserts `arg` is one of `choices`. Throws a `TypeError` otherwise. | ||
else if (typeof comparator !== 'function') | ||
assertTypeOf(comparator, 'function', 'comparator'); | ||
throw new TypeError(`"comparator" must be of type "function". Got ${ | ||
comparator | ||
} of type "${typeof comparator}".`); | ||
if (__indexOf(choices, arg as T) === -1) | ||
throw new TypeError( | ||
`"${name}" must be one of "${choices.join( | ||
`"${name}" must be one of ${choices.join( | ||
', ' | ||
)}". Got "${arg}" of type "${typeof arg}".` | ||
)}. Got "${arg}" of type "${typeof arg}".` | ||
); | ||
@@ -65,0 +65,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
365999