@jblib/should 0.0.3 → 0.0.5
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.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/should-be-false.d.ts +13 -0
- package/dist/should-be-false.d.ts.map +1 -0
- package/dist/should-be-false.js +16 -0
- package/dist/should-be-false.js.map +1 -0
- package/dist/should-be-true.d.ts +13 -0
- package/dist/should-be-true.d.ts.map +1 -0
- package/dist/should-be-true.js +16 -0
- package/dist/should-be-true.js.map +1 -0
- package/dist/should-never.d.ts +12 -0
- package/dist/should-never.d.ts.map +1 -0
- package/dist/should-never.js +15 -0
- package/dist/should-never.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/should-be-false.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* shouldBeFalse checks if the provided value is strictly false.
|
|
4
|
+
* If it is not, it throws an error.
|
|
5
|
+
*
|
|
6
|
+
* @param v value that should always be false
|
|
7
|
+
* @param message custom error message to throw if the value is not false
|
|
8
|
+
* @throws {Error} if the value is not false
|
|
9
|
+
*/
|
|
10
|
+
declare const shouldBeFalse: (v: unknown, message?: string) => void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { shouldBeFalse };
|
|
13
|
+
//# sourceMappingURL=should-be-false.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-be-false.d.ts","names":[],"sources":["../src/should-be-false.ts"],"mappings":";;;;;;;;;cAQM,aAAA,GAAiB,CAAA,WAAY,OAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/should-be-false.ts
|
|
2
|
+
/**
|
|
3
|
+
* shouldBeFalse checks if the provided value is strictly false.
|
|
4
|
+
* If it is not, it throws an error.
|
|
5
|
+
*
|
|
6
|
+
* @param v value that should always be false
|
|
7
|
+
* @param message custom error message to throw if the value is not false
|
|
8
|
+
* @throws {Error} if the value is not false
|
|
9
|
+
*/
|
|
10
|
+
const shouldBeFalse = (v, message) => {
|
|
11
|
+
if (v !== false) throw new Error(message ?? `should be false, but got ${String(v)}`);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { shouldBeFalse };
|
|
16
|
+
//# sourceMappingURL=should-be-false.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-be-false.js","names":[],"sources":["../src/should-be-false.ts"],"sourcesContent":["/**\n * shouldBeFalse checks if the provided value is strictly false.\n * If it is not, it throws an error.\n *\n * @param v value that should always be false\n * @param message custom error message to throw if the value is not false\n * @throws {Error} if the value is not false\n */\nconst shouldBeFalse = (v: unknown, message?: string): void => {\n if (v !== false) {\n throw new Error(message ?? `should be false, but got ${String(v)}`)\n }\n}\n\nexport { shouldBeFalse }\n"],"mappings":";;;;;;;;;AAQA,MAAM,iBAAiB,GAAY,YAA2B;AAC5D,KAAI,MAAM,MACR,OAAM,IAAI,MAAM,WAAW,4BAA4B,OAAO,EAAE,GAAG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/should-be-true.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* shouldBeTrue checks if the provided value is strictly true.
|
|
4
|
+
* If it is not, it throws an error.
|
|
5
|
+
*
|
|
6
|
+
* @param v value that should always be true
|
|
7
|
+
* @param message custom error message to throw if the value is not true
|
|
8
|
+
* @throws {Error} if the value is not true
|
|
9
|
+
*/
|
|
10
|
+
declare const shouldBeTrue: (v: unknown, message?: string) => void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { shouldBeTrue };
|
|
13
|
+
//# sourceMappingURL=should-be-true.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-be-true.d.ts","names":[],"sources":["../src/should-be-true.ts"],"mappings":";;;;;;;;;cAQM,YAAA,GAAgB,CAAA,WAAY,OAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/should-be-true.ts
|
|
2
|
+
/**
|
|
3
|
+
* shouldBeTrue checks if the provided value is strictly true.
|
|
4
|
+
* If it is not, it throws an error.
|
|
5
|
+
*
|
|
6
|
+
* @param v value that should always be true
|
|
7
|
+
* @param message custom error message to throw if the value is not true
|
|
8
|
+
* @throws {Error} if the value is not true
|
|
9
|
+
*/
|
|
10
|
+
const shouldBeTrue = (v, message) => {
|
|
11
|
+
if (v !== true) throw new Error(message ?? `should be true, but got ${String(v)}`);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { shouldBeTrue };
|
|
16
|
+
//# sourceMappingURL=should-be-true.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-be-true.js","names":[],"sources":["../src/should-be-true.ts"],"sourcesContent":["/**\n * shouldBeTrue checks if the provided value is strictly true.\n * If it is not, it throws an error.\n *\n * @param v value that should always be true\n * @param message custom error message to throw if the value is not true\n * @throws {Error} if the value is not true\n */\nconst shouldBeTrue = (v: unknown, message?: string): void => {\n if (v !== true) {\n throw new Error(message ?? `should be true, but got ${String(v)}`)\n }\n}\n\nexport { shouldBeTrue }\n"],"mappings":";;;;;;;;;AAQA,MAAM,gBAAgB,GAAY,YAA2B;AAC3D,KAAI,MAAM,KACR,OAAM,IAAI,MAAM,WAAW,2BAA2B,OAAO,EAAE,GAAG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/should-never.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* shouldNever always throws an error when called.
|
|
4
|
+
* This is useful for failing in areas that should never be reached.
|
|
5
|
+
*
|
|
6
|
+
* @param message custom error message to throw if the value is called
|
|
7
|
+
* @throws {Error} if the value is called
|
|
8
|
+
*/
|
|
9
|
+
declare const shouldNever: (message?: string) => never;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { shouldNever };
|
|
12
|
+
//# sourceMappingURL=should-never.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-never.d.ts","names":[],"sources":["../src/should-never.ts"],"mappings":";;;;;;;;cAOM,WAAA,GAAe,OAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/should-never.ts
|
|
2
|
+
/**
|
|
3
|
+
* shouldNever always throws an error when called.
|
|
4
|
+
* This is useful for failing in areas that should never be reached.
|
|
5
|
+
*
|
|
6
|
+
* @param message custom error message to throw if the value is called
|
|
7
|
+
* @throws {Error} if the value is called
|
|
8
|
+
*/
|
|
9
|
+
const shouldNever = (message) => {
|
|
10
|
+
throw new Error(message ?? "should never be called");
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { shouldNever };
|
|
15
|
+
//# sourceMappingURL=should-never.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-never.js","names":[],"sources":["../src/should-never.ts"],"sourcesContent":["/**\n * shouldNever always throws an error when called.\n * This is useful for failing in areas that should never be reached.\n *\n * @param message custom error message to throw if the value is called\n * @throws {Error} if the value is called\n */\nconst shouldNever = (message?: string): never => {\n throw new Error(message ?? 'should never be called')\n}\n\nexport { shouldNever }\n"],"mappings":";;;;;;;;AAOA,MAAM,eAAe,YAA4B;AAC/C,OAAM,IAAI,MAAM,WAAW,yBAAyB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jblib/should",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "should, assertions that throw errors when conditions aren't met",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"tsdown": "^0.21.10",
|
|
9
9
|
"typescript": "^6.0.3",
|
|
10
10
|
"vitest": "^4.1.5",
|
|
11
|
-
"@jblib/eslint": "0.0.
|
|
11
|
+
"@jblib/eslint": "0.0.7"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"should",
|