@xylabs/assert 2.9.3 → 2.10.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 +16 -0
- package/dist/{types/index.d.ts → index.d.ts} +4 -5
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +16 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +28 -14
- package/tsup.config.ts +14 -0
- package/dist/cjs/index.js +0 -17
- package/dist/cjs/index.js.map +0 -1
- package/dist/docs.json +0 -687
- package/dist/esm/index.js +0 -14
- package/dist/esm/index.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/docs/assets/highlight.css +0 -50
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1367
- package/docs/functions/assertEx.html +0 -108
- package/docs/index.html +0 -85
- package/docs/modules.html +0 -65
- package/docs/types/AssertExErrorFunc.html +0 -64
- package/docs/types/AssertExMessageFunc.html +0 -62
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type AssertExMessageFunc<T> = (value?: T | null) => string;
|
|
2
|
+
type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R;
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Intended for simple null/undefined checks for variables
|
|
6
|
+
*
|
|
7
|
+
* @param expr - Expression to be evaluated for truthiness
|
|
8
|
+
* @param message - Message in Error if expression is false, may be a function that returns a string
|
|
9
|
+
* @throws AssertExError
|
|
10
|
+
* @returns Value of expression
|
|
11
|
+
*/
|
|
12
|
+
declare function assertEx<T>(expr?: T | null, message?: string): T;
|
|
13
|
+
declare function assertEx<T>(expr?: T | null, messageFunc?: AssertExMessageFunc<T>): T;
|
|
14
|
+
declare function assertEx<T, R extends Error>(expr?: T | null, errorFunc?: AssertExErrorFunc<T, R>): T;
|
|
15
|
+
|
|
16
|
+
export { AssertExErrorFunc, AssertExMessageFunc, assertEx, assertEx as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type AssertExMessageFunc<T> = (value?: T | null) => string;
|
|
2
|
+
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,6 +12,5 @@ export 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
|
-
export { assertEx };
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
15
|
+
|
|
16
|
+
export { AssertExErrorFunc, AssertExMessageFunc, assertEx, assertEx as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
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);
|
|
19
|
+
|
|
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
|
+
function assertEx(expr, messageOrFunc) {
|
|
28
|
+
if (expr)
|
|
29
|
+
return expr;
|
|
30
|
+
if (typeof messageOrFunc === "function") {
|
|
31
|
+
const errorOrMessage = messageOrFunc(expr);
|
|
32
|
+
throw typeof errorOrMessage === "string" ? Error(errorOrMessage) : errorOrMessage;
|
|
33
|
+
}
|
|
34
|
+
throw Error(messageOrFunc);
|
|
35
|
+
}
|
|
36
|
+
var src_default = assertEx;
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
assertEx
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type AssertExMessageFunc<T> = (value?: T | null) => string\nexport type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R\n\n/**\n *\n * Intended for simple null/undefined checks for variables\n *\n * @param expr - Expression to be evaluated for truthiness\n * @param message - Message in Error if expression is false, may be a function that returns a string\n * @throws AssertExError\n * @returns Value of expression\n */\nfunction assertEx<T>(expr?: T | null, message?: string): T\nfunction assertEx<T>(expr?: T | null, messageFunc?: AssertExMessageFunc<T>): T\nfunction assertEx<T, R extends Error>(expr?: T | null, errorFunc?: AssertExErrorFunc<T, R>): T\nfunction assertEx<T, R extends Error, P extends string | AssertExMessageFunc<T> | AssertExErrorFunc<T, R>>(expr?: T | null, messageOrFunc?: P): T {\n if (expr) return expr\n if (typeof messageOrFunc === 'function') {\n const errorOrMessage = messageOrFunc(expr)\n throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage\n }\n // a string was sent\n throw Error(messageOrFunc)\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default assertEx\n\nexport { assertEx }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,SAAS,SAAkG,MAAiB,eAAsB;AAChJ,MAAI;AAAM,WAAO;AACjB,MAAI,OAAO,kBAAkB,YAAY;AACvC,UAAM,iBAAiB,cAAc,IAAI;AACzC,UAAM,OAAO,mBAAmB,WAAW,MAAM,cAAc,IAAI;AAAA,EACrE;AAEA,QAAM,MAAM,aAAa;AAC3B;AAGA,IAAO,cAAQ;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function assertEx(expr, messageOrFunc) {
|
|
3
|
+
if (expr)
|
|
4
|
+
return expr;
|
|
5
|
+
if (typeof messageOrFunc === "function") {
|
|
6
|
+
const errorOrMessage = messageOrFunc(expr);
|
|
7
|
+
throw typeof errorOrMessage === "string" ? Error(errorOrMessage) : errorOrMessage;
|
|
8
|
+
}
|
|
9
|
+
throw Error(messageOrFunc);
|
|
10
|
+
}
|
|
11
|
+
var src_default = assertEx;
|
|
12
|
+
export {
|
|
13
|
+
assertEx,
|
|
14
|
+
src_default as default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type AssertExMessageFunc<T> = (value?: T | null) => string\nexport type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R\n\n/**\n *\n * Intended for simple null/undefined checks for variables\n *\n * @param expr - Expression to be evaluated for truthiness\n * @param message - Message in Error if expression is false, may be a function that returns a string\n * @throws AssertExError\n * @returns Value of expression\n */\nfunction assertEx<T>(expr?: T | null, message?: string): T\nfunction assertEx<T>(expr?: T | null, messageFunc?: AssertExMessageFunc<T>): T\nfunction assertEx<T, R extends Error>(expr?: T | null, errorFunc?: AssertExErrorFunc<T, R>): T\nfunction assertEx<T, R extends Error, P extends string | AssertExMessageFunc<T> | AssertExErrorFunc<T, R>>(expr?: T | null, messageOrFunc?: P): T {\n if (expr) return expr\n if (typeof messageOrFunc === 'function') {\n const errorOrMessage = messageOrFunc(expr)\n throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage\n }\n // a string was sent\n throw Error(messageOrFunc)\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default assertEx\n\nexport { assertEx }\n"],"mappings":";AAeA,SAAS,SAAkG,MAAiB,eAAsB;AAChJ,MAAI;AAAM,WAAO;AACjB,MAAI,OAAO,kBAAkB,YAAY;AACvC,UAAM,iBAAiB,cAAc,IAAI;AACzC,UAAM,OAAO,mBAAmB,WAAW,MAAM,cAAc,IAAI;AAAA,EACrE;AAEA,QAAM,MAAM,aAAa;AAC3B;AAGA,IAAO,cAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -11,30 +11,40 @@
|
|
|
11
11
|
"url": "https://github.com/xylabs/sdk-js/issues"
|
|
12
12
|
},
|
|
13
13
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
14
|
-
"browser": "dist/esm/index.js",
|
|
15
|
-
"main": "dist/cjs/index.js",
|
|
16
|
-
"module": "dist/esm/index.js",
|
|
17
14
|
"docs": "dist/docs.json",
|
|
18
|
-
"types": "dist/
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
19
16
|
"exports": {
|
|
20
17
|
".": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
24
21
|
},
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
}
|
|
29
|
-
"default": "./dist/esm/index.js"
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
|
+
"default": "./dist/index.mjs"
|
|
25
|
+
}
|
|
30
26
|
},
|
|
31
27
|
"./dist/docs.json": {
|
|
32
28
|
"default": "./dist/docs.json"
|
|
33
29
|
},
|
|
30
|
+
"./cjs": {
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./docs": {
|
|
34
|
+
"default": "./dist/docs.json"
|
|
35
|
+
},
|
|
36
|
+
"./esm": {
|
|
37
|
+
"default": "./dist/index.mjs"
|
|
38
|
+
},
|
|
34
39
|
"./package.json": "./package.json"
|
|
35
40
|
},
|
|
41
|
+
"main": "dist/index.js",
|
|
42
|
+
"module": "dist/index.mjs",
|
|
36
43
|
"devDependencies": {
|
|
37
|
-
"@xylabs/ts-scripts-yarn3": "^2.
|
|
44
|
+
"@xylabs/ts-scripts-yarn3": "^2.19.5",
|
|
45
|
+
"@xylabs/tsconfig": "^2.19.5",
|
|
46
|
+
"publint": "^0.2.2",
|
|
47
|
+
"tsup": "^7.2.0"
|
|
38
48
|
},
|
|
39
49
|
"homepage": "https://xylabs.com",
|
|
40
50
|
"keywords": [
|
|
@@ -46,10 +56,14 @@
|
|
|
46
56
|
"publishConfig": {
|
|
47
57
|
"access": "public"
|
|
48
58
|
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"package-compile": "tsup && publint",
|
|
61
|
+
"package-recompile": "tsup && publint"
|
|
62
|
+
},
|
|
49
63
|
"repository": {
|
|
50
64
|
"type": "git",
|
|
51
65
|
"url": "https://github.com/xylabs/sdk-js.git"
|
|
52
66
|
},
|
|
53
67
|
"sideEffects": false,
|
|
54
|
-
"version": "2.
|
|
68
|
+
"version": "2.10.0"
|
|
55
69
|
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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: true,
|
|
8
|
+
dts: true,
|
|
9
|
+
entry: ['src'],
|
|
10
|
+
format: ['cjs', 'esm'],
|
|
11
|
+
sourcemap: true,
|
|
12
|
+
splitting: false,
|
|
13
|
+
tsconfig: 'tsconfig.json',
|
|
14
|
+
})
|
package/dist/cjs/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertEx = void 0;
|
|
4
|
-
function assertEx(expr, messageOrFunc) {
|
|
5
|
-
if (expr)
|
|
6
|
-
return expr;
|
|
7
|
-
if (typeof messageOrFunc === 'function') {
|
|
8
|
-
const errorOrMessage = messageOrFunc(expr);
|
|
9
|
-
throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage;
|
|
10
|
-
}
|
|
11
|
-
// a string was sent
|
|
12
|
-
throw Error(messageOrFunc);
|
|
13
|
-
}
|
|
14
|
-
exports.assertEx = assertEx;
|
|
15
|
-
// eslint-disable-next-line import/no-default-export
|
|
16
|
-
exports.default = assertEx;
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAeA,SAAS,QAAQ,CAA0F,IAAe,EAAE,aAAiB;IAC3I,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;QACvC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;QAC1C,MAAM,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAA;KAClF;IACD,oBAAoB;IACpB,MAAM,KAAK,CAAC,aAAa,CAAC,CAAA;AAC5B,CAAC;AAKQ,4BAAQ;AAHjB,oDAAoD;AACpD,kBAAe,QAAQ,CAAA"}
|