@davidsouther/jiffies 2.2.5 → 2026.4.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/LICENSE +1 -1
- package/package.json +22 -25
- package/src/assert.ts +5 -5
- package/src/components/button_bar.ts +28 -30
- package/src/components/inline_edit.ts +8 -7
- package/src/components/logger.ts +6 -6
- package/src/components/select.ts +7 -7
- package/src/components/test.ts +5 -0
- package/src/components/virtual_scroll.test.ts +9 -6
- package/src/components/virtual_scroll.ts +29 -24
- package/src/context.test.ts +4 -4
- package/src/context.ts +16 -11
- package/src/debounce.ts +9 -3
- package/src/diff.test.ts +4 -4
- package/src/diff.ts +14 -16
- package/src/dom/css/border.ts +11 -11
- package/src/dom/css/core.ts +1 -1
- package/src/dom/css/fstyle.ts +4 -4
- package/src/dom/css/sizing.ts +1 -1
- package/src/dom/dom.ts +59 -47
- package/src/dom/fc.test.ts +8 -8
- package/src/dom/fc.ts +32 -35
- package/src/dom/form/form.app.ts +9 -9
- package/src/dom/form/form.ts +21 -15
- package/src/dom/form/index.html +3 -2
- package/src/dom/html.test.ts +12 -10
- package/src/dom/html.ts +2 -3
- package/src/dom/index.ts +2 -0
- package/src/dom/observable.test.ts +6 -6
- package/src/dom/observable.ts +2 -2
- package/src/dom/provide.ts +1 -1
- package/src/dom/router/link.ts +3 -3
- package/src/dom/router/router.ts +5 -5
- package/src/dom/svg.ts +7 -6
- package/src/dom/test.ts +3 -0
- package/src/dom/types/css.ts +43 -61
- package/src/dom/types/html.ts +2 -4
- package/src/dom/xml.ts +2 -2
- package/src/equal.test.ts +3 -3
- package/src/equal.ts +27 -14
- package/src/flags.test.ts +2 -2
- package/src/flags.ts +2 -2
- package/src/fs.test.ts +5 -5
- package/src/fs.ts +26 -20
- package/src/fs_node.ts +4 -4
- package/src/fs_win.test.ts +1 -1
- package/src/generator.test.ts +4 -3
- package/src/generator.ts +1 -1
- package/src/hooks/_notes +4 -1
- package/src/index.html +7 -7
- package/src/lock.test.ts +4 -4
- package/src/lock.ts +8 -7
- package/src/log.ts +17 -18
- package/src/observable/event.ts +7 -7
- package/src/observable/observable.test.ts +3 -3
- package/src/observable/observable.ts +73 -52
- package/src/result.test.ts +7 -10
- package/src/result.ts +51 -47
- package/src/safe.ts +1 -1
- package/src/scope/describe.ts +12 -11
- package/src/scope/display/console.ts +4 -4
- package/src/scope/display/dom.ts +9 -9
- package/src/scope/display/junit.ts +21 -24
- package/src/scope/execute.ts +17 -12
- package/src/scope/expect.ts +22 -22
- package/src/scope/fix.ts +8 -7
- package/src/scope/index.ts +3 -3
- package/src/scope/scope.ts +2 -2
- package/src/scope/state.ts +2 -2
- package/src/server/http/apps.ts +5 -5
- package/src/server/http/css.ts +10 -26
- package/src/server/http/index.ts +30 -24
- package/src/server/http/response.ts +12 -5
- package/src/server/http/sitemap.ts +8 -8
- package/src/server/http/static.ts +9 -6
- package/src/server/http/typescript.ts +25 -25
- package/src/server/main.ts +7 -4
- package/src/test.mjs +8 -8
- package/src/test_all.ts +16 -13
- package/src/transpile.mjs +5 -18
- package/tsconfig.json +34 -0
- package/build/pico.css +0 -2466
- package/build/pico.css.map +0 -1
- package/lib/cjs/assert.d.ts +0 -26
- package/lib/cjs/assert.js +0 -46
- package/lib/cjs/awaitable.d.ts +0 -1
- package/lib/cjs/awaitable.js +0 -2
- package/lib/cjs/case.d.ts +0 -1
- package/lib/cjs/case.js +0 -9
- package/lib/cjs/components/button_bar.d.ts +0 -8
- package/lib/cjs/components/button_bar.js +0 -29
- package/lib/cjs/components/inline_edit.d.ts +0 -12
- package/lib/cjs/components/inline_edit.js +0 -51
- package/lib/cjs/components/logger.d.ts +0 -6
- package/lib/cjs/components/logger.js +0 -27
- package/lib/cjs/components/select.d.ts +0 -13
- package/lib/cjs/components/select.js +0 -6
- package/lib/cjs/components/test.d.ts +0 -1
- package/lib/cjs/components/test.js +0 -7
- package/lib/cjs/components/virtual_scroll.d.ts +0 -40
- package/lib/cjs/components/virtual_scroll.js +0 -102
- package/lib/cjs/components/virtual_scroll.test.d.ts +0 -1
- package/lib/cjs/components/virtual_scroll.test.js +0 -22
- package/lib/cjs/context.d.ts +0 -15
- package/lib/cjs/context.js +0 -48
- package/lib/cjs/context.test.d.ts +0 -1
- package/lib/cjs/context.test.js +0 -48
- package/lib/cjs/debounce.d.ts +0 -1
- package/lib/cjs/debounce.js +0 -12
- package/lib/cjs/diff.d.ts +0 -15
- package/lib/cjs/diff.js +0 -58
- package/lib/cjs/diff.test.d.ts +0 -1
- package/lib/cjs/diff.test.js +0 -41
- package/lib/cjs/display.d.ts +0 -5
- package/lib/cjs/display.js +0 -16
- package/lib/cjs/dom/css/border.d.ts +0 -11
- package/lib/cjs/dom/css/border.js +0 -33
- package/lib/cjs/dom/css/constants.d.ts +0 -31
- package/lib/cjs/dom/css/constants.js +0 -31
- package/lib/cjs/dom/css/core.d.ts +0 -5
- package/lib/cjs/dom/css/core.js +0 -31
- package/lib/cjs/dom/css/fstyle.d.ts +0 -5
- package/lib/cjs/dom/css/fstyle.js +0 -36
- package/lib/cjs/dom/css/sizing.d.ts +0 -5
- package/lib/cjs/dom/css/sizing.js +0 -14
- package/lib/cjs/dom/dom.d.ts +0 -27
- package/lib/cjs/dom/dom.js +0 -110
- package/lib/cjs/dom/fc.d.ts +0 -14
- package/lib/cjs/dom/fc.js +0 -39
- package/lib/cjs/dom/fc.test.d.ts +0 -1
- package/lib/cjs/dom/fc.test.js +0 -23
- package/lib/cjs/dom/form/form.app.d.ts +0 -1
- package/lib/cjs/dom/form/form.app.js +0 -27
- package/lib/cjs/dom/form/form.d.ts +0 -26
- package/lib/cjs/dom/form/form.js +0 -49
- package/lib/cjs/dom/form/form.test.d.ts +0 -0
- package/lib/cjs/dom/form/form.test.js +0 -1
- package/lib/cjs/dom/html.d.ts +0 -113
- package/lib/cjs/dom/html.js +0 -119
- package/lib/cjs/dom/html.test.d.ts +0 -1
- package/lib/cjs/dom/html.test.js +0 -60
- package/lib/cjs/dom/observable.d.ts +0 -2
- package/lib/cjs/dom/observable.js +0 -10
- package/lib/cjs/dom/observable.test.d.ts +0 -1
- package/lib/cjs/dom/observable.test.js +0 -35
- package/lib/cjs/dom/provide.d.ts +0 -3
- package/lib/cjs/dom/provide.js +0 -12
- package/lib/cjs/dom/router/link.d.ts +0 -6
- package/lib/cjs/dom/router/link.js +0 -7
- package/lib/cjs/dom/router/router.d.ts +0 -13
- package/lib/cjs/dom/router/router.js +0 -55
- package/lib/cjs/dom/svg.d.ts +0 -64
- package/lib/cjs/dom/svg.js +0 -69
- package/lib/cjs/dom/test.d.ts +0 -1
- package/lib/cjs/dom/test.js +0 -13
- package/lib/cjs/dom/types/css.d.ts +0 -6612
- package/lib/cjs/dom/types/css.js +0 -24
- package/lib/cjs/dom/types/dom.d.ts +0 -0
- package/lib/cjs/dom/types/dom.js +0 -1
- package/lib/cjs/dom/types/html.d.ts +0 -616
- package/lib/cjs/dom/types/html.js +0 -2
- package/lib/cjs/dom/xml.d.ts +0 -1
- package/lib/cjs/dom/xml.js +0 -8
- package/lib/cjs/equal.d.ts +0 -8
- package/lib/cjs/equal.js +0 -48
- package/lib/cjs/equal.test.d.ts +0 -1
- package/lib/cjs/equal.test.js +0 -22
- package/lib/cjs/flags.d.ts +0 -7
- package/lib/cjs/flags.js +0 -52
- package/lib/cjs/flags.test.d.ts +0 -1
- package/lib/cjs/flags.test.js +0 -37
- package/lib/cjs/fs.d.ts +0 -72
- package/lib/cjs/fs.js +0 -235
- package/lib/cjs/fs.test.d.ts +0 -1
- package/lib/cjs/fs.test.js +0 -86
- package/lib/cjs/fs_node.d.ts +0 -15
- package/lib/cjs/fs_node.js +0 -50
- package/lib/cjs/fs_win.test.d.ts +0 -1
- package/lib/cjs/fs_win.test.js +0 -10
- package/lib/cjs/generator.d.ts +0 -1
- package/lib/cjs/generator.js +0 -14
- package/lib/cjs/generator.test.d.ts +0 -1
- package/lib/cjs/generator.test.js +0 -26
- package/lib/cjs/is_browser.d.ts +0 -1
- package/lib/cjs/is_browser.js +0 -4
- package/lib/cjs/loader-register.d.mts +0 -1
- package/lib/cjs/loader-register.d.ts +0 -1
- package/lib/cjs/loader-register.js +0 -4
- package/lib/cjs/loader-register.mjs +0 -4
- package/lib/cjs/loader.d.mts +0 -23
- package/lib/cjs/loader.mjs +0 -41
- package/lib/cjs/lock.d.ts +0 -1
- package/lib/cjs/lock.js +0 -27
- package/lib/cjs/lock.test.d.ts +0 -1
- package/lib/cjs/lock.test.js +0 -18
- package/lib/cjs/log.d.ts +0 -56
- package/lib/cjs/log.js +0 -103
- package/lib/cjs/observable/event.d.ts +0 -35
- package/lib/cjs/observable/event.js +0 -61
- package/lib/cjs/observable/observable.d.ts +0 -132
- package/lib/cjs/observable/observable.js +0 -363
- package/lib/cjs/observable/observable.test.d.ts +0 -1
- package/lib/cjs/observable/observable.test.js +0 -65
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/range.d.ts +0 -1
- package/lib/cjs/range.js +0 -11
- package/lib/cjs/result.d.ts +0 -31
- package/lib/cjs/result.js +0 -80
- package/lib/cjs/result.test.d.ts +0 -1
- package/lib/cjs/result.test.js +0 -78
- package/lib/cjs/safe.d.ts +0 -1
- package/lib/cjs/safe.js +0 -14
- package/lib/cjs/scope/describe.d.ts +0 -18
- package/lib/cjs/scope/describe.js +0 -73
- package/lib/cjs/scope/display/console.d.ts +0 -2
- package/lib/cjs/scope/display/console.js +0 -25
- package/lib/cjs/scope/display/dom.d.ts +0 -3
- package/lib/cjs/scope/display/dom.js +0 -30
- package/lib/cjs/scope/display/junit.d.ts +0 -2
- package/lib/cjs/scope/display/junit.js +0 -21
- package/lib/cjs/scope/execute.d.ts +0 -12
- package/lib/cjs/scope/execute.js +0 -91
- package/lib/cjs/scope/expect.d.ts +0 -23
- package/lib/cjs/scope/expect.js +0 -110
- package/lib/cjs/scope/fix.d.ts +0 -4
- package/lib/cjs/scope/fix.js +0 -26
- package/lib/cjs/scope/index.d.ts +0 -3
- package/lib/cjs/scope/index.js +0 -15
- package/lib/cjs/scope/scope.d.ts +0 -17
- package/lib/cjs/scope/scope.js +0 -2
- package/lib/cjs/scope/state.d.ts +0 -2
- package/lib/cjs/scope/state.js +0 -12
- package/lib/cjs/server/http/apps.d.ts +0 -5
- package/lib/cjs/server/http/apps.js +0 -27
- package/lib/cjs/server/http/css.d.ts +0 -5
- package/lib/cjs/server/http/css.js +0 -54
- package/lib/cjs/server/http/index.d.ts +0 -21
- package/lib/cjs/server/http/index.js +0 -77
- package/lib/cjs/server/http/response.d.ts +0 -4
- package/lib/cjs/server/http/response.js +0 -45
- package/lib/cjs/server/http/sitemap.d.ts +0 -2
- package/lib/cjs/server/http/sitemap.js +0 -46
- package/lib/cjs/server/http/static.d.ts +0 -2
- package/lib/cjs/server/http/static.js +0 -25
- package/lib/cjs/server/http/typescript.d.ts +0 -5
- package/lib/cjs/server/http/typescript.js +0 -44
- package/lib/cjs/server/main.d.ts +0 -2
- package/lib/cjs/server/main.js +0 -14
- package/lib/cjs/test.d.mts +0 -2
- package/lib/cjs/test.mjs +0 -28
- package/lib/cjs/test_all.d.ts +0 -9
- package/lib/cjs/test_all.js +0 -30
- package/lib/cjs/transpile.d.mts +0 -3
- package/lib/cjs/transpile.mjs +0 -22
- package/lib/cjs/tsconfig.tsbuildinfo +0 -1
- package/lib/esm/assert.d.ts +0 -26
- package/lib/esm/assert.js +0 -38
- package/lib/esm/awaitable.d.ts +0 -1
- package/lib/esm/awaitable.js +0 -1
- package/lib/esm/case.d.ts +0 -1
- package/lib/esm/case.js +0 -5
- package/lib/esm/components/button_bar.d.ts +0 -8
- package/lib/esm/components/button_bar.js +0 -27
- package/lib/esm/components/inline_edit.d.ts +0 -12
- package/lib/esm/components/inline_edit.js +0 -48
- package/lib/esm/components/logger.d.ts +0 -6
- package/lib/esm/components/logger.js +0 -22
- package/lib/esm/components/select.d.ts +0 -10
- package/lib/esm/components/select.js +0 -3
- package/lib/esm/components/test.d.ts +0 -1
- package/lib/esm/components/test.js +0 -3
- package/lib/esm/components/virtual_scroll.d.ts +0 -40
- package/lib/esm/components/virtual_scroll.js +0 -94
- package/lib/esm/components/virtual_scroll.test.d.ts +0 -1
- package/lib/esm/components/virtual_scroll.test.js +0 -20
- package/lib/esm/context.d.ts +0 -15
- package/lib/esm/context.js +0 -43
- package/lib/esm/context.test.d.ts +0 -1
- package/lib/esm/context.test.js +0 -46
- package/lib/esm/debounce.d.ts +0 -2
- package/lib/esm/debounce.js +0 -8
- package/lib/esm/diff.d.ts +0 -15
- package/lib/esm/diff.js +0 -54
- package/lib/esm/diff.test.d.ts +0 -1
- package/lib/esm/diff.test.js +0 -39
- package/lib/esm/display.d.ts +0 -5
- package/lib/esm/display.js +0 -11
- package/lib/esm/dom/css/border.d.ts +0 -11
- package/lib/esm/dom/css/border.js +0 -27
- package/lib/esm/dom/css/constants.d.ts +0 -31
- package/lib/esm/dom/css/constants.js +0 -28
- package/lib/esm/dom/css/core.d.ts +0 -5
- package/lib/esm/dom/css/core.js +0 -24
- package/lib/esm/dom/css/fstyle.d.ts +0 -5
- package/lib/esm/dom/css/fstyle.js +0 -32
- package/lib/esm/dom/css/sizing.d.ts +0 -5
- package/lib/esm/dom/css/sizing.js +0 -10
- package/lib/esm/dom/dom.d.ts +0 -27
- package/lib/esm/dom/dom.js +0 -104
- package/lib/esm/dom/fc.d.ts +0 -14
- package/lib/esm/dom/fc.js +0 -35
- package/lib/esm/dom/fc.test.d.ts +0 -1
- package/lib/esm/dom/fc.test.js +0 -21
- package/lib/esm/dom/form/form.app.d.ts +0 -1
- package/lib/esm/dom/form/form.app.js +0 -23
- package/lib/esm/dom/form/form.d.ts +0 -26
- package/lib/esm/dom/form/form.js +0 -34
- package/lib/esm/dom/form/form.test.d.ts +0 -0
- package/lib/esm/dom/form/form.test.js +0 -1
- package/lib/esm/dom/html.d.ts +0 -113
- package/lib/esm/dom/html.js +0 -114
- package/lib/esm/dom/html.test.d.ts +0 -1
- package/lib/esm/dom/html.test.js +0 -58
- package/lib/esm/dom/observable.d.ts +0 -2
- package/lib/esm/dom/observable.js +0 -6
- package/lib/esm/dom/observable.test.d.ts +0 -1
- package/lib/esm/dom/observable.test.js +0 -33
- package/lib/esm/dom/provide.d.ts +0 -3
- package/lib/esm/dom/provide.js +0 -7
- package/lib/esm/dom/router/link.d.ts +0 -6
- package/lib/esm/dom/router/link.js +0 -3
- package/lib/esm/dom/router/router.d.ts +0 -13
- package/lib/esm/dom/router/router.js +0 -52
- package/lib/esm/dom/svg.d.ts +0 -64
- package/lib/esm/dom/svg.js +0 -65
- package/lib/esm/dom/test.d.ts +0 -1
- package/lib/esm/dom/test.js +0 -9
- package/lib/esm/dom/types/css.d.ts +0 -6612
- package/lib/esm/dom/types/css.js +0 -23
- package/lib/esm/dom/types/dom.d.ts +0 -0
- package/lib/esm/dom/types/dom.js +0 -1
- package/lib/esm/dom/types/html.d.ts +0 -616
- package/lib/esm/dom/types/html.js +0 -1
- package/lib/esm/dom/xml.d.ts +0 -1
- package/lib/esm/dom/xml.js +0 -4
- package/lib/esm/equal.d.ts +0 -8
- package/lib/esm/equal.js +0 -41
- package/lib/esm/equal.test.d.ts +0 -1
- package/lib/esm/equal.test.js +0 -20
- package/lib/esm/flags.d.ts +0 -7
- package/lib/esm/flags.js +0 -48
- package/lib/esm/flags.test.d.ts +0 -1
- package/lib/esm/flags.test.js +0 -35
- package/lib/esm/fs.d.ts +0 -72
- package/lib/esm/fs.js +0 -226
- package/lib/esm/fs.test.d.ts +0 -1
- package/lib/esm/fs.test.js +0 -84
- package/lib/esm/fs_node.d.ts +0 -15
- package/lib/esm/fs_node.js +0 -45
- package/lib/esm/fs_win.test.d.ts +0 -1
- package/lib/esm/fs_win.test.js +0 -8
- package/lib/esm/generator.d.ts +0 -1
- package/lib/esm/generator.js +0 -10
- package/lib/esm/generator.test.d.ts +0 -1
- package/lib/esm/generator.test.js +0 -24
- package/lib/esm/is_browser.d.ts +0 -1
- package/lib/esm/is_browser.js +0 -1
- package/lib/esm/loader-register.d.mts +0 -1
- package/lib/esm/loader-register.mjs +0 -2
- package/lib/esm/loader.d.mts +0 -23
- package/lib/esm/loader.mjs +0 -36
- package/lib/esm/lock.d.ts +0 -1
- package/lib/esm/lock.js +0 -23
- package/lib/esm/lock.test.d.ts +0 -1
- package/lib/esm/lock.test.js +0 -16
- package/lib/esm/log.d.ts +0 -56
- package/lib/esm/log.js +0 -93
- package/lib/esm/observable/event.d.ts +0 -35
- package/lib/esm/observable/event.js +0 -46
- package/lib/esm/observable/observable.d.ts +0 -132
- package/lib/esm/observable/observable.js +0 -343
- package/lib/esm/observable/observable.test.d.ts +0 -1
- package/lib/esm/observable/observable.test.js +0 -63
- package/lib/esm/range.d.ts +0 -1
- package/lib/esm/range.js +0 -7
- package/lib/esm/result.d.ts +0 -31
- package/lib/esm/result.js +0 -65
- package/lib/esm/result.test.d.ts +0 -1
- package/lib/esm/result.test.js +0 -76
- package/lib/esm/safe.d.ts +0 -1
- package/lib/esm/safe.js +0 -10
- package/lib/esm/scope/describe.d.ts +0 -18
- package/lib/esm/scope/describe.js +0 -60
- package/lib/esm/scope/display/console.d.ts +0 -2
- package/lib/esm/scope/display/console.js +0 -21
- package/lib/esm/scope/display/dom.d.ts +0 -3
- package/lib/esm/scope/display/dom.js +0 -26
- package/lib/esm/scope/display/junit.d.ts +0 -2
- package/lib/esm/scope/display/junit.js +0 -17
- package/lib/esm/scope/execute.d.ts +0 -12
- package/lib/esm/scope/execute.js +0 -85
- package/lib/esm/scope/expect.d.ts +0 -23
- package/lib/esm/scope/expect.js +0 -104
- package/lib/esm/scope/fix.d.ts +0 -4
- package/lib/esm/scope/fix.js +0 -22
- package/lib/esm/scope/index.d.ts +0 -3
- package/lib/esm/scope/index.js +0 -3
- package/lib/esm/scope/scope.d.ts +0 -17
- package/lib/esm/scope/scope.js +0 -1
- package/lib/esm/scope/state.d.ts +0 -2
- package/lib/esm/scope/state.js +0 -8
- package/lib/esm/server/http/apps.d.ts +0 -5
- package/lib/esm/server/http/apps.js +0 -23
- package/lib/esm/server/http/css.d.ts +0 -5
- package/lib/esm/server/http/css.js +0 -50
- package/lib/esm/server/http/index.d.ts +0 -21
- package/lib/esm/server/http/index.js +0 -73
- package/lib/esm/server/http/response.d.ts +0 -4
- package/lib/esm/server/http/response.js +0 -40
- package/lib/esm/server/http/sitemap.d.ts +0 -2
- package/lib/esm/server/http/sitemap.js +0 -42
- package/lib/esm/server/http/static.d.ts +0 -2
- package/lib/esm/server/http/static.js +0 -21
- package/lib/esm/server/http/typescript.d.ts +0 -5
- package/lib/esm/server/http/typescript.js +0 -40
- package/lib/esm/server/main.d.ts +0 -2
- package/lib/esm/server/main.js +0 -12
- package/lib/esm/test.d.mts +0 -2
- package/lib/esm/test.mjs +0 -26
- package/lib/esm/test_all.d.ts +0 -9
- package/lib/esm/test_all.js +0 -28
- package/lib/esm/transpile.d.mts +0 -3
- package/lib/esm/transpile.mjs +0 -18
- package/lib/esm/tsconfig.tsbuildinfo +0 -1
- package/src/components/test.js +0 -3
- package/src/loader-register.mjs +0 -3
- package/src/loader.mjs +0 -46
package/src/result.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export type None = null;
|
|
2
|
-
export type Some<T> = T;
|
|
3
|
-
export type Option<T> = Some<T> | None;
|
|
4
|
-
export type Err<E = Error> = {
|
|
5
|
-
err: E;
|
|
6
|
-
map: <U>(fn: (t: unknown) => Result<U>) => Result<U>;
|
|
7
|
-
};
|
|
8
|
-
export type Ok<T> = { ok: T; map: <U>(fn: (t: T) => Result<U>) => Result<U> };
|
|
9
|
-
export type Result<T, E = Error> = Ok<T> | Err<E>;
|
|
10
|
-
|
|
11
1
|
export const isNone = <T>(s: Option<T>): s is None => s === null;
|
|
12
2
|
export const isSome = <T>(s: Option<T>): s is Some<T> => s != null;
|
|
13
3
|
|
|
@@ -17,87 +7,101 @@ export function None<T = unknown>(_?: T): Option<T> {
|
|
|
17
7
|
|
|
18
8
|
export function Some<T>(t: Option<T>): Option<T>;
|
|
19
9
|
export function Some<T>(t: T): Option<T>;
|
|
20
|
-
export function Some(t:
|
|
10
|
+
export function Some<T>(t: Option<T> | T): Option<T> {
|
|
21
11
|
return t;
|
|
22
12
|
}
|
|
23
13
|
|
|
24
14
|
export const isOk = <T, E>(t: Result<T, E>): t is Ok<T> =>
|
|
25
|
-
Object.
|
|
15
|
+
t && Object.hasOwn(t, "ok");
|
|
26
16
|
export const isErr = <T, E>(e: Result<T, E>): e is Err<E> =>
|
|
27
|
-
Object.
|
|
17
|
+
e && Object.hasOwn(e, "err");
|
|
28
18
|
export const isResult = <T, E>(t: Result<T, E>): t is Result<T, E> =>
|
|
29
19
|
isOk(t) || isErr(t);
|
|
30
20
|
|
|
31
21
|
// Beware: Order matters for correct inference.
|
|
32
|
-
export function Ok<T>(ok: Ok<T>): T;
|
|
33
|
-
export function Ok<T>(t?: T): Ok<T>;
|
|
34
|
-
export function Ok<T, E>(t:
|
|
35
|
-
return isOk(t)
|
|
36
|
-
? t.ok
|
|
37
|
-
: {
|
|
22
|
+
export function Ok<T, _E = unknown>(ok: Ok<T>): T;
|
|
23
|
+
export function Ok<T, _E = unknown>(t?: T): Ok<T>;
|
|
24
|
+
export function Ok<T, E = unknown>(t: T | Ok<T>): T | Ok<T> {
|
|
25
|
+
return isOk(t as Ok<T>)
|
|
26
|
+
? (t as Ok<T>).ok
|
|
27
|
+
: ({
|
|
38
28
|
ok: t,
|
|
39
29
|
map<U>(fn: (_: typeof t) => Result<U, E>): Result<U, E> {
|
|
40
30
|
return fn(Ok(this));
|
|
41
31
|
},
|
|
42
|
-
};
|
|
32
|
+
} as Ok<T>);
|
|
43
33
|
}
|
|
44
34
|
|
|
45
35
|
// Beware: Order matters for correct inference.
|
|
46
|
-
export function Err<E>(e: Err<E>): E;
|
|
47
|
-
export function Err<E>(e: E): Err<E>;
|
|
48
|
-
export function Err<E>(e: string): Err<E>;
|
|
49
|
-
export function Err<T, E>(e:
|
|
36
|
+
export function Err<_T, E>(e: Err<E>): E;
|
|
37
|
+
export function Err<_T, E>(e: E): Err<E>;
|
|
38
|
+
export function Err<_T, E>(e: string): Err<E>;
|
|
39
|
+
export function Err<T, E>(e: E | string | Err<E>): E | Err<E> {
|
|
50
40
|
return (
|
|
51
|
-
e.err ??
|
|
41
|
+
((e as Err<E>).err as E) ??
|
|
42
|
+
({
|
|
52
43
|
err: e,
|
|
53
44
|
map<U>(this: Result<T, E>, _fn: (t: unknown) => Result<U>): Result<U, E> {
|
|
54
45
|
return this as Result<U, E>;
|
|
55
46
|
},
|
|
56
|
-
}
|
|
47
|
+
} as Err<E>)
|
|
57
48
|
);
|
|
58
49
|
}
|
|
59
50
|
|
|
60
51
|
export function unwrap<T, E>(result: Result<T, E>): T | never;
|
|
61
52
|
export function unwrap<O>(some: Option<O>): O | never;
|
|
62
|
-
export function unwrap(t:
|
|
63
|
-
if (isNone(t)) {
|
|
64
|
-
throw new Error(
|
|
53
|
+
export function unwrap<T, E>(t: Result<T, E> | Option<T> | T): T | never {
|
|
54
|
+
if (isNone(t as Option<T>)) {
|
|
55
|
+
throw new Error("Attempted to unwrap None");
|
|
65
56
|
}
|
|
66
|
-
if (isErr(t)) {
|
|
57
|
+
if (isErr(t as Result<T, E>)) {
|
|
67
58
|
throw Err(t);
|
|
68
59
|
}
|
|
69
|
-
if (isOk(t)) {
|
|
70
|
-
return Ok(t);
|
|
60
|
+
if (isOk(t as Result<T, E>)) {
|
|
61
|
+
return Ok(t as Ok<T>);
|
|
71
62
|
}
|
|
72
|
-
return t;
|
|
63
|
+
return t as T;
|
|
73
64
|
}
|
|
74
65
|
|
|
75
66
|
export function unwrapOr<T, E>(result: Result<T, E>, def: T): T;
|
|
76
67
|
export function unwrapOr<T>(some: Some<T>, def: T): T;
|
|
77
|
-
export function unwrapOr(t:
|
|
78
|
-
if (isNone(t)) {
|
|
68
|
+
export function unwrapOr<T, E>(t: Some<T> | Result<T, E>, def: T): T {
|
|
69
|
+
if (isNone(t as Some<T>)) {
|
|
79
70
|
return def;
|
|
80
71
|
}
|
|
81
|
-
if (isErr(t)) {
|
|
72
|
+
if (isErr(t as Result<T, E>)) {
|
|
82
73
|
return def;
|
|
83
74
|
}
|
|
84
|
-
if (isOk(t)) {
|
|
85
|
-
return Ok(t);
|
|
75
|
+
if (isOk(t as Result<T, E>)) {
|
|
76
|
+
return Ok(t as Ok<T>);
|
|
86
77
|
}
|
|
87
|
-
return t;
|
|
78
|
+
return t as T;
|
|
88
79
|
}
|
|
89
80
|
|
|
90
|
-
export function unwrapOrElse<T, E>(result: Result<T,
|
|
91
|
-
export function unwrapOrElse<T>(some: Some<T>, def: () => T): T;
|
|
92
|
-
export function unwrapOrElse(t:
|
|
93
|
-
if (isNone(t)) {
|
|
81
|
+
export function unwrapOrElse<T, E>(result: Result<T, E>, def: () => T): T;
|
|
82
|
+
export function unwrapOrElse<T, _E>(some: Some<T>, def: () => T): T;
|
|
83
|
+
export function unwrapOrElse<T, E>(t: Result<T, E> | Some<T>, def: () => T): T {
|
|
84
|
+
if (isNone(t as Some<T>)) {
|
|
94
85
|
return def();
|
|
95
86
|
}
|
|
96
|
-
if (isErr(t)) {
|
|
87
|
+
if (isErr(t as Err<T>)) {
|
|
97
88
|
return def();
|
|
98
89
|
}
|
|
99
|
-
if (isOk(t)) {
|
|
100
|
-
return Ok(t);
|
|
90
|
+
if (isOk(t as Ok<T>)) {
|
|
91
|
+
return Ok(t as Ok<T>);
|
|
101
92
|
}
|
|
102
|
-
return t;
|
|
93
|
+
return t as T;
|
|
103
94
|
}
|
|
95
|
+
|
|
96
|
+
export type None = null;
|
|
97
|
+
// biome-ignore lint/suspicious/noRedeclare: This file does trickery with const and type.
|
|
98
|
+
export type Some<T> = T;
|
|
99
|
+
export type Option<T> = Some<T> | None;
|
|
100
|
+
// biome-ignore lint/suspicious/noRedeclare: This file does trickery with const and type.
|
|
101
|
+
export type Err<E = Error> = {
|
|
102
|
+
err: E;
|
|
103
|
+
map: <U>(fn: (t: unknown) => Result<U>) => Result<U>;
|
|
104
|
+
};
|
|
105
|
+
// biome-ignore lint/suspicious/noRedeclare: This file does trickery with const and type.
|
|
106
|
+
export type Ok<T> = { ok: T; map: <U>(fn: (t: T) => Result<U>) => Result<U> };
|
|
107
|
+
export type Result<T, E = Error> = Ok<T> | Err<E>;
|
package/src/safe.ts
CHANGED
package/src/scope/describe.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { assert } from "../assert.
|
|
2
|
-
import { getLogger } from "../log.
|
|
3
|
-
import { TestCase } from "./scope.
|
|
4
|
-
import * as state from "./state.
|
|
1
|
+
import { assert } from "../assert.ts";
|
|
2
|
+
import { getLogger } from "../log.ts";
|
|
3
|
+
import type { TestCase } from "./scope.ts";
|
|
4
|
+
import * as state from "./state.ts";
|
|
5
5
|
|
|
6
6
|
export const beforeall = Symbol("beforeAll");
|
|
7
7
|
export const beforeeach = Symbol("beforeEach");
|
|
@@ -11,12 +11,13 @@ export const aftereach = Symbol("afterEach");
|
|
|
11
11
|
const logger = getLogger("scope");
|
|
12
12
|
|
|
13
13
|
const CASES: TestCase = {};
|
|
14
|
-
|
|
14
|
+
const cases = [CASES];
|
|
15
15
|
let totalCases = 0;
|
|
16
16
|
let skippedCases = 0;
|
|
17
17
|
|
|
18
18
|
function push(title: string) {
|
|
19
|
-
|
|
19
|
+
cases[0][title] = cases[0][title] ?? {};
|
|
20
|
+
const next = cases[0][title] as TestCase;
|
|
20
21
|
cases.unshift(next);
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -36,21 +37,21 @@ export function getSkippedCases() {
|
|
|
36
37
|
return skippedCases;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
export function describe(title: string, block:
|
|
40
|
+
export function describe(title: string, block: CallableFunction) {
|
|
40
41
|
logger.debug(`describe(${title})`);
|
|
41
42
|
push(title);
|
|
42
43
|
block();
|
|
43
44
|
pop();
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export function it(title: string, block:
|
|
47
|
+
export function it(title: string, block: CallableFunction) {
|
|
47
48
|
logger.debug(`it(${title})`);
|
|
48
|
-
assert(cases[0][title]
|
|
49
|
+
assert(cases[0][title] === undefined, `Block already has test ${title}`);
|
|
49
50
|
totalCases += 1;
|
|
50
51
|
cases[0][title] = block;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
it.skip = (title: string, _block:
|
|
54
|
+
it.skip = (title: string, _block: CallableFunction) => {
|
|
54
55
|
logger.debug(`it.skip(${title})`);
|
|
55
56
|
totalCases += 1;
|
|
56
57
|
skippedCases += 1;
|
|
@@ -74,7 +75,7 @@ export function afterAll(fn: () => void) {
|
|
|
74
75
|
|
|
75
76
|
export function cleanState<State extends {}>(
|
|
76
77
|
init: () => State,
|
|
77
|
-
runner: (action: () => void) => void = beforeEach
|
|
78
|
+
runner: (action: () => void) => void = beforeEach,
|
|
78
79
|
): State {
|
|
79
80
|
return state.cleanState(init, runner);
|
|
80
81
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getLogger } from "../../log.
|
|
2
|
-
import { getTotalCases } from "../describe.
|
|
3
|
-
import { flattenResults } from "../execute.
|
|
4
|
-
import { TestResult } from "../scope.
|
|
1
|
+
import { getLogger } from "../../log.ts";
|
|
2
|
+
import { getTotalCases } from "../describe.ts";
|
|
3
|
+
import { flattenResults } from "../execute.ts";
|
|
4
|
+
import type { TestResult } from "../scope.ts";
|
|
5
5
|
|
|
6
6
|
const logger = getLogger("Scope Test Runner");
|
|
7
7
|
|
package/src/scope/display/dom.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { isHTMLLogger, makeHTMLLogger } from "../../components/logger.
|
|
2
|
-
import { DOMElement } from "../../dom/dom.
|
|
3
|
-
import { DEFAULT_LOGGER, LEVEL } from "../../log.
|
|
4
|
-
import { getTotalCases } from "../describe.
|
|
5
|
-
import { flattenResults } from "../execute.
|
|
6
|
-
import { TestResult } from "../scope.
|
|
1
|
+
import { isHTMLLogger, makeHTMLLogger } from "../../components/logger.ts";
|
|
2
|
+
import type { DOMElement } from "../../dom/dom.ts";
|
|
3
|
+
import { DEFAULT_LOGGER, LEVEL } from "../../log.ts";
|
|
4
|
+
import { getTotalCases } from "../describe.ts";
|
|
5
|
+
import { flattenResults } from "../execute.ts";
|
|
6
|
+
import type { TestResult } from "../scope.ts";
|
|
7
7
|
|
|
8
8
|
export function displayStatistics(
|
|
9
9
|
results: TestResult,
|
|
10
|
-
root: DOMElement = document.body as DOMElement
|
|
10
|
+
root: DOMElement = document.body as DOMElement,
|
|
11
11
|
) {
|
|
12
12
|
const { executed, failed } = results;
|
|
13
13
|
const logger = (() => {
|
|
14
14
|
try {
|
|
15
15
|
return makeHTMLLogger(
|
|
16
|
-
`Executed ${executed} of ${getTotalCases()}; ${failed} failed
|
|
16
|
+
`Executed ${executed} of ${getTotalCases()}; ${failed} failed.`,
|
|
17
17
|
);
|
|
18
|
-
} catch (
|
|
18
|
+
} catch (_e) {
|
|
19
19
|
return DEFAULT_LOGGER;
|
|
20
20
|
}
|
|
21
21
|
})();
|
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
import { xml } from "../../dom/xml.
|
|
2
|
-
import { FlatResult, flattenResults } from "../execute.
|
|
3
|
-
import { TestResult } from "../scope.
|
|
1
|
+
import { xml } from "../../dom/xml.ts";
|
|
2
|
+
import { type FlatResult, flattenResults } from "../execute.ts";
|
|
3
|
+
import type { TestResult } from "../scope.ts";
|
|
4
4
|
|
|
5
5
|
const cases = (results: TestResult) =>
|
|
6
6
|
Object.entries(results).filter(
|
|
7
|
-
([key]) => !["executed", "passed", "failed"].includes(key)
|
|
7
|
+
([key]) => !["executed", "passed", "failed"].includes(key),
|
|
8
8
|
);
|
|
9
9
|
|
|
10
10
|
export function asXML(results: TestResult) {
|
|
11
|
-
return (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
)
|
|
25
|
-
);
|
|
11
|
+
return `<?xml version="1.0" encoding="UTF-8" ?>${xml(
|
|
12
|
+
"testsuites",
|
|
13
|
+
{ tests: results.executed, failures: results.failed },
|
|
14
|
+
cases(results).map(([title, children]) =>
|
|
15
|
+
testsuite(
|
|
16
|
+
title,
|
|
17
|
+
(children as TestResult).executed,
|
|
18
|
+
(children as TestResult).failed,
|
|
19
|
+
flattenResults(children as TestResult),
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
)}`;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
function testsuite(
|
|
29
26
|
name: string,
|
|
30
27
|
tests: number,
|
|
31
28
|
failures: number,
|
|
32
|
-
cases: FlatResult[]
|
|
29
|
+
cases: FlatResult[],
|
|
33
30
|
) {
|
|
34
31
|
const id = name.replace("s+", "_");
|
|
35
32
|
return xml(
|
|
36
33
|
"testsuite",
|
|
37
34
|
{ id, name, tests, failures },
|
|
38
35
|
cases.map(({ test, stack }) =>
|
|
39
|
-
testcase({ name: `${name} ${test}` }, stack ? [stack as string] : [])
|
|
40
|
-
)
|
|
36
|
+
testcase({ name: `${name} ${test}` }, stack ? [stack as string] : []),
|
|
37
|
+
),
|
|
41
38
|
);
|
|
42
39
|
}
|
|
43
40
|
|
|
@@ -47,12 +44,12 @@ function testcase(
|
|
|
47
44
|
id = name.replace(/\s+/g, "_"),
|
|
48
45
|
time = "0.00",
|
|
49
46
|
}: { name: string; id?: string; time?: string },
|
|
50
|
-
failures: string[]
|
|
47
|
+
failures: string[],
|
|
51
48
|
) {
|
|
52
49
|
return xml(
|
|
53
50
|
"testcase",
|
|
54
51
|
{ id, name, time },
|
|
55
|
-
failures.map((stack) => failure({ text: stack }))
|
|
52
|
+
failures.map((stack) => failure({ text: stack })),
|
|
56
53
|
);
|
|
57
54
|
}
|
|
58
55
|
|
package/src/scope/execute.ts
CHANGED
|
@@ -4,8 +4,13 @@ import {
|
|
|
4
4
|
beforeall,
|
|
5
5
|
beforeeach,
|
|
6
6
|
rootCases,
|
|
7
|
-
} from "./describe.
|
|
8
|
-
import {
|
|
7
|
+
} from "./describe.ts";
|
|
8
|
+
import type {
|
|
9
|
+
TestFailed,
|
|
10
|
+
TestPassed,
|
|
11
|
+
TestResult,
|
|
12
|
+
TestSummary,
|
|
13
|
+
} from "./scope.ts";
|
|
9
14
|
|
|
10
15
|
export async function execute(cases = rootCases()): Promise<TestResult> {
|
|
11
16
|
const beforeallfn = cases[beforeall] ?? (() => {});
|
|
@@ -18,7 +23,7 @@ export async function execute(cases = rootCases()): Promise<TestResult> {
|
|
|
18
23
|
try {
|
|
19
24
|
await beforeallfn();
|
|
20
25
|
} catch (e) {
|
|
21
|
-
result
|
|
26
|
+
result._beforeAll = { error: e };
|
|
22
27
|
return result;
|
|
23
28
|
}
|
|
24
29
|
|
|
@@ -50,20 +55,20 @@ export async function execute(cases = rootCases()): Promise<TestResult> {
|
|
|
50
55
|
try {
|
|
51
56
|
await afterallfn();
|
|
52
57
|
} catch (e) {
|
|
53
|
-
result
|
|
58
|
+
result._afterAll = { error: e };
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
return result;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
export function getError({ error }: TestResult) {
|
|
60
|
-
if (typeof error
|
|
65
|
+
if (typeof error === "string") {
|
|
61
66
|
return error;
|
|
62
|
-
}
|
|
67
|
+
}
|
|
68
|
+
if ((error as TestResult).message) {
|
|
63
69
|
return (error as TestResult).stack;
|
|
64
|
-
} else {
|
|
65
|
-
return "unknown error";
|
|
66
70
|
}
|
|
71
|
+
return "unknown error";
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
export interface FlatResult {
|
|
@@ -74,7 +79,7 @@ export interface FlatResult {
|
|
|
74
79
|
|
|
75
80
|
function makeResult(
|
|
76
81
|
test: string,
|
|
77
|
-
result: TestResult | TestSummary
|
|
82
|
+
result: TestResult | TestSummary,
|
|
78
83
|
): FlatResult[] {
|
|
79
84
|
if ((result as TestFailed).error)
|
|
80
85
|
return [
|
|
@@ -91,13 +96,13 @@ function makeResult(
|
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
export function flattenResults(results: TestResult, prefix = ""): FlatResult[] {
|
|
94
|
-
const arrow = prefix
|
|
99
|
+
const arrow = prefix === "" ? "" : " -> ";
|
|
95
100
|
let errorList: FlatResult[] = [];
|
|
96
101
|
for (const [title, result] of Object.entries(results).filter(
|
|
97
|
-
([key]) => !["executed", "passed", "failed"].includes(key)
|
|
102
|
+
([key]) => !["executed", "passed", "failed"].includes(key),
|
|
98
103
|
)) {
|
|
99
104
|
const test = `${prefix}${arrow}${title}`;
|
|
100
|
-
if (typeof result
|
|
105
|
+
if (typeof result === "number") continue;
|
|
101
106
|
const flatResult = makeResult(test, result);
|
|
102
107
|
errorList = errorList.concat(flatResult);
|
|
103
108
|
}
|
package/src/scope/expect.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { assert } from "../assert.
|
|
2
|
-
import { display } from "../display.
|
|
3
|
-
import { equals } from "../equal.
|
|
1
|
+
import { assert } from "../assert.ts";
|
|
2
|
+
import { display } from "../display.ts";
|
|
3
|
+
import { equals } from "../equal.ts";
|
|
4
4
|
|
|
5
5
|
export class Matcher<T> {
|
|
6
6
|
actual: T;
|
|
@@ -21,27 +21,27 @@ export class Matcher<T> {
|
|
|
21
21
|
equals(this.actual, expected, partial),
|
|
22
22
|
() =>
|
|
23
23
|
`Objects are not equivalent: ${display(this.actual)}, ${display(
|
|
24
|
-
expected
|
|
25
|
-
)}
|
|
24
|
+
expected,
|
|
25
|
+
)}`,
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
toMatch(expected: RegExp | string) {
|
|
30
30
|
assert(
|
|
31
31
|
typeof this.actual === "string",
|
|
32
|
-
() => "Must have string for regexp match"
|
|
32
|
+
() => "Must have string for regexp match",
|
|
33
33
|
);
|
|
34
34
|
// @ts-expect-error
|
|
35
35
|
const actual: string = this.actual;
|
|
36
36
|
if (typeof expected === "string") {
|
|
37
37
|
assert(
|
|
38
38
|
actual.includes(expected),
|
|
39
|
-
() => `${actual} does not include ${expected}
|
|
39
|
+
() => `${actual} does not include ${expected}`,
|
|
40
40
|
);
|
|
41
41
|
} else {
|
|
42
42
|
assert(
|
|
43
43
|
expected.test(actual),
|
|
44
|
-
() => `${actual} does not match ${expected}
|
|
44
|
+
() => `${actual} does not match ${expected}`,
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -54,8 +54,8 @@ export class Matcher<T> {
|
|
|
54
54
|
equals(actual, v, true),
|
|
55
55
|
() =>
|
|
56
56
|
`Comparing ${k}, properties not equal: ${display(actual)}, ${display(
|
|
57
|
-
v
|
|
58
|
-
)}
|
|
57
|
+
v,
|
|
58
|
+
)}`,
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -63,21 +63,21 @@ export class Matcher<T> {
|
|
|
63
63
|
toBeNull() {
|
|
64
64
|
assert(
|
|
65
65
|
this.actual === null,
|
|
66
|
-
() => `Expected null, got ${JSON.stringify(this.actual)}
|
|
66
|
+
() => `Expected null, got ${JSON.stringify(this.actual)}`,
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
toThrow(message = "") {
|
|
71
71
|
let didThrow = false;
|
|
72
72
|
|
|
73
|
-
let result: unknown
|
|
73
|
+
let result: unknown;
|
|
74
74
|
try {
|
|
75
75
|
// @ts-expect-error
|
|
76
76
|
result = this.actual();
|
|
77
77
|
} catch (e) {
|
|
78
78
|
assert(
|
|
79
79
|
((e as { message?: string }).message ?? "").match(message) !== null,
|
|
80
|
-
() => `Expected thrown message to match ${message}, got ${e}
|
|
80
|
+
() => `Expected thrown message to match ${message}, got ${e}`,
|
|
81
81
|
);
|
|
82
82
|
didThrow = true;
|
|
83
83
|
}
|
|
@@ -105,22 +105,22 @@ export class NotMatcher<T> {
|
|
|
105
105
|
!equals(this.actual, expected),
|
|
106
106
|
() =>
|
|
107
107
|
`Objects are equivalent: ${JSON.stringify(
|
|
108
|
-
this.actual
|
|
109
|
-
)}, ${JSON.stringify(expected)}
|
|
108
|
+
this.actual,
|
|
109
|
+
)}, ${JSON.stringify(expected)}`,
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
toMatch(expected: RegExp | string) {
|
|
114
114
|
assert(
|
|
115
115
|
typeof this.actual === "string",
|
|
116
|
-
() => "Must have string for regexp match"
|
|
116
|
+
() => "Must have string for regexp match",
|
|
117
117
|
);
|
|
118
118
|
// @ts-expect-error
|
|
119
119
|
const actual: string = this.actual;
|
|
120
120
|
if (typeof expected === "string") {
|
|
121
121
|
assert(
|
|
122
122
|
!actual.includes(expected),
|
|
123
|
-
() => `${actual} includes ${expected}
|
|
123
|
+
() => `${actual} includes ${expected}`,
|
|
124
124
|
);
|
|
125
125
|
} else {
|
|
126
126
|
assert(!expected.test(actual), () => `${actual} matches ${expected}`);
|
|
@@ -135,27 +135,27 @@ export class NotMatcher<T> {
|
|
|
135
135
|
!equals(actual, v),
|
|
136
136
|
() =>
|
|
137
137
|
`Comparing ${k}, properties equal: ${JSON.stringify(
|
|
138
|
-
actual
|
|
139
|
-
)}, ${JSON.stringify(v)}
|
|
138
|
+
actual,
|
|
139
|
+
)}, ${JSON.stringify(v)}`,
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
toBeNull() {
|
|
145
|
-
assert(this.actual !== null, () =>
|
|
145
|
+
assert(this.actual !== null, () => "Expected not null");
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
toThrow(message = "") {
|
|
149
149
|
let didThrow = false;
|
|
150
150
|
|
|
151
|
-
let result: unknown
|
|
151
|
+
let result: unknown;
|
|
152
152
|
try {
|
|
153
153
|
// @ts-expect-error
|
|
154
154
|
result = this.actual();
|
|
155
155
|
} catch (e) {
|
|
156
156
|
assert(
|
|
157
157
|
((e as { message?: string }).message ?? "").match(message) !== null,
|
|
158
|
-
() => `Expected thrown message to match ${message}, got ${e}
|
|
158
|
+
() => `Expected thrown message to match ${message}, got ${e}`,
|
|
159
159
|
);
|
|
160
160
|
didThrow = true;
|
|
161
161
|
}
|
package/src/scope/fix.ts
CHANGED
|
@@ -3,27 +3,28 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export function fix<T>(n: T): T {
|
|
5
5
|
if (typeof n === "number") {
|
|
6
|
-
// @ts-ignore
|
|
7
6
|
return +n.toFixed(1) as T;
|
|
8
7
|
}
|
|
9
8
|
if (n !== Object(n)) {
|
|
10
9
|
// A primitive
|
|
11
10
|
return n;
|
|
12
11
|
}
|
|
13
|
-
if (n
|
|
14
|
-
// @ts-ignore
|
|
12
|
+
if (Array.isArray(n)) {
|
|
15
13
|
return n.map(fix) as T;
|
|
16
14
|
}
|
|
17
|
-
// @ts-
|
|
15
|
+
// @ts-expect-error
|
|
18
16
|
return mapreduce<T>(fix, n as Record<string, T>);
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
function mapreduce<T, U>(
|
|
22
20
|
fn: (t: T) => U,
|
|
23
|
-
iter: Record<string, T
|
|
21
|
+
iter: Record<string, T>,
|
|
24
22
|
): Record<string, U> {
|
|
25
23
|
return Object.entries(iter).reduce(
|
|
26
|
-
(acc, [k, v]) =>
|
|
27
|
-
|
|
24
|
+
(acc, [k, v]) => {
|
|
25
|
+
acc[k] = fn(v);
|
|
26
|
+
return acc;
|
|
27
|
+
},
|
|
28
|
+
{} as Record<string, U>,
|
|
28
29
|
);
|
|
29
30
|
}
|
package/src/scope/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { expect } from "./expect.js";
|
|
2
|
-
export { fix } from "./fix.js";
|
|
3
1
|
export {
|
|
4
2
|
afterAll,
|
|
5
3
|
afterEach,
|
|
@@ -8,4 +6,6 @@ export {
|
|
|
8
6
|
cleanState,
|
|
9
7
|
describe,
|
|
10
8
|
it,
|
|
11
|
-
} from "./describe.
|
|
9
|
+
} from "./describe.ts";
|
|
10
|
+
export { expect } from "./expect.ts";
|
|
11
|
+
export { fix } from "./fix.ts";
|
package/src/scope/scope.ts
CHANGED
package/src/scope/state.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Awaitable } from "../awaitable.
|
|
1
|
+
import type { Awaitable } from "../awaitable.ts";
|
|
2
2
|
|
|
3
3
|
export function cleanState<State extends {}>(
|
|
4
4
|
init: () => Awaitable<State>,
|
|
5
|
-
runner: (action: () => Promise<void>) => void
|
|
5
|
+
runner: (action: () => Promise<void>) => void,
|
|
6
6
|
): State {
|
|
7
7
|
const state = {};
|
|
8
8
|
runner(async () => {
|
package/src/server/http/apps.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as fs from "fs/promises";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { MiddlewareFactory } from "./index.
|
|
4
|
-
import { fileResponse } from "./response.
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { MiddlewareFactory } from "./index.ts";
|
|
4
|
+
import { fileResponse } from "./response.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Searches up the request path until the first index is found.
|
|
@@ -18,7 +18,7 @@ export const findIndex: MiddlewareFactory =
|
|
|
18
18
|
try {
|
|
19
19
|
const stat = await fs.stat(index);
|
|
20
20
|
return fileResponse(index, stat);
|
|
21
|
-
} catch (
|
|
21
|
+
} catch (_e) {
|
|
22
22
|
filename = path.dirname(filename);
|
|
23
23
|
}
|
|
24
24
|
}
|