@davidsouther/jiffies 1.0.0 → 2.0.1
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/build/pico.css +2466 -0
- package/build/pico.css.map +1 -0
- package/{build → lib/cjs}/assert.d.ts +0 -0
- package/lib/cjs/assert.js +40 -0
- package/{build → lib/cjs}/case.d.ts +0 -0
- package/lib/cjs/case.js +9 -0
- package/{build → lib/cjs}/components/button_bar.d.ts +1 -1
- package/lib/cjs/components/button_bar.js +29 -0
- package/{build → lib/cjs}/components/inline_edit.d.ts +1 -1
- package/lib/cjs/components/inline_edit.js +51 -0
- package/{build → lib/cjs}/components/logger.d.ts +2 -3
- package/lib/cjs/components/logger.js +27 -0
- package/{build → lib/cjs}/components/select.d.ts +2 -2
- package/lib/cjs/components/select.js +6 -0
- package/lib/cjs/components/test.d.ts +1 -0
- package/lib/cjs/components/test.js +7 -0
- package/{build → lib/cjs}/components/virtual_scroll.d.ts +3 -4
- package/lib/cjs/components/virtual_scroll.js +102 -0
- package/{build → lib/cjs}/components/virtual_scroll.test.d.ts +0 -0
- package/lib/cjs/components/virtual_scroll.test.js +22 -0
- package/{build → lib/cjs}/context.d.ts +0 -0
- package/lib/cjs/context.js +48 -0
- package/{build → lib/cjs}/context.test.d.ts +0 -0
- package/lib/cjs/context.test.js +48 -0
- package/{build → lib/cjs}/debounce.d.ts +0 -0
- package/lib/cjs/debounce.js +11 -0
- package/lib/cjs/diff.d.ts +15 -0
- package/lib/cjs/diff.js +58 -0
- package/{build/components/test.d.ts → lib/cjs/diff.test.d.ts} +0 -0
- package/lib/cjs/diff.test.js +41 -0
- package/{build → lib/cjs}/display.d.ts +0 -0
- package/lib/cjs/display.js +16 -0
- package/{build → lib/cjs}/dom/css/border.d.ts +0 -0
- package/lib/cjs/dom/css/border.js +33 -0
- package/{build → lib/cjs}/dom/css/constants.d.ts +0 -0
- package/lib/cjs/dom/css/constants.js +31 -0
- package/{build → lib/cjs}/dom/css/core.d.ts +0 -0
- package/lib/cjs/dom/css/core.js +31 -0
- package/{build → lib/cjs}/dom/css/fstyle.d.ts +0 -0
- package/lib/cjs/dom/css/fstyle.js +36 -0
- package/{build → lib/cjs}/dom/css/sizing.d.ts +0 -0
- package/lib/cjs/dom/css/sizing.js +14 -0
- package/lib/cjs/dom/dom.d.ts +27 -0
- package/lib/cjs/dom/dom.js +110 -0
- package/{build → lib/cjs}/dom/fc.d.ts +5 -5
- package/lib/cjs/dom/fc.js +39 -0
- package/{build → lib/cjs}/dom/fc.test.d.ts +0 -0
- package/lib/cjs/dom/fc.test.js +23 -0
- package/lib/cjs/dom/form/form.app.d.ts +1 -0
- package/lib/cjs/dom/form/form.app.js +27 -0
- package/{build → lib/cjs}/dom/form/form.d.ts +9 -9
- package/lib/cjs/dom/form/form.js +49 -0
- package/{build → lib/cjs}/dom/form/form.test.d.ts +0 -0
- package/{build → lib/cjs}/dom/form/form.test.js +0 -0
- package/lib/cjs/dom/html.d.ts +113 -0
- package/lib/cjs/dom/html.js +119 -0
- package/{build → lib/cjs}/dom/html.test.d.ts +0 -0
- package/lib/cjs/dom/html.test.js +60 -0
- package/lib/cjs/dom/observable.d.ts +2 -0
- package/lib/cjs/dom/observable.js +10 -0
- package/{build/dom/test.d.ts → lib/cjs/dom/observable.test.d.ts} +0 -0
- package/lib/cjs/dom/observable.test.js +35 -0
- package/{build → lib/cjs}/dom/provide.d.ts +0 -0
- package/lib/cjs/dom/provide.js +12 -0
- package/lib/cjs/dom/router/link.d.ts +6 -0
- package/lib/cjs/dom/router/link.js +7 -0
- package/{build → lib/cjs}/dom/router/router.d.ts +3 -3
- package/lib/cjs/dom/router/router.js +52 -0
- package/lib/cjs/dom/svg.d.ts +64 -0
- package/lib/cjs/dom/svg.js +69 -0
- package/lib/cjs/dom/test.d.ts +1 -0
- package/lib/cjs/dom/test.js +13 -0
- package/{build → lib/cjs}/dom/types/css.d.ts +0 -0
- package/lib/cjs/dom/types/css.js +24 -0
- package/{build → lib/cjs}/dom/types/dom.d.ts +0 -0
- package/{build → lib/cjs}/dom/types/dom.js +0 -0
- package/{build → lib/cjs}/dom/types/html.d.ts +1 -1
- package/lib/cjs/dom/types/html.js +2 -0
- package/{build → lib/cjs}/dom/xml.d.ts +0 -0
- package/lib/cjs/dom/xml.js +8 -0
- package/{build → lib/cjs}/equal.d.ts +0 -0
- package/lib/cjs/equal.js +43 -0
- package/{build → lib/cjs}/equal.test.d.ts +0 -0
- package/lib/cjs/equal.test.js +22 -0
- package/{build → lib/cjs}/flags.d.ts +0 -0
- package/lib/cjs/flags.js +52 -0
- package/{build → lib/cjs}/flags.test.d.ts +0 -0
- package/lib/cjs/flags.test.js +37 -0
- package/{build → lib/cjs}/fs.d.ts +0 -0
- package/lib/cjs/fs.js +151 -0
- package/{build → lib/cjs}/fs.test.d.ts +0 -0
- package/lib/cjs/fs.test.js +45 -0
- package/{build → lib/cjs}/generator.d.ts +0 -0
- package/lib/cjs/generator.js +14 -0
- package/{build → lib/cjs}/generator.test.d.ts +0 -0
- package/lib/cjs/generator.test.js +26 -0
- package/{build → lib/cjs}/is_browser.d.ts +0 -0
- package/lib/cjs/is_browser.js +4 -0
- package/{build → lib/cjs}/loader.d.mts +0 -0
- package/lib/cjs/loader.mjs +40 -0
- package/{build → lib/cjs}/lock.d.ts +0 -0
- package/lib/cjs/lock.js +27 -0
- package/{build → lib/cjs}/lock.test.d.ts +0 -0
- package/lib/cjs/lock.test.js +18 -0
- package/{build → lib/cjs}/log.d.ts +0 -0
- package/lib/cjs/log.js +54 -0
- package/lib/cjs/observable/event.d.ts +35 -0
- package/lib/cjs/observable/event.js +61 -0
- package/lib/cjs/observable/observable.d.ts +132 -0
- package/lib/cjs/observable/observable.js +363 -0
- package/{build/dom/types/html.js → lib/cjs/observable/observable.test.d.ts} +0 -0
- package/lib/cjs/observable/observable.test.js +65 -0
- package/{build → lib/cjs}/range.d.ts +0 -0
- package/lib/cjs/range.js +11 -0
- package/{build → lib/cjs}/result.d.ts +0 -0
- package/lib/cjs/result.js +80 -0
- package/{build → lib/cjs}/result.test.d.ts +0 -0
- package/lib/cjs/result.test.js +73 -0
- package/{build → lib/cjs}/safe.d.ts +0 -0
- package/lib/cjs/safe.js +14 -0
- package/{build → lib/cjs}/scope/describe.d.ts +4 -0
- package/lib/cjs/scope/describe.js +73 -0
- package/{build → lib/cjs}/scope/display/console.d.ts +0 -0
- package/lib/cjs/scope/display/console.js +25 -0
- package/{build → lib/cjs}/scope/display/dom.d.ts +2 -2
- package/lib/cjs/scope/display/dom.js +30 -0
- package/{build → lib/cjs}/scope/display/junit.d.ts +0 -0
- package/lib/cjs/scope/display/junit.js +21 -0
- package/{build → lib/cjs}/scope/execute.d.ts +1 -1
- package/lib/cjs/scope/execute.js +91 -0
- package/{build → lib/cjs}/scope/expect.d.ts +0 -0
- package/lib/cjs/scope/expect.js +114 -0
- package/{build → lib/cjs}/scope/fix.d.ts +0 -0
- package/lib/cjs/scope/fix.js +26 -0
- package/{build → lib/cjs}/scope/index.d.ts +0 -0
- package/lib/cjs/scope/index.js +15 -0
- package/{build → lib/cjs}/scope/scope.d.ts +0 -0
- package/lib/cjs/scope/scope.js +2 -0
- package/lib/cjs/scope/state.d.ts +1 -0
- package/lib/cjs/scope/state.js +11 -0
- package/{build → lib/cjs}/server/http/apps.d.ts +0 -0
- package/lib/cjs/server/http/apps.js +27 -0
- package/{build → lib/cjs}/server/http/css.d.ts +0 -0
- package/lib/cjs/server/http/css.js +54 -0
- package/{build → lib/cjs}/server/http/index.d.ts +0 -0
- package/lib/cjs/server/http/index.js +77 -0
- package/{build → lib/cjs}/server/http/response.d.ts +0 -0
- package/lib/cjs/server/http/response.js +45 -0
- package/{build → lib/cjs}/server/http/sitemap.d.ts +0 -0
- package/lib/cjs/server/http/sitemap.js +46 -0
- package/{build → lib/cjs}/server/http/static.d.ts +0 -0
- package/lib/cjs/server/http/static.js +25 -0
- package/{build → lib/cjs}/server/http/typescript.d.ts +0 -0
- package/lib/cjs/server/http/typescript.js +44 -0
- package/{build → lib/cjs}/server/main.d.ts +0 -0
- package/lib/cjs/server/main.js +14 -0
- package/{build → lib/cjs}/test.d.mts +0 -0
- package/lib/cjs/test.mjs +28 -0
- package/{build → lib/cjs}/test_all.d.ts +2 -0
- package/lib/cjs/test_all.js +30 -0
- package/{build → lib/cjs}/transpile.d.mts +0 -0
- package/lib/cjs/transpile.mjs +22 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -0
- package/lib/esm/assert.d.ts +23 -0
- package/{build → lib/esm}/assert.js +1 -1
- package/lib/esm/case.d.ts +1 -0
- package/{build → lib/esm}/case.js +0 -0
- package/lib/esm/components/button_bar.d.ts +8 -0
- package/{build → lib/esm}/components/button_bar.js +3 -3
- package/lib/esm/components/inline_edit.d.ts +12 -0
- package/{build → lib/esm}/components/inline_edit.js +3 -3
- package/lib/esm/components/logger.d.ts +6 -0
- package/{build → lib/esm}/components/logger.js +3 -3
- package/lib/esm/components/select.d.ts +10 -0
- package/{build → lib/esm}/components/select.js +2 -2
- package/lib/esm/components/test.d.ts +1 -0
- package/lib/esm/components/test.js +3 -0
- package/lib/esm/components/virtual_scroll.d.ts +40 -0
- package/{build → lib/esm}/components/virtual_scroll.js +3 -3
- package/{build/scope/scope.js → lib/esm/components/virtual_scroll.test.d.ts} +0 -0
- package/{build → lib/esm}/components/virtual_scroll.test.js +3 -4
- package/lib/esm/context.d.ts +15 -0
- package/{build → lib/esm}/context.js +3 -3
- package/lib/esm/context.test.d.ts +1 -0
- package/{build → lib/esm}/context.test.js +0 -0
- package/lib/esm/debounce.d.ts +1 -0
- package/{build → lib/esm}/debounce.js +0 -0
- package/lib/esm/diff.d.ts +15 -0
- package/lib/esm/diff.js +54 -0
- package/lib/esm/diff.test.d.ts +1 -0
- package/lib/esm/diff.test.js +39 -0
- package/lib/esm/display.d.ts +5 -0
- package/{build → lib/esm}/display.js +0 -0
- package/lib/esm/dom/css/border.d.ts +11 -0
- package/{build → lib/esm}/dom/css/border.js +0 -0
- package/lib/esm/dom/css/constants.d.ts +31 -0
- package/{build → lib/esm}/dom/css/constants.js +0 -0
- package/lib/esm/dom/css/core.d.ts +5 -0
- package/{build → lib/esm}/dom/css/core.js +0 -0
- package/lib/esm/dom/css/fstyle.d.ts +5 -0
- package/{build → lib/esm}/dom/css/fstyle.js +0 -0
- package/lib/esm/dom/css/sizing.d.ts +5 -0
- package/{build → lib/esm}/dom/css/sizing.js +0 -0
- package/lib/esm/dom/dom.d.ts +27 -0
- package/{build → lib/esm}/dom/dom.js +44 -35
- package/lib/esm/dom/fc.d.ts +14 -0
- package/{build → lib/esm}/dom/fc.js +1 -1
- package/lib/esm/dom/fc.test.d.ts +1 -0
- package/{build → lib/esm}/dom/fc.test.js +0 -0
- package/lib/esm/dom/form/form.app.d.ts +1 -0
- package/{build → lib/esm}/dom/form/form.app.js +0 -0
- package/lib/esm/dom/form/form.d.ts +26 -0
- package/{build → lib/esm}/dom/form/form.js +0 -0
- package/lib/esm/dom/form/form.test.d.ts +0 -0
- package/lib/esm/dom/form/form.test.js +1 -0
- package/lib/esm/dom/html.d.ts +113 -0
- package/{build → lib/esm}/dom/html.js +0 -0
- package/lib/esm/dom/html.test.d.ts +1 -0
- package/{build → lib/esm}/dom/html.test.js +4 -4
- package/lib/esm/dom/observable.d.ts +2 -0
- package/lib/esm/dom/observable.js +6 -0
- package/lib/esm/dom/observable.test.d.ts +1 -0
- package/lib/esm/dom/observable.test.js +33 -0
- package/lib/esm/dom/provide.d.ts +3 -0
- package/{build → lib/esm}/dom/provide.js +0 -0
- package/lib/esm/dom/router/link.d.ts +6 -0
- package/{build → lib/esm}/dom/router/link.js +0 -0
- package/lib/esm/dom/router/router.d.ts +12 -0
- package/{build → lib/esm}/dom/router/router.js +0 -0
- package/lib/esm/dom/svg.d.ts +64 -0
- package/{build → lib/esm}/dom/svg.js +0 -0
- package/lib/esm/dom/test.d.ts +1 -0
- package/lib/esm/dom/test.js +9 -0
- package/lib/esm/dom/types/css.d.ts +6612 -0
- package/{build → lib/esm}/dom/types/css.js +0 -0
- package/lib/esm/dom/types/dom.d.ts +0 -0
- package/lib/esm/dom/types/dom.js +1 -0
- package/lib/esm/dom/types/html.d.ts +616 -0
- package/lib/esm/dom/types/html.js +1 -0
- package/lib/esm/dom/xml.d.ts +1 -0
- package/{build → lib/esm}/dom/xml.js +1 -2
- package/lib/esm/equal.d.ts +5 -0
- package/{build → lib/esm}/equal.js +1 -1
- package/lib/esm/equal.test.d.ts +1 -0
- package/{build → lib/esm}/equal.test.js +0 -0
- package/lib/esm/flags.d.ts +7 -0
- package/{build → lib/esm}/flags.js +1 -1
- package/lib/esm/flags.test.d.ts +1 -0
- package/{build → lib/esm}/flags.test.js +0 -0
- package/lib/esm/fs.d.ts +48 -0
- package/{build → lib/esm}/fs.js +4 -4
- package/lib/esm/fs.test.d.ts +1 -0
- package/{build → lib/esm}/fs.test.js +0 -0
- package/lib/esm/generator.d.ts +1 -0
- package/{build → lib/esm}/generator.js +0 -0
- package/lib/esm/generator.test.d.ts +1 -0
- package/{build → lib/esm}/generator.test.js +0 -0
- package/lib/esm/is_browser.d.ts +1 -0
- package/{build → lib/esm}/is_browser.js +0 -0
- package/lib/esm/loader.d.mts +22 -0
- package/{build → lib/esm}/loader.mjs +0 -0
- package/lib/esm/lock.d.ts +1 -0
- package/{build → lib/esm}/lock.js +0 -0
- package/lib/esm/lock.test.d.ts +1 -0
- package/{build → lib/esm}/lock.test.js +0 -0
- package/lib/esm/log.d.ts +26 -0
- package/{build → lib/esm}/log.js +0 -0
- package/lib/esm/observable/event.d.ts +35 -0
- package/lib/esm/observable/event.js +46 -0
- package/lib/esm/observable/observable.d.ts +132 -0
- package/lib/esm/observable/observable.js +343 -0
- package/lib/esm/observable/observable.test.d.ts +1 -0
- package/lib/esm/observable/observable.test.js +63 -0
- package/lib/esm/range.d.ts +1 -0
- package/{build → lib/esm}/range.js +0 -0
- package/lib/esm/result.d.ts +31 -0
- package/{build → lib/esm}/result.js +1 -1
- package/lib/esm/result.test.d.ts +1 -0
- package/{build → lib/esm}/result.test.js +0 -0
- package/lib/esm/safe.d.ts +1 -0
- package/{build → lib/esm}/safe.js +0 -0
- package/lib/esm/scope/describe.d.ts +18 -0
- package/{build → lib/esm}/scope/describe.js +14 -6
- package/lib/esm/scope/display/console.d.ts +2 -0
- package/{build → lib/esm}/scope/display/console.js +0 -0
- package/lib/esm/scope/display/dom.d.ts +3 -0
- package/{build → lib/esm}/scope/display/dom.js +0 -0
- package/lib/esm/scope/display/junit.d.ts +2 -0
- package/{build → lib/esm}/scope/display/junit.js +0 -0
- package/lib/esm/scope/execute.d.ts +12 -0
- package/{build → lib/esm}/scope/execute.js +2 -2
- package/lib/esm/scope/expect.d.ts +23 -0
- package/{build → lib/esm}/scope/expect.js +0 -0
- package/lib/esm/scope/fix.d.ts +4 -0
- package/{build → lib/esm}/scope/fix.js +0 -0
- package/{build/scope/index.js → lib/esm/scope/index.d.ts} +0 -0
- package/lib/esm/scope/index.js +3 -0
- package/lib/esm/scope/scope.d.ts +17 -0
- package/lib/esm/scope/scope.js +1 -0
- package/lib/esm/scope/state.d.ts +1 -0
- package/lib/esm/scope/state.js +7 -0
- package/lib/esm/server/http/apps.d.ts +5 -0
- package/{build → lib/esm}/server/http/apps.js +0 -0
- package/lib/esm/server/http/css.d.ts +5 -0
- package/{build → lib/esm}/server/http/css.js +3 -0
- package/lib/esm/server/http/index.d.ts +21 -0
- package/{build → lib/esm}/server/http/index.js +0 -0
- package/lib/esm/server/http/response.d.ts +4 -0
- package/{build → lib/esm}/server/http/response.js +0 -0
- package/lib/esm/server/http/sitemap.d.ts +2 -0
- package/{build → lib/esm}/server/http/sitemap.js +0 -0
- package/lib/esm/server/http/static.d.ts +2 -0
- package/{build → lib/esm}/server/http/static.js +0 -0
- package/lib/esm/server/http/typescript.d.ts +5 -0
- package/{build → lib/esm}/server/http/typescript.js +0 -0
- package/lib/esm/server/main.d.ts +2 -0
- package/{build → lib/esm}/server/main.js +5 -2
- package/lib/esm/test.d.mts +2 -0
- package/lib/esm/test.mjs +26 -0
- package/lib/esm/test_all.d.ts +9 -0
- package/{build → lib/esm}/test_all.js +17 -7
- package/lib/esm/transpile.d.mts +3 -0
- package/{build → lib/esm}/transpile.mjs +0 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +17 -18
- package/src/assert.ts +1 -1
- package/src/components/button_bar.ts +3 -3
- package/src/components/inline_edit.ts +3 -3
- package/src/components/logger.ts +5 -6
- package/src/components/select.ts +3 -3
- package/src/components/test.js +3 -2
- package/src/components/virtual_scroll.test.ts +4 -4
- package/src/components/virtual_scroll.ts +8 -8
- package/src/context.ts +3 -3
- package/src/diff.test.ts +48 -0
- package/src/diff.ts +84 -0
- package/src/dom/css/border.ts +3 -3
- package/src/dom/css/core.ts +1 -1
- package/src/dom/css/fstyle.ts +2 -2
- package/src/dom/css/sizing.ts +1 -1
- package/src/dom/dom.ts +73 -61
- package/src/dom/fc.test.ts +3 -3
- package/src/dom/fc.ts +11 -10
- package/src/dom/form/form.app.ts +2 -2
- package/src/dom/form/form.ts +3 -3
- package/src/dom/html.test.ts +8 -8
- package/src/dom/html.ts +7 -10
- package/src/dom/observable.test.ts +43 -0
- package/src/dom/observable.ts +11 -0
- package/src/dom/provide.ts +1 -1
- package/src/dom/router/link.ts +2 -2
- package/src/dom/router/router.ts +5 -5
- package/src/dom/svg.ts +1 -1
- package/src/dom/test.ts +8 -2
- package/src/dom/types/html.ts +1 -1
- package/src/dom/xml.ts +1 -2
- package/src/equal.ts +1 -1
- package/src/flags.ts +1 -1
- package/src/fs.ts +4 -4
- package/src/index.html +12 -9
- package/src/observable/_notes +21 -8
- package/src/observable/event.ts +93 -0
- package/src/observable/observable.test.ts +73 -0
- package/src/observable/observable.ts +463 -0
- package/src/pico/_variables.scss +1 -1
- package/src/pico/layout/_sectioning.scss +2 -0
- package/src/result.ts +1 -1
- package/src/scope/describe.ts +16 -6
- package/src/scope/display/console.ts +4 -4
- package/src/scope/display/dom.ts +7 -7
- package/src/scope/display/junit.ts +3 -3
- package/src/scope/execute.ts +4 -7
- package/src/scope/expect.ts +3 -3
- package/src/scope/state.ts +10 -0
- package/src/server/http/css.ts +3 -1
- package/src/server/http/sitemap.ts +1 -1
- package/src/server/main.ts +9 -2
- package/src/test.mjs +22 -18
- package/src/test_all.ts +20 -8
- package/build/components/test.js +0 -2
- package/build/dom/dom.d.ts +0 -27
- package/build/dom/form/form.app.d.ts +0 -1
- package/build/dom/html.d.ts +0 -117
- package/build/dom/router/link.d.ts +0 -6
- package/build/dom/svg.d.ts +0 -64
- package/build/dom/test.js +0 -2
- package/build/test.mjs +0 -23
- package/src/observable/observable._js +0 -175
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { DEFAULT_LOGGER } from "../log.js";
|
|
2
|
+
export const Observable = {
|
|
3
|
+
of(...ts) {
|
|
4
|
+
const subject = new Subject();
|
|
5
|
+
(async function next() {
|
|
6
|
+
if (subject.cold) {
|
|
7
|
+
subject.onWarm(next);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (ts.length === 0) {
|
|
11
|
+
subject.complete();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const t = ts.shift();
|
|
15
|
+
await subject.next(t);
|
|
16
|
+
next();
|
|
17
|
+
})();
|
|
18
|
+
return subject;
|
|
19
|
+
},
|
|
20
|
+
combineLatest(o1, o2) {
|
|
21
|
+
let latestSubject = new Subject();
|
|
22
|
+
let o1LatestSet = false;
|
|
23
|
+
let o1Latest;
|
|
24
|
+
let o2LatestSet = false;
|
|
25
|
+
let o2Latest;
|
|
26
|
+
function next() {
|
|
27
|
+
if (o1LatestSet && o2LatestSet) {
|
|
28
|
+
latestSubject.next([o1Latest, o2Latest]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function error(e) {
|
|
32
|
+
latestSubject.error(e);
|
|
33
|
+
}
|
|
34
|
+
function complete() {
|
|
35
|
+
latestSubject.complete();
|
|
36
|
+
o1sub.unsubscribe();
|
|
37
|
+
o2sub.unsubscribe();
|
|
38
|
+
}
|
|
39
|
+
let o1sub = o1.subscribe({
|
|
40
|
+
next(t) {
|
|
41
|
+
o1Latest = t;
|
|
42
|
+
o1LatestSet = true;
|
|
43
|
+
next();
|
|
44
|
+
},
|
|
45
|
+
error,
|
|
46
|
+
complete,
|
|
47
|
+
});
|
|
48
|
+
let o2sub = o2.subscribe({
|
|
49
|
+
next(t) {
|
|
50
|
+
o2Latest = t;
|
|
51
|
+
o2LatestSet = true;
|
|
52
|
+
next();
|
|
53
|
+
},
|
|
54
|
+
error,
|
|
55
|
+
complete,
|
|
56
|
+
});
|
|
57
|
+
return latestSubject;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export const AsyncScheduler = {
|
|
61
|
+
execute(fn) {
|
|
62
|
+
return Promise.all(fn()).then(() => undefined);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export const SyncScheduler = {
|
|
66
|
+
execute(fn) {
|
|
67
|
+
fn();
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export class Subject {
|
|
71
|
+
scheduler;
|
|
72
|
+
#coldWaiters = new Set();
|
|
73
|
+
#subscribers = new Set();
|
|
74
|
+
#complete = false;
|
|
75
|
+
get $() {
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
get hot() {
|
|
79
|
+
return this.#subscribers.size > 0;
|
|
80
|
+
}
|
|
81
|
+
get cold() {
|
|
82
|
+
return !this.hot;
|
|
83
|
+
}
|
|
84
|
+
constructor(scheduler = AsyncScheduler) {
|
|
85
|
+
this.scheduler = scheduler;
|
|
86
|
+
}
|
|
87
|
+
onWarm(fn) {
|
|
88
|
+
if (this.cold)
|
|
89
|
+
this.#coldWaiters.add(fn);
|
|
90
|
+
}
|
|
91
|
+
next(t) {
|
|
92
|
+
if (this.#complete)
|
|
93
|
+
throw new Error("Cannot call next on a completed subject");
|
|
94
|
+
return this.scheduler.execute(() => [...this.#subscribers].map((s) => s.next?.(t)));
|
|
95
|
+
}
|
|
96
|
+
error(e) {
|
|
97
|
+
if (this.#complete)
|
|
98
|
+
throw new Error("Cannot call error on a completed subject");
|
|
99
|
+
return this.scheduler.execute(() => [...this.#subscribers].map((s) => s.error?.(e)));
|
|
100
|
+
}
|
|
101
|
+
complete() {
|
|
102
|
+
if (this.#complete)
|
|
103
|
+
throw new Error("Cannot call complete on a completed subject");
|
|
104
|
+
this.#complete = true;
|
|
105
|
+
const finished = this.scheduler.execute(() => [...this.#subscribers].map((s) => s.complete?.()));
|
|
106
|
+
this.#subscribers.clear(); // Free subscribers for garbage collection
|
|
107
|
+
return finished;
|
|
108
|
+
}
|
|
109
|
+
subscribe(subscriber) {
|
|
110
|
+
if (this.#complete)
|
|
111
|
+
throw new Error("Cannot call subscribe on a completed subject");
|
|
112
|
+
if (subscriber instanceof Function) {
|
|
113
|
+
subscriber = { next: subscriber };
|
|
114
|
+
}
|
|
115
|
+
this.#subscribers.add(subscriber);
|
|
116
|
+
[...this.#coldWaiters].forEach((w) => w());
|
|
117
|
+
this.#coldWaiters.clear();
|
|
118
|
+
return {
|
|
119
|
+
unsubscribe: () => this.#subscribers.delete(subscriber),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
pipe(...os) {
|
|
123
|
+
this.subscribe(os[0]);
|
|
124
|
+
for (let i = 1; i < os.length; i++) {
|
|
125
|
+
os[i - 1].subscribe(os[i]);
|
|
126
|
+
}
|
|
127
|
+
return os[os.length - 1];
|
|
128
|
+
}
|
|
129
|
+
filter(fn) {
|
|
130
|
+
return this.pipe(operator.filter(fn));
|
|
131
|
+
}
|
|
132
|
+
distinct(fn = Object.is) {
|
|
133
|
+
return this.pipe(operator.distinct(fn));
|
|
134
|
+
}
|
|
135
|
+
map(fn) {
|
|
136
|
+
return this.pipe(operator.map(fn));
|
|
137
|
+
}
|
|
138
|
+
reduce(fn, init) {
|
|
139
|
+
return this.pipe(operator.reduce(fn, init));
|
|
140
|
+
}
|
|
141
|
+
replay(n) {
|
|
142
|
+
return this.pipe(operator.replay(n));
|
|
143
|
+
}
|
|
144
|
+
tap(s) {
|
|
145
|
+
return this.pipe(operator.tap(s));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export class BehaviorSubject extends Subject {
|
|
149
|
+
#current;
|
|
150
|
+
constructor(t, scheduler) {
|
|
151
|
+
super(scheduler);
|
|
152
|
+
this.#current = t;
|
|
153
|
+
}
|
|
154
|
+
next(t) {
|
|
155
|
+
this.#current = t;
|
|
156
|
+
return super.next(t);
|
|
157
|
+
}
|
|
158
|
+
subscribe(subscriber) {
|
|
159
|
+
if (subscriber instanceof Function) {
|
|
160
|
+
subscriber = { next: subscriber };
|
|
161
|
+
}
|
|
162
|
+
subscriber.next?.(this.#current);
|
|
163
|
+
return super.subscribe(subscriber);
|
|
164
|
+
}
|
|
165
|
+
get current() {
|
|
166
|
+
return this.#current;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
export class ReplaySubject extends Subject {
|
|
170
|
+
n;
|
|
171
|
+
#history = [];
|
|
172
|
+
constructor(n, scheduler) {
|
|
173
|
+
super(scheduler);
|
|
174
|
+
this.n = n;
|
|
175
|
+
}
|
|
176
|
+
next(t) {
|
|
177
|
+
this.#history.push(t);
|
|
178
|
+
if (this.#history.length > this.n) {
|
|
179
|
+
this.#history.shift();
|
|
180
|
+
}
|
|
181
|
+
return super.next(t);
|
|
182
|
+
}
|
|
183
|
+
subscribe(subscriber) {
|
|
184
|
+
if (subscriber instanceof Function) {
|
|
185
|
+
subscriber = { next: subscriber };
|
|
186
|
+
}
|
|
187
|
+
const history = [...this.#history];
|
|
188
|
+
(function send() {
|
|
189
|
+
if (history.length == 0)
|
|
190
|
+
return;
|
|
191
|
+
const t = history.shift();
|
|
192
|
+
subscriber.next?.(t);
|
|
193
|
+
new Promise(send);
|
|
194
|
+
})();
|
|
195
|
+
return super.subscribe(subscriber);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
export function eventListener() {
|
|
199
|
+
const observable = new Subject();
|
|
200
|
+
function listener(e) {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
observable.next(e);
|
|
203
|
+
}
|
|
204
|
+
return [observable, listener];
|
|
205
|
+
}
|
|
206
|
+
export class EventHandler extends Subject {
|
|
207
|
+
eventFn;
|
|
208
|
+
constructor(eventFn) {
|
|
209
|
+
super();
|
|
210
|
+
this.eventFn = eventFn;
|
|
211
|
+
}
|
|
212
|
+
next(e) {
|
|
213
|
+
e.preventDefault();
|
|
214
|
+
super.next(e);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
export const watch = (logger = DEFAULT_LOGGER) => (observable) => {
|
|
218
|
+
observable.tap({
|
|
219
|
+
next(t) {
|
|
220
|
+
logger.info(t);
|
|
221
|
+
},
|
|
222
|
+
complete() {
|
|
223
|
+
logger.info("Observable completed");
|
|
224
|
+
},
|
|
225
|
+
error(e) {
|
|
226
|
+
logger.warn(e);
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
class MapOperator extends Subject {
|
|
231
|
+
mapFn;
|
|
232
|
+
constructor(mapFn) {
|
|
233
|
+
super();
|
|
234
|
+
this.mapFn = mapFn;
|
|
235
|
+
}
|
|
236
|
+
next(t) {
|
|
237
|
+
return super.next(this.mapFn(t));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
class FilterOperator extends Subject {
|
|
241
|
+
filterFn;
|
|
242
|
+
constructor(filterFn) {
|
|
243
|
+
super();
|
|
244
|
+
this.filterFn = filterFn;
|
|
245
|
+
}
|
|
246
|
+
next(t) {
|
|
247
|
+
return this.filterFn(t) ? super.next(t) : undefined;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
class DistinctOperator extends Subject {
|
|
251
|
+
distinctFn;
|
|
252
|
+
#prior = undefined;
|
|
253
|
+
constructor(distinctFn = Object.is) {
|
|
254
|
+
super();
|
|
255
|
+
this.distinctFn = distinctFn;
|
|
256
|
+
}
|
|
257
|
+
next(t) {
|
|
258
|
+
if (this.#prior === undefined) {
|
|
259
|
+
this.#prior = t;
|
|
260
|
+
return super.next(t);
|
|
261
|
+
}
|
|
262
|
+
const same = this.distinctFn(this.#prior, t);
|
|
263
|
+
if (!same) {
|
|
264
|
+
this.#prior = t;
|
|
265
|
+
return super.next(t);
|
|
266
|
+
}
|
|
267
|
+
return undefined;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
class ReduceOperator extends BehaviorSubject {
|
|
271
|
+
fn;
|
|
272
|
+
constructor(fn, init) {
|
|
273
|
+
super(init);
|
|
274
|
+
this.fn = fn;
|
|
275
|
+
}
|
|
276
|
+
next(t) {
|
|
277
|
+
return super.next(this.fn(this.current, t));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
export class TakeUntilOperator extends Subject {
|
|
281
|
+
constructor(o) {
|
|
282
|
+
super();
|
|
283
|
+
o.subscribe(() => this.complete());
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
export class TapOperator extends Subject {
|
|
287
|
+
subscriber;
|
|
288
|
+
constructor(fn) {
|
|
289
|
+
super();
|
|
290
|
+
this.subscriber = fn instanceof Function ? { next: fn } : fn;
|
|
291
|
+
}
|
|
292
|
+
next(t) {
|
|
293
|
+
this.subscriber.next?.(t);
|
|
294
|
+
return super.next(t);
|
|
295
|
+
}
|
|
296
|
+
error(e) {
|
|
297
|
+
this.subscriber.error?.(e);
|
|
298
|
+
return super.error(e);
|
|
299
|
+
}
|
|
300
|
+
complete() {
|
|
301
|
+
this.subscriber.complete?.();
|
|
302
|
+
return super.complete();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
class FirstOperator extends Subject {
|
|
306
|
+
next(t) {
|
|
307
|
+
const next = super.next(t);
|
|
308
|
+
this.complete();
|
|
309
|
+
return next;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
class LastOperator extends Subject {
|
|
313
|
+
#latest;
|
|
314
|
+
next(t) {
|
|
315
|
+
this.#latest = t;
|
|
316
|
+
}
|
|
317
|
+
complete() {
|
|
318
|
+
if (this.#latest !== undefined) {
|
|
319
|
+
super.next(this.#latest);
|
|
320
|
+
}
|
|
321
|
+
return super.complete();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
export const filter = (fn) => new FilterOperator(fn);
|
|
325
|
+
export const distinct = (fn) => new DistinctOperator(fn ?? Object.is);
|
|
326
|
+
export const first = () => new FirstOperator();
|
|
327
|
+
export const last = () => new LastOperator();
|
|
328
|
+
export const map = (fn) => new MapOperator(fn);
|
|
329
|
+
export const replay = (n) => new ReplaySubject(n);
|
|
330
|
+
export const reduce = (fn, init) => new ReduceOperator(fn, init);
|
|
331
|
+
export const takeUntil = (o) => new TakeUntilOperator(o);
|
|
332
|
+
export const tap = (fn) => new TapOperator(fn);
|
|
333
|
+
export const operator = {
|
|
334
|
+
filter,
|
|
335
|
+
distinct,
|
|
336
|
+
first,
|
|
337
|
+
last,
|
|
338
|
+
map,
|
|
339
|
+
replay,
|
|
340
|
+
reduce,
|
|
341
|
+
takeUntil,
|
|
342
|
+
tap,
|
|
343
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { describe, expect, it } from "../scope/index.js";
|
|
2
|
+
import { Observable, Subject, filter, map } from "./observable.js";
|
|
3
|
+
describe("Observables", () => {
|
|
4
|
+
describe("basics", () => {
|
|
5
|
+
it("can create and observe a scalar subject", async () => {
|
|
6
|
+
const subject = new Subject();
|
|
7
|
+
let resolved = 42;
|
|
8
|
+
subject.subscribe({
|
|
9
|
+
next: (n) => {
|
|
10
|
+
resolved = n;
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
expect(resolved).toBe(42);
|
|
14
|
+
await subject.next(64);
|
|
15
|
+
expect(resolved).toBe(64);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe("creation", () => {
|
|
19
|
+
it("builds an observable of items", async () => {
|
|
20
|
+
const stream = Observable.of(2, 4, 8, 16);
|
|
21
|
+
let values = [];
|
|
22
|
+
await new Promise((resolve) => {
|
|
23
|
+
stream.subscribe({
|
|
24
|
+
next: (n) => {
|
|
25
|
+
values.unshift(n);
|
|
26
|
+
},
|
|
27
|
+
complete: () => {
|
|
28
|
+
resolve();
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
expect(values).toEqual([16, 8, 4, 2]);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe("pipes", () => {
|
|
36
|
+
it("runs a pipe", async () => {
|
|
37
|
+
const subject = new Subject();
|
|
38
|
+
let resolved = 0;
|
|
39
|
+
const inflate = (i) => (n) => n + i;
|
|
40
|
+
const biggerThan = (i) => (n) => n > i;
|
|
41
|
+
const assign = (n) => {
|
|
42
|
+
resolved = n;
|
|
43
|
+
};
|
|
44
|
+
subject.pipe(map(inflate(22)), filter(biggerThan(70))).subscribe(assign);
|
|
45
|
+
expect(resolved).toBe(0);
|
|
46
|
+
await subject.next(42);
|
|
47
|
+
expect(resolved).toBe(0);
|
|
48
|
+
await subject.next(50);
|
|
49
|
+
expect(resolved).toBe(72);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe("Subject", () => {
|
|
53
|
+
it("is callable", async () => {
|
|
54
|
+
const subject = new Subject();
|
|
55
|
+
let resolved = 0;
|
|
56
|
+
subject.subscribe((n) => {
|
|
57
|
+
resolved = n;
|
|
58
|
+
});
|
|
59
|
+
await subject.next(42);
|
|
60
|
+
expect(resolved).toBe(42);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function range(start: number, end: number, stride?: number): number[];
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare type None = null;
|
|
2
|
+
export declare type Some<T> = T;
|
|
3
|
+
export declare type Option<T> = Some<T> | None;
|
|
4
|
+
export declare type Err<E = Error> = {
|
|
5
|
+
err: E;
|
|
6
|
+
map: <U>(fn: (t: unknown) => Result<U>) => Result<U>;
|
|
7
|
+
};
|
|
8
|
+
export declare type Ok<T> = {
|
|
9
|
+
ok: T;
|
|
10
|
+
map: <U>(fn: (t: T) => Result<U>) => Result<U>;
|
|
11
|
+
};
|
|
12
|
+
export declare type Result<T, E = Error> = Ok<T> | Err<E>;
|
|
13
|
+
export declare const isNone: <T>(s: Option<T>) => s is null;
|
|
14
|
+
export declare const isSome: <T>(s: Option<T>) => s is T;
|
|
15
|
+
export declare function None<T = unknown>(_?: T): Option<T>;
|
|
16
|
+
export declare function Some<T>(t: Option<T>): Option<T>;
|
|
17
|
+
export declare function Some<T>(t: T): Option<T>;
|
|
18
|
+
export declare const isOk: <T, E>(t: Result<T, E>) => t is Ok<T>;
|
|
19
|
+
export declare const isErr: <T, E>(e: Result<T, E>) => e is Err<E>;
|
|
20
|
+
export declare const isResult: <T, E>(t: Result<T, E>) => t is Result<T, E>;
|
|
21
|
+
export declare function Ok<T>(ok: Ok<T>): T;
|
|
22
|
+
export declare function Ok<T>(t: T): Ok<T>;
|
|
23
|
+
export declare function Err<E>(e: Err<E>): E;
|
|
24
|
+
export declare function Err<E>(e: E): Err<E>;
|
|
25
|
+
export declare function Err<E>(e: string): Err<E>;
|
|
26
|
+
export declare function unwrap<T, E>(result: Result<T, E>): T | never;
|
|
27
|
+
export declare function unwrap<O>(some: Option<O>): O | never;
|
|
28
|
+
export declare function unwrapOr<T, E>(result: Result<T, E>, def: T): T;
|
|
29
|
+
export declare function unwrapOr<T>(some: Some<T>, def: T): T;
|
|
30
|
+
export declare function unwrapOrElse<T, E>(result: Result<T, Error>, def: () => T): T;
|
|
31
|
+
export declare function unwrapOrElse<T>(some: Some<T>, def: () => T): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const safe: <A extends unknown[], R>(fn: (...args: A) => R, r: R) => (...args: A) => R;
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TestCase } from "./scope.js";
|
|
2
|
+
export declare const beforeall: unique symbol;
|
|
3
|
+
export declare const beforeeach: unique symbol;
|
|
4
|
+
export declare const afterall: unique symbol;
|
|
5
|
+
export declare const aftereach: unique symbol;
|
|
6
|
+
export declare function rootCases(): TestCase;
|
|
7
|
+
export declare function getTotalCases(): number;
|
|
8
|
+
export declare function getSkippedCases(): number;
|
|
9
|
+
export declare function describe(title: string, block: Function): void;
|
|
10
|
+
export declare function it(title: string, block: Function): void;
|
|
11
|
+
export declare namespace it {
|
|
12
|
+
var skip: (title: string, _block: Function) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function beforeEach(fn: () => void): void;
|
|
15
|
+
export declare function beforeAll(fn: () => void): void;
|
|
16
|
+
export declare function afterEach(fn: () => void): void;
|
|
17
|
+
export declare function afterAll(fn: () => void): void;
|
|
18
|
+
export declare function cleanState<State extends {}>(init: () => State, runner?: (action: () => void) => void): State;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { assert } from "../assert.js";
|
|
1
2
|
import { getLogger } from "../log.js";
|
|
3
|
+
import * as state from "./state.js";
|
|
2
4
|
export const beforeall = Symbol("beforeAll");
|
|
3
5
|
export const beforeeach = Symbol("beforeEach");
|
|
4
6
|
export const afterall = Symbol("afterAll");
|
|
@@ -7,8 +9,9 @@ const logger = getLogger("scope");
|
|
|
7
9
|
const CASES = {};
|
|
8
10
|
let cases = [CASES];
|
|
9
11
|
let totalCases = 0;
|
|
12
|
+
let skippedCases = 0;
|
|
10
13
|
function push(title) {
|
|
11
|
-
const next = (cases[0][title] = {});
|
|
14
|
+
const next = (cases[0][title] = cases[0][title] ?? {});
|
|
12
15
|
cases.unshift(next);
|
|
13
16
|
}
|
|
14
17
|
function pop() {
|
|
@@ -20,6 +23,9 @@ export function rootCases() {
|
|
|
20
23
|
export function getTotalCases() {
|
|
21
24
|
return totalCases;
|
|
22
25
|
}
|
|
26
|
+
export function getSkippedCases() {
|
|
27
|
+
return skippedCases;
|
|
28
|
+
}
|
|
23
29
|
export function describe(title, block) {
|
|
24
30
|
logger.debug(`describe(${title})`);
|
|
25
31
|
push(title);
|
|
@@ -28,9 +34,15 @@ export function describe(title, block) {
|
|
|
28
34
|
}
|
|
29
35
|
export function it(title, block) {
|
|
30
36
|
logger.debug(`it(${title})`);
|
|
37
|
+
assert(cases[0][title] == undefined, `Block already has test ${title}`);
|
|
31
38
|
totalCases += 1;
|
|
32
39
|
cases[0][title] = block;
|
|
33
40
|
}
|
|
41
|
+
it.skip = (title, _block) => {
|
|
42
|
+
logger.debug(`it.skip(${title})`);
|
|
43
|
+
totalCases += 1;
|
|
44
|
+
skippedCases += 1;
|
|
45
|
+
};
|
|
34
46
|
export function beforeEach(fn) {
|
|
35
47
|
cases[0][beforeeach] = fn;
|
|
36
48
|
}
|
|
@@ -44,9 +56,5 @@ export function afterAll(fn) {
|
|
|
44
56
|
cases[0][afterall] = fn;
|
|
45
57
|
}
|
|
46
58
|
export function cleanState(init, runner = beforeEach) {
|
|
47
|
-
|
|
48
|
-
runner(() => {
|
|
49
|
-
Object.assign(state, init());
|
|
50
|
-
});
|
|
51
|
-
return state;
|
|
59
|
+
return state.cleanState(init, runner);
|
|
52
60
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TestResult, TestSummary } from "./scope.js";
|
|
2
|
+
export declare function execute(cases?: import("./scope.js").TestCase): Promise<TestResult>;
|
|
3
|
+
export declare function getError({ error }: TestResult): number | TestResult | TestSummary | "unknown error";
|
|
4
|
+
export interface FlatResult {
|
|
5
|
+
test: string;
|
|
6
|
+
stack?: string | number | TestResult | TestSummary;
|
|
7
|
+
stats: {
|
|
8
|
+
executed: number;
|
|
9
|
+
failed: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function flattenResults(results: TestResult, prefix?: string): FlatResult[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterall, aftereach, beforeall, beforeeach, rootCases, } from "./describe.js";
|
|
2
|
-
export async function execute(
|
|
2
|
+
export async function execute(cases = rootCases()) {
|
|
3
3
|
const beforeallfn = cases[beforeall] ?? (() => { });
|
|
4
4
|
const beforeeachfn = cases[beforeeach] ?? (() => { });
|
|
5
5
|
const afterallfn = cases[afterall] ?? (() => { });
|
|
@@ -31,7 +31,7 @@ export async function execute(prefix = "", cases = rootCases()) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
else if (block) {
|
|
34
|
-
const run = await execute(
|
|
34
|
+
const run = await execute(block);
|
|
35
35
|
result.executed += run.executed;
|
|
36
36
|
result.passed += run.passed;
|
|
37
37
|
result.failed += run.failed;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class Matcher<T> {
|
|
2
|
+
actual: T;
|
|
3
|
+
constructor(actual: T);
|
|
4
|
+
get not(): Matcher<T>;
|
|
5
|
+
toBe(expected: T): void;
|
|
6
|
+
toEqual(expected: T, partial?: boolean): void;
|
|
7
|
+
toMatch(expected: RegExp | string): void;
|
|
8
|
+
toMatchObject(expected: Partial<T>): void;
|
|
9
|
+
toBeNull(): void;
|
|
10
|
+
toThrow(message?: string): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class NotMatcher<T> {
|
|
13
|
+
actual: T;
|
|
14
|
+
constructor(actual: T);
|
|
15
|
+
get not(): Matcher<T>;
|
|
16
|
+
toBe(expected: T): void;
|
|
17
|
+
toEqual(expected: T): void;
|
|
18
|
+
toMatch(expected: RegExp | string): void;
|
|
19
|
+
toMatchObject(expected: Partial<T>): void;
|
|
20
|
+
toBeNull(): void;
|
|
21
|
+
toThrow(message?: string): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function expect<T>(t: T): Matcher<T>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface TestCase {
|
|
2
|
+
[k: string]: Function | TestCase;
|
|
3
|
+
[k: symbol]: Function;
|
|
4
|
+
}
|
|
5
|
+
export interface TestResult {
|
|
6
|
+
executed: number;
|
|
7
|
+
passed: number;
|
|
8
|
+
failed: number;
|
|
9
|
+
[k: string]: TestResult | TestSummary | number;
|
|
10
|
+
}
|
|
11
|
+
export declare type TestSummary = TestFailed | TestPassed;
|
|
12
|
+
export interface TestFailed {
|
|
13
|
+
error: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface TestPassed {
|
|
16
|
+
passed: true;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cleanState<State extends {}>(init: () => State, runner: (action: () => void) => void): State;
|
|
File without changes
|