@xylabs/assert 2.10.17 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -9
- package/src/index.ts +0 -3
- package/tsup.config.ts +0 -16
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
type AssertExMessageFunc<T> = (value?: T | null) => string;
|
|
2
|
-
type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R;
|
|
1
|
+
export type AssertExMessageFunc<T> = (value?: T | null) => string;
|
|
2
|
+
export type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R;
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* Intended for simple null/undefined checks for variables
|
|
@@ -12,5 +12,5 @@ type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R;
|
|
|
12
12
|
declare function assertEx<T>(expr?: T | null, message?: string): T;
|
|
13
13
|
declare function assertEx<T>(expr?: T | null, messageFunc?: AssertExMessageFunc<T>): T;
|
|
14
14
|
declare function assertEx<T, R extends Error>(expr?: T | null, errorFunc?: AssertExErrorFunc<T, R>): T;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export { assertEx };
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,KAAK,MAAM,CAAA;AACjE,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,CAAA;AAE3E;;;;;;;;GAQG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAA;AAC1D,iBAAS,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAC9E,iBAAS,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;AAW9F,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
type AssertExMessageFunc<T> = (value?: T | null) => string;
|
|
2
|
-
type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R;
|
|
1
|
+
export type AssertExMessageFunc<T> = (value?: T | null) => string;
|
|
2
|
+
export type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R;
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* Intended for simple null/undefined checks for variables
|
|
@@ -12,5 +12,5 @@ type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R;
|
|
|
12
12
|
declare function assertEx<T>(expr?: T | null, message?: string): T;
|
|
13
13
|
declare function assertEx<T>(expr?: T | null, messageFunc?: AssertExMessageFunc<T>): T;
|
|
14
14
|
declare function assertEx<T, R extends Error>(expr?: T | null, errorFunc?: AssertExErrorFunc<T, R>): T;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export { assertEx };
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,KAAK,MAAM,CAAA;AACjE,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,CAAA;AAE3E;;;;;;;;GAQG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAA;AAC1D,iBAAS,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAC9E,iBAAS,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;AAW9F,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
assertEx: () => assertEx,
|
|
24
|
-
default: () => src_default
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(src_exports);
|
|
27
3
|
function assertEx(expr, messageOrFunc) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
4
|
+
if (expr)
|
|
5
|
+
return expr;
|
|
6
|
+
if (typeof messageOrFunc === 'function') {
|
|
7
|
+
const errorOrMessage = messageOrFunc(expr);
|
|
8
|
+
throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage;
|
|
9
|
+
}
|
|
10
|
+
// a string was sent
|
|
11
|
+
throw Error(messageOrFunc);
|
|
35
12
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
assertEx
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
|
13
|
+
|
|
14
|
+
exports.assertEx = assertEx;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA,SAAY,QAAA,CAAA,IAAA,EAAA,aAAyB,EAAC;AACtC,IAAA,QAAY;AAEZ,QAAA,OAAA,IAAA,CAAA;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
function assertEx(expr, messageOrFunc) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
if (expr)
|
|
3
|
+
return expr;
|
|
4
|
+
if (typeof messageOrFunc === 'function') {
|
|
5
|
+
const errorOrMessage = messageOrFunc(expr);
|
|
6
|
+
throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage;
|
|
7
|
+
}
|
|
8
|
+
// a string was sent
|
|
9
|
+
throw Error(messageOrFunc);
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
|
|
14
|
-
src_default as default
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=index.mjs.map
|
|
11
|
+
|
|
12
|
+
export { assertEx };
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,SAAY,QAAA,CAAA,IAAA,EAAA,aAAyB,EAAC;AACtC,IAAA,QAAY;AAEZ,QAAA,OAAA,IAAA,CAAA;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -41,10 +41,8 @@
|
|
|
41
41
|
"main": "dist/index.js",
|
|
42
42
|
"module": "dist/index.mjs",
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@xylabs/ts-scripts-yarn3": "^
|
|
45
|
-
"@xylabs/tsconfig": "^
|
|
46
|
-
"publint": "^0.2.2",
|
|
47
|
-
"tsup": "^7.2.0"
|
|
44
|
+
"@xylabs/ts-scripts-yarn3": "^3.0.0-rc.15",
|
|
45
|
+
"@xylabs/tsconfig": "^3.0.0-rc.15"
|
|
48
46
|
},
|
|
49
47
|
"homepage": "https://xylabs.com",
|
|
50
48
|
"keywords": [
|
|
@@ -56,14 +54,10 @@
|
|
|
56
54
|
"publishConfig": {
|
|
57
55
|
"access": "public"
|
|
58
56
|
},
|
|
59
|
-
"scripts": {
|
|
60
|
-
"package-compile": "tsup && publint",
|
|
61
|
-
"package-recompile": "tsup && publint"
|
|
62
|
-
},
|
|
63
57
|
"repository": {
|
|
64
58
|
"type": "git",
|
|
65
59
|
"url": "https://github.com/xylabs/sdk-js.git"
|
|
66
60
|
},
|
|
67
61
|
"sideEffects": false,
|
|
68
|
-
"version": "2.
|
|
62
|
+
"version": "2.11.0"
|
|
69
63
|
}
|
package/src/index.ts
CHANGED
package/tsup.config.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line import/no-default-export
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
bundle: true,
|
|
6
|
-
cjsInterop: true,
|
|
7
|
-
clean: false,
|
|
8
|
-
dts: {
|
|
9
|
-
entry: ['src/index.ts'],
|
|
10
|
-
},
|
|
11
|
-
entry: ['src/index.ts'],
|
|
12
|
-
format: ['cjs', 'esm'],
|
|
13
|
-
sourcemap: true,
|
|
14
|
-
splitting: false,
|
|
15
|
-
tsconfig: 'tsconfig.build.json',
|
|
16
|
-
})
|