@jblib/should 0.0.1 → 0.0.2
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/LICENSE +21 -0
- package/dist/should-be-true.d.ts +1 -1
- package/dist/should-be-true.d.ts.map +1 -1
- package/dist/should-be-true.js +3 -1
- package/dist/should-be-true.js.map +1 -1
- package/package.json +21 -22
- package/src/should-be-false.spec.ts +26 -0
- package/src/should-be-false.ts +7 -0
- package/src/should-be-true.spec.ts +15 -11
- package/src/should-be-true.ts +5 -1
- package/eslint.config.ts +0 -6
- package/tsconfig.json +0 -8
- package/tsdown.config.ts +0 -23
- package/vitest.config.ts +0 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joseph Beck
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/should-be-true.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-be-true.d.ts","names":[],"sources":["../src/should-be-true.ts"],"mappings":";cAAM,YAAA,GAAgB,CAAA"}
|
|
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-be-true.js","names":[],"sources":["../src/should-be-true.ts"],"sourcesContent":["const shouldBeTrue = (v: unknown):
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jblib/should",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "should",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "should, assertions that throw errors when conditions aren't met",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "tsdown",
|
|
8
|
-
"test": "vitest",
|
|
9
|
-
"lint": "eslint .",
|
|
10
|
-
"lint:fix": "eslint . --fix"
|
|
11
|
-
},
|
|
12
6
|
"devDependencies": {
|
|
13
|
-
"vitest": "
|
|
14
|
-
"typescript": "
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
7
|
+
"vitest": "^4.1.5",
|
|
8
|
+
"typescript": "^6.0.3",
|
|
9
|
+
"prettier": "^3.8.3",
|
|
10
|
+
"tsdown": "^0.21.10",
|
|
11
|
+
"@jblib/eslint": "0.0.1"
|
|
18
12
|
},
|
|
19
13
|
"keywords": [
|
|
20
|
-
"should"
|
|
14
|
+
"should",
|
|
15
|
+
"assert"
|
|
21
16
|
],
|
|
22
17
|
"author": {
|
|
23
18
|
"name": "Joseph Beck"
|
|
24
19
|
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src"
|
|
23
|
+
],
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
27
|
"url": "git+https://github.com/joseph-beck/jblib.git",
|
|
28
28
|
"directory": "packages/should"
|
|
29
29
|
},
|
|
30
30
|
"license": "MIT",
|
|
31
|
-
"packageManager": "pnpm@10.33.0",
|
|
32
31
|
"exports": {
|
|
33
|
-
".": "./
|
|
32
|
+
".": "./dist/index.js",
|
|
34
33
|
"./package.json": "./package.json"
|
|
35
34
|
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsdown",
|
|
37
|
+
"test": "vitest",
|
|
38
|
+
"lint": "eslint .",
|
|
39
|
+
"lint:fix": "eslint . --fix"
|
|
41
40
|
}
|
|
42
|
-
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { shouldBeFalse } from './should-be-false.js'
|
|
4
|
+
|
|
5
|
+
describe('should be false', () => {
|
|
6
|
+
it('should not throw for false', () => {
|
|
7
|
+
expect(() => shouldBeFalse(false)).not.toThrow()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('should throw for true', () => {
|
|
11
|
+
expect(() => shouldBeFalse(true)).toThrow('should be false, but got true')
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('should throw for non-false values', () => {
|
|
15
|
+
expect(() => shouldBeFalse(123)).toThrow('should be false, but got 123')
|
|
16
|
+
expect(() => shouldBeFalse('hello')).toThrow('should be false, but got hello')
|
|
17
|
+
expect(() => shouldBeFalse({})).toThrow('should be false, but got [object Object]')
|
|
18
|
+
expect(() => shouldBeFalse([])).toThrow('should be false, but got ')
|
|
19
|
+
expect(() => shouldBeFalse(null)).toThrow('should be false, but got null')
|
|
20
|
+
expect(() => shouldBeFalse(undefined)).toThrow('should be false, but got undefined')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should use custom message if provided', () => {
|
|
24
|
+
expect(() => shouldBeFalse(true, 'custom error message')).toThrow('custom error message')
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -3,20 +3,24 @@ import { describe, expect, it } from 'vitest'
|
|
|
3
3
|
import { shouldBeTrue } from './should-be-true.js'
|
|
4
4
|
|
|
5
5
|
describe('should be true', () => {
|
|
6
|
-
it('should
|
|
7
|
-
expect(shouldBeTrue(true)).
|
|
6
|
+
it('should not throw for true', () => {
|
|
7
|
+
expect(() => shouldBeTrue(true)).not.toThrow()
|
|
8
8
|
})
|
|
9
9
|
|
|
10
|
-
it('should
|
|
11
|
-
expect(shouldBeTrue(false)).
|
|
10
|
+
it('should throw for false', () => {
|
|
11
|
+
expect(() => shouldBeTrue(false)).toThrow('should be true, but got false')
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
it('should
|
|
15
|
-
expect(shouldBeTrue(123)).
|
|
16
|
-
expect(shouldBeTrue('hello')).
|
|
17
|
-
expect(shouldBeTrue({})).
|
|
18
|
-
expect(shouldBeTrue([])).
|
|
19
|
-
expect(shouldBeTrue(null)).
|
|
20
|
-
expect(shouldBeTrue(undefined)).
|
|
14
|
+
it('should throw for non-true values', () => {
|
|
15
|
+
expect(() => shouldBeTrue(123)).toThrow('should be true, but got 123')
|
|
16
|
+
expect(() => shouldBeTrue('hello')).toThrow('should be true, but got hello')
|
|
17
|
+
expect(() => shouldBeTrue({})).toThrow('should be true, but got [object Object]')
|
|
18
|
+
expect(() => shouldBeTrue([])).toThrow('should be true, but got ')
|
|
19
|
+
expect(() => shouldBeTrue(null)).toThrow('should be true, but got null')
|
|
20
|
+
expect(() => shouldBeTrue(undefined)).toThrow('should be true, but got undefined')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should use custom message if provided', () => {
|
|
24
|
+
expect(() => shouldBeTrue(false, 'custom error message')).toThrow('custom error message')
|
|
21
25
|
})
|
|
22
26
|
})
|
package/src/should-be-true.ts
CHANGED
package/eslint.config.ts
DELETED
package/tsconfig.json
DELETED
package/tsdown.config.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsdown'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ['./src/index.ts'],
|
|
5
|
-
format: ['esm'],
|
|
6
|
-
platform: 'node',
|
|
7
|
-
unbundle: true,
|
|
8
|
-
dts: true,
|
|
9
|
-
sourcemap: true,
|
|
10
|
-
clean: true,
|
|
11
|
-
minify: false,
|
|
12
|
-
fixedExtension: false,
|
|
13
|
-
exports: {
|
|
14
|
-
devExports: true,
|
|
15
|
-
},
|
|
16
|
-
publint: {
|
|
17
|
-
strict: true,
|
|
18
|
-
},
|
|
19
|
-
attw: {
|
|
20
|
-
profile: 'esm-only',
|
|
21
|
-
level: 'error',
|
|
22
|
-
},
|
|
23
|
-
})
|