@jblib/should 0.0.2 → 0.0.3
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/README.md +13 -0
- package/package.json +4 -4
- package/src/index.ts +3 -3
- package/src/should-be-false.ts +8 -0
- package/src/should-be-true.ts +8 -0
- package/src/should-never.spec.ts +9 -0
- package/src/should-never.ts +12 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -3
- package/dist/should-be-true.d.ts +0 -5
- package/dist/should-be-true.d.ts.map +0 -1
- package/dist/should-be-true.js +0 -8
- package/dist/should-be-true.js.map +0 -1
package/README.md
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jblib/should",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "should, assertions that throw errors when conditions aren't met",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"vitest": "^4.1.5",
|
|
8
|
-
"typescript": "^6.0.3",
|
|
9
7
|
"prettier": "^3.8.3",
|
|
10
8
|
"tsdown": "^0.21.10",
|
|
11
|
-
"
|
|
9
|
+
"typescript": "^6.0.3",
|
|
10
|
+
"vitest": "^4.1.5",
|
|
11
|
+
"@jblib/eslint": "0.0.3"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"should",
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
1
|
+
export { shouldBeFalse } from './should-be-false.js'
|
|
2
|
+
export { shouldBeTrue } from './should-be-true.js'
|
|
3
|
+
export { shouldNever } from './should-never.js'
|
package/src/should-be-false.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shouldBeFalse checks if the provided value is strictly false.
|
|
3
|
+
* If it is not, it throws an error.
|
|
4
|
+
*
|
|
5
|
+
* @param v value that should always be false
|
|
6
|
+
* @param message custom error message to throw if the value is not false
|
|
7
|
+
* @throws {Error} if the value is not false
|
|
8
|
+
*/
|
|
1
9
|
const shouldBeFalse = (v: unknown, message?: string): void => {
|
|
2
10
|
if (v !== false) {
|
|
3
11
|
throw new Error(message ?? `should be false, but got ${String(v)}`)
|
package/src/should-be-true.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shouldBeTrue checks if the provided value is strictly true.
|
|
3
|
+
* If it is not, it throws an error.
|
|
4
|
+
*
|
|
5
|
+
* @param v value that should always be true
|
|
6
|
+
* @param message custom error message to throw if the value is not true
|
|
7
|
+
* @throws {Error} if the value is not true
|
|
8
|
+
*/
|
|
1
9
|
const shouldBeTrue = (v: unknown, message?: string): void => {
|
|
2
10
|
if (v !== true) {
|
|
3
11
|
throw new Error(message ?? `should be true, but got ${String(v)}`)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shouldNever always throws an error when called.
|
|
3
|
+
* This is useful for failing in areas that should never be reached.
|
|
4
|
+
*
|
|
5
|
+
* @param message custom error message to throw if the value is called
|
|
6
|
+
* @throws {Error} if the value is called
|
|
7
|
+
*/
|
|
8
|
+
const shouldNever = (message?: string): never => {
|
|
9
|
+
throw new Error(message ?? 'should never be called')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { shouldNever }
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
package/dist/should-be-true.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"should-be-true.d.ts","names":[],"sources":["../src/should-be-true.ts"],"mappings":";cAAM,YAAA,GAAgB,CAAA,WAAY,OAAA"}
|
package/dist/should-be-true.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"should-be-true.js","names":[],"sources":["../src/should-be-true.ts"],"sourcesContent":["const 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":";AAAA,MAAM,gBAAgB,GAAY,YAA2B;AAC3D,KAAI,MAAM,KACR,OAAM,IAAI,MAAM,WAAW,2BAA2B,OAAO,EAAE,GAAG"}
|