@xylabs/assert
Advanced tools
Comparing version 2.10.18 to 2.11.0
@@ -1,3 +0,3 @@ | ||
type AssertExMessageFunc<T> = (value?: T | null) => string; | ||
type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R; | ||
export type AssertExMessageFunc<T> = (value?: T | null) => string; | ||
export type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R; | ||
/** | ||
@@ -15,3 +15,3 @@ * | ||
declare function assertEx<T, R extends Error>(expr?: T | null, errorFunc?: AssertExErrorFunc<T, R>): T; | ||
export { AssertExErrorFunc, AssertExMessageFunc, assertEx, assertEx as default }; | ||
export { assertEx }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,41 +0,15 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
'use strict'; | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
assertEx: () => assertEx, | ||
default: () => src_default | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
function assertEx(expr, messageOrFunc) { | ||
if (expr) | ||
return expr; | ||
if (typeof messageOrFunc === "function") { | ||
const errorOrMessage = messageOrFunc(expr); | ||
throw typeof errorOrMessage === "string" ? Error(errorOrMessage) : errorOrMessage; | ||
} | ||
throw Error(messageOrFunc); | ||
if (expr) | ||
return expr; | ||
if (typeof messageOrFunc === 'function') { | ||
const errorOrMessage = messageOrFunc(expr); | ||
throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage; | ||
} | ||
// a string was sent | ||
throw Error(messageOrFunc); | ||
} | ||
var src_default = assertEx; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
assertEx | ||
}); | ||
//# sourceMappingURL=index.js.map | ||
exports.assertEx = assertEx; | ||
//# sourceMappingURL=index.js.map |
@@ -44,6 +44,4 @@ { | ||
"devDependencies": { | ||
"@xylabs/ts-scripts-yarn3": "^2.19.12", | ||
"@xylabs/tsconfig": "^2.19.12", | ||
"publint": "^0.2.2", | ||
"tsup": "^7.2.0" | ||
"@xylabs/ts-scripts-yarn3": "^3.0.0-rc.15", | ||
"@xylabs/tsconfig": "^3.0.0-rc.15" | ||
}, | ||
@@ -60,6 +58,2 @@ "homepage": "https://xylabs.com", | ||
}, | ||
"scripts": { | ||
"package-compile": "tsup && publint", | ||
"package-recompile": "tsup && publint" | ||
}, | ||
"repository": { | ||
@@ -70,3 +64,3 @@ "type": "git", | ||
"sideEffects": false, | ||
"version": "2.10.18" | ||
"version": "2.11.0" | ||
} |
@@ -26,5 +26,2 @@ export type AssertExMessageFunc<T> = (value?: T | null) => string | ||
// eslint-disable-next-line import/no-default-export | ||
export default assertEx | ||
export { assertEx } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
2
12
16600
64