diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b3d16f0..00c3532 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -63,38 +63,23 @@ check:lint:
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
when: manual
-check:test-generate:
+check:test:
stage: check
needs: []
script:
- >
nix-shell --arg ci true --run $'
- ./scripts/check-test-generate.sh > ./tmp/check-test.yml;
+ npm test -- --ci --coverage;
'
artifacts:
when: always
- paths:
- - ./tmp/check-test.yml
- rules:
- # Runs on feature commits and ignores version commits
- - if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
- # Manually run on commits other than master and staging and ignore version commits
- - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
- when: manual
-
-check:test:
- stage: check
- needs:
- - check:test-generate
- trigger:
- include:
- - artifact: tmp/check-test.yml
- job: check:test-generate
- strategy: depend
- inherit:
- variables: false
- variables:
- PARENT_PIPELINE_ID: $CI_PIPELINE_ID
+ reports:
+ junit:
+ - ./tmp/junit/junit.xml
+ coverage_report:
+ coverage_format: cobertura
+ path: ./tmp/coverage/cobertura-coverage.xml
+ coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on feature commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -148,37 +133,79 @@ build:dist:
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
-build:platforms-generate:
+build:linux:
stage: build
needs: []
script:
- >
nix-shell --arg ci true --run $'
- ./scripts/build-platforms-generate.sh > ./tmp/build-platforms.yml;
+ npm test -- --ci --coverage;
'
artifacts:
when: always
- paths:
- - ./tmp/build-platforms.yml
+ reports:
+ junit:
+ - ./tmp/junit/junit.xml
+ coverage_report:
+ coverage_format: cobertura
+ path: ./tmp/coverage/cobertura-coverage.xml
+ coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
-build:platforms:
+build:windows:
stage: build
- needs:
- - build:platforms-generate
- trigger:
- include:
- - artifact: tmp/build-platforms.yml
- job: build:platforms-generate
- strategy: depend
- inherit:
- variables: false
- variables:
- PARENT_PIPELINE_ID: $CI_PIPELINE_ID
+ needs: []
+ tags:
+ - windows
+ before_script:
+ - mkdir -Force "$CI_PROJECT_DIR/tmp"
+ script:
+ - .\scripts\choco-install.ps1
+ - refreshenv
+ - npm install --ignore-scripts
+ - $env:Path = "$(npm root)\.bin;" + $env:Path
+ - npm test -- --ci --coverage
+ artifacts:
+ when: always
+ reports:
+ junit:
+ - ./tmp/junit/junit.xml
+ coverage_report:
+ coverage_format: cobertura
+ path: ./tmp/coverage/cobertura-coverage.xml
+ coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
+ rules:
+ # Runs on staging commits and ignores version commits
+ - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
+ # Runs on tag pipeline where the tag is a prerelease or release version
+ - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
+
+build:macos:
+ stage: build
+ needs: []
+ tags:
+ - saas-macos-medium-m1
+ image: macos-12-xcode-14
+ script:
+ - eval "$(brew shellenv)"
+ - ./scripts/brew-install.sh
+ - hash -r
+ - npm install --ignore-scripts
+ - export PATH="$(npm root)/.bin:$PATH"
+ - npm test -- --ci --coverage
+ artifacts:
+ when: always
+ reports:
+ junit:
+ - ./tmp/junit/junit.xml
+ coverage_report:
+ coverage_format: cobertura
+ path: ./tmp/coverage/cobertura-coverage.xml
+ coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -189,7 +216,9 @@ build:prerelease:
stage: build
needs:
- build:dist
- - build:platforms
+ - build:linux
+ - build:windows
+ - build:macos
# Don't interrupt publishing job
interruptible: false
script:
@@ -212,7 +241,11 @@ integration:merge:
stage: integration
needs:
- build:merge
- - job: build:platforms
+ - job: build:linux
+ optional: true
+ - job: build:windows
+ optional: true
+ - job: build:macos
optional: true
# Requires mutual exclusion
resource_group: integration:merge
@@ -245,12 +278,12 @@ release:distribution:
stage: release
needs:
- build:dist
- - build:platforms
+ - build:linux
+ - build:windows
+ - build:macos
- integration:merge
# Don't interrupt publishing job
interruptible: false
- # Requires mutual exclusion
- resource_group: release:distribution
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
- echo 'Publishing library'
diff --git a/docs/assets/search.js b/docs/assets/search.js
index fa04c57..7790d85 100644
--- a/docs/assets/search.js
+++ b/docs/assets/search.js
@@ -1 +1 @@
-window.searchData = JSON.parse("{\"kinds\":{\"4\":\"Namespace\",\"32\":\"Variable\",\"64\":\"Function\",\"128\":\"Class\",\"1024\":\"Property\",\"65536\":\"Type literal\",\"4194304\":\"Type alias\"},\"rows\":[{\"kind\":4,\"name\":\"decorators\",\"url\":\"modules/decorators.html\",\"classes\":\"tsd-kind-namespace\"},{\"kind\":64,\"name\":\"context\",\"url\":\"functions/decorators.context.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"decorators\"},{\"kind\":64,\"name\":\"cancellable\",\"url\":\"functions/decorators.cancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"decorators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/decorators.cancellable.html#cancellable.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"decorators.cancellable.cancellable\"},{\"kind\":64,\"name\":\"timed\",\"url\":\"functions/decorators.timed.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"decorators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/decorators.timed.html#timed.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"decorators.timed.timed\"},{\"kind\":64,\"name\":\"timedCancellable\",\"url\":\"functions/decorators.timedCancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"decorators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/decorators.timedCancellable.html#timedCancellable.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"decorators.timedCancellable.timedCancellable\"},{\"kind\":4,\"name\":\"functions\",\"url\":\"modules/functions.html\",\"classes\":\"tsd-kind-namespace\"},{\"kind\":64,\"name\":\"cancellable\",\"url\":\"functions/functions.cancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"functions\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/functions.cancellable.html#cancellable.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"functions.cancellable.cancellable\"},{\"kind\":64,\"name\":\"timed\",\"url\":\"functions/functions.timed.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"functions\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/functions.timed.html#timed.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"functions.timed.timed\"},{\"kind\":64,\"name\":\"timedCancellable\",\"url\":\"functions/functions.timedCancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"functions\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/functions.timedCancellable.html#timedCancellable.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"functions.timedCancellable.timedCancellable\"},{\"kind\":4,\"name\":\"utils\",\"url\":\"modules/utils.html\",\"classes\":\"tsd-kind-namespace\"},{\"kind\":32,\"name\":\"AsyncFunction\",\"url\":\"variables/utils.AsyncFunction.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":32,\"name\":\"GeneratorFunction\",\"url\":\"variables/utils.GeneratorFunction.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":32,\"name\":\"AsyncGeneratorFunction\",\"url\":\"variables/utils.AsyncGeneratorFunction.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":32,\"name\":\"contexts\",\"url\":\"variables/utils.contexts.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"getContextIndex\",\"url\":\"functions/utils.getContextIndex.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"checkContextCancellable\",\"url\":\"functions/utils.checkContextCancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"checkContextTimed\",\"url\":\"functions/utils.checkContextTimed.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"isPromiseLike\",\"url\":\"functions/utils.isPromiseLike.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"isGenerator\",\"url\":\"functions/utils.isGenerator.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"isAsyncGenerator\",\"url\":\"functions/utils.isAsyncGenerator.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":4,\"name\":\"errors\",\"url\":\"modules/errors.html\",\"classes\":\"tsd-kind-namespace\"},{\"kind\":128,\"name\":\"ErrorContexts\",\"url\":\"classes/errors.ErrorContexts.html\",\"classes\":\"tsd-kind-class tsd-parent-kind-namespace\",\"parent\":\"errors\"},{\"kind\":1024,\"name\":\"description\",\"url\":\"classes/errors.ErrorContexts.html#description\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"errors.ErrorContexts\"},{\"kind\":128,\"name\":\"ErrorContextsTimedTimeOut\",\"url\":\"classes/errors.ErrorContextsTimedTimeOut.html\",\"classes\":\"tsd-kind-class tsd-parent-kind-namespace\",\"parent\":\"errors\"},{\"kind\":1024,\"name\":\"description\",\"url\":\"classes/errors.ErrorContextsTimedTimeOut.html#description\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"errors.ErrorContextsTimedTimeOut\"},{\"kind\":4194304,\"name\":\"ContextCancellable\",\"url\":\"types/ContextCancellable.html\",\"classes\":\"tsd-kind-type-alias\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/ContextCancellable.html#__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"ContextCancellable\"},{\"kind\":1024,\"name\":\"signal\",\"url\":\"types/ContextCancellable.html#__type.signal\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"ContextCancellable.__type\"},{\"kind\":4194304,\"name\":\"ContextTimed\",\"url\":\"types/ContextTimed.html\",\"classes\":\"tsd-kind-type-alias\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,31.781]],[\"comment/0\",[]],[\"name/1\",[1,31.781]],[\"comment/1\",[]],[\"name/2\",[2,26.672]],[\"comment/2\",[]],[\"name/3\",[3,15.686]],[\"comment/3\",[]],[\"name/4\",[4,26.672]],[\"comment/4\",[]],[\"name/5\",[3,15.686]],[\"comment/5\",[]],[\"name/6\",[5,26.672]],[\"comment/6\",[]],[\"name/7\",[3,15.686]],[\"comment/7\",[]],[\"name/8\",[6,31.781]],[\"comment/8\",[]],[\"name/9\",[2,26.672]],[\"comment/9\",[]],[\"name/10\",[3,15.686]],[\"comment/10\",[]],[\"name/11\",[4,26.672]],[\"comment/11\",[]],[\"name/12\",[3,15.686]],[\"comment/12\",[]],[\"name/13\",[5,26.672]],[\"comment/13\",[]],[\"name/14\",[3,15.686]],[\"comment/14\",[]],[\"name/15\",[7,31.781]],[\"comment/15\",[]],[\"name/16\",[8,31.781]],[\"comment/16\",[]],[\"name/17\",[9,31.781]],[\"comment/17\",[]],[\"name/18\",[10,31.781]],[\"comment/18\",[]],[\"name/19\",[11,31.781]],[\"comment/19\",[]],[\"name/20\",[12,31.781]],[\"comment/20\",[]],[\"name/21\",[13,31.781]],[\"comment/21\",[]],[\"name/22\",[14,31.781]],[\"comment/22\",[]],[\"name/23\",[15,31.781]],[\"comment/23\",[]],[\"name/24\",[16,31.781]],[\"comment/24\",[]],[\"name/25\",[17,31.781]],[\"comment/25\",[]],[\"name/26\",[18,31.781]],[\"comment/26\",[]],[\"name/27\",[19,31.781]],[\"comment/27\",[]],[\"name/28\",[20,26.672]],[\"comment/28\",[]],[\"name/29\",[21,31.781]],[\"comment/29\",[]],[\"name/30\",[20,26.672]],[\"comment/30\",[]],[\"name/31\",[22,31.781]],[\"comment/31\",[]],[\"name/32\",[3,15.686]],[\"comment/32\",[]],[\"name/33\",[23,31.781]],[\"comment/33\",[]],[\"name/34\",[24,31.781]],[\"comment/34\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":3,\"name\":{\"3\":{},\"5\":{},\"7\":{},\"10\":{},\"12\":{},\"14\":{},\"32\":{}},\"comment\":{}}],[\"asyncfunction\",{\"_index\":8,\"name\":{\"16\":{}},\"comment\":{}}],[\"asyncgeneratorfunction\",{\"_index\":10,\"name\":{\"18\":{}},\"comment\":{}}],[\"cancellable\",{\"_index\":2,\"name\":{\"2\":{},\"9\":{}},\"comment\":{}}],[\"checkcontextcancellable\",{\"_index\":13,\"name\":{\"21\":{}},\"comment\":{}}],[\"checkcontexttimed\",{\"_index\":14,\"name\":{\"22\":{}},\"comment\":{}}],[\"context\",{\"_index\":1,\"name\":{\"1\":{}},\"comment\":{}}],[\"contextcancellable\",{\"_index\":22,\"name\":{\"31\":{}},\"comment\":{}}],[\"contexts\",{\"_index\":11,\"name\":{\"19\":{}},\"comment\":{}}],[\"contexttimed\",{\"_index\":24,\"name\":{\"34\":{}},\"comment\":{}}],[\"decorators\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"description\",{\"_index\":20,\"name\":{\"28\":{},\"30\":{}},\"comment\":{}}],[\"errorcontexts\",{\"_index\":19,\"name\":{\"27\":{}},\"comment\":{}}],[\"errorcontextstimedtimeout\",{\"_index\":21,\"name\":{\"29\":{}},\"comment\":{}}],[\"errors\",{\"_index\":18,\"name\":{\"26\":{}},\"comment\":{}}],[\"functions\",{\"_index\":6,\"name\":{\"8\":{}},\"comment\":{}}],[\"generatorfunction\",{\"_index\":9,\"name\":{\"17\":{}},\"comment\":{}}],[\"getcontextindex\",{\"_index\":12,\"name\":{\"20\":{}},\"comment\":{}}],[\"isasyncgenerator\",{\"_index\":17,\"name\":{\"25\":{}},\"comment\":{}}],[\"isgenerator\",{\"_index\":16,\"name\":{\"24\":{}},\"comment\":{}}],[\"ispromiselike\",{\"_index\":15,\"name\":{\"23\":{}},\"comment\":{}}],[\"signal\",{\"_index\":23,\"name\":{\"33\":{}},\"comment\":{}}],[\"timed\",{\"_index\":4,\"name\":{\"4\":{},\"11\":{}},\"comment\":{}}],[\"timedcancellable\",{\"_index\":5,\"name\":{\"6\":{},\"13\":{}},\"comment\":{}}],[\"utils\",{\"_index\":7,\"name\":{\"15\":{}},\"comment\":{}}]],\"pipeline\":[]}}");
\ No newline at end of file
+window.searchData = JSON.parse("{\"kinds\":{\"4\":\"Namespace\",\"32\":\"Variable\",\"64\":\"Function\",\"128\":\"Class\",\"1024\":\"Property\",\"65536\":\"Type literal\",\"4194304\":\"Type alias\"},\"rows\":[{\"kind\":4,\"name\":\"decorators\",\"url\":\"modules/decorators.html\",\"classes\":\"tsd-kind-namespace\"},{\"kind\":64,\"name\":\"context\",\"url\":\"functions/decorators.context.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"decorators\"},{\"kind\":64,\"name\":\"cancellable\",\"url\":\"functions/decorators.cancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"decorators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/decorators.cancellable.html#cancellable.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"decorators.cancellable.cancellable\"},{\"kind\":64,\"name\":\"timed\",\"url\":\"functions/decorators.timed.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"decorators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/decorators.timed.html#timed.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"decorators.timed.timed\"},{\"kind\":64,\"name\":\"timedCancellable\",\"url\":\"functions/decorators.timedCancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"decorators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/decorators.timedCancellable.html#timedCancellable.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"decorators.timedCancellable.timedCancellable\"},{\"kind\":4,\"name\":\"functions\",\"url\":\"modules/functions.html\",\"classes\":\"tsd-kind-namespace\"},{\"kind\":64,\"name\":\"cancellable\",\"url\":\"functions/functions.cancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"functions\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/functions.cancellable.html#cancellable.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"functions.cancellable.cancellable\"},{\"kind\":64,\"name\":\"timed\",\"url\":\"functions/functions.timed.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"functions\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/functions.timed.html#timed.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"functions.timed.timed\"},{\"kind\":64,\"name\":\"timedCancellable\",\"url\":\"functions/functions.timedCancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"functions\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/functions.timedCancellable.html#timedCancellable.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"functions.timedCancellable.timedCancellable\"},{\"kind\":4,\"name\":\"utils\",\"url\":\"modules/utils.html\",\"classes\":\"tsd-kind-namespace\"},{\"kind\":32,\"name\":\"AsyncFunction\",\"url\":\"variables/utils.AsyncFunction.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":32,\"name\":\"GeneratorFunction\",\"url\":\"variables/utils.GeneratorFunction.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":32,\"name\":\"AsyncGeneratorFunction\",\"url\":\"variables/utils.AsyncGeneratorFunction.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":32,\"name\":\"contexts\",\"url\":\"variables/utils.contexts.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"getContextIndex\",\"url\":\"functions/utils.getContextIndex.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"checkContextCancellable\",\"url\":\"functions/utils.checkContextCancellable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"checkContextTimed\",\"url\":\"functions/utils.checkContextTimed.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"timer\",\"url\":\"functions/utils.timer.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"isPromiseLike\",\"url\":\"functions/utils.isPromiseLike.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"isGenerator\",\"url\":\"functions/utils.isGenerator.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"isAsyncGenerator\",\"url\":\"functions/utils.isAsyncGenerator.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-namespace\",\"parent\":\"utils\"},{\"kind\":4,\"name\":\"errors\",\"url\":\"modules/errors.html\",\"classes\":\"tsd-kind-namespace\"},{\"kind\":128,\"name\":\"ErrorContexts\",\"url\":\"classes/errors.ErrorContexts.html\",\"classes\":\"tsd-kind-class tsd-parent-kind-namespace\",\"parent\":\"errors\"},{\"kind\":1024,\"name\":\"description\",\"url\":\"classes/errors.ErrorContexts.html#description\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"errors.ErrorContexts\"},{\"kind\":128,\"name\":\"ErrorContextsTimedTimeOut\",\"url\":\"classes/errors.ErrorContextsTimedTimeOut.html\",\"classes\":\"tsd-kind-class tsd-parent-kind-namespace\",\"parent\":\"errors\"},{\"kind\":1024,\"name\":\"description\",\"url\":\"classes/errors.ErrorContextsTimedTimeOut.html#description\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"errors.ErrorContextsTimedTimeOut\"},{\"kind\":4194304,\"name\":\"ContextCancellable\",\"url\":\"types/ContextCancellable.html\",\"classes\":\"tsd-kind-type-alias\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/ContextCancellable.html#__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"ContextCancellable\"},{\"kind\":1024,\"name\":\"signal\",\"url\":\"types/ContextCancellable.html#__type.signal\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"ContextCancellable.__type\"},{\"kind\":4194304,\"name\":\"ContextTimed\",\"url\":\"types/ContextTimed.html\",\"classes\":\"tsd-kind-type-alias\"},{\"kind\":4194304,\"name\":\"ContextTimedInput\",\"url\":\"types/ContextTimedInput.html\",\"classes\":\"tsd-kind-type-alias\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,32.321]],[\"comment/0\",[]],[\"name/1\",[1,32.321]],[\"comment/1\",[]],[\"name/2\",[2,27.213]],[\"comment/2\",[]],[\"name/3\",[3,16.227]],[\"comment/3\",[]],[\"name/4\",[4,27.213]],[\"comment/4\",[]],[\"name/5\",[3,16.227]],[\"comment/5\",[]],[\"name/6\",[5,27.213]],[\"comment/6\",[]],[\"name/7\",[3,16.227]],[\"comment/7\",[]],[\"name/8\",[6,32.321]],[\"comment/8\",[]],[\"name/9\",[2,27.213]],[\"comment/9\",[]],[\"name/10\",[3,16.227]],[\"comment/10\",[]],[\"name/11\",[4,27.213]],[\"comment/11\",[]],[\"name/12\",[3,16.227]],[\"comment/12\",[]],[\"name/13\",[5,27.213]],[\"comment/13\",[]],[\"name/14\",[3,16.227]],[\"comment/14\",[]],[\"name/15\",[7,32.321]],[\"comment/15\",[]],[\"name/16\",[8,32.321]],[\"comment/16\",[]],[\"name/17\",[9,32.321]],[\"comment/17\",[]],[\"name/18\",[10,32.321]],[\"comment/18\",[]],[\"name/19\",[11,32.321]],[\"comment/19\",[]],[\"name/20\",[12,32.321]],[\"comment/20\",[]],[\"name/21\",[13,32.321]],[\"comment/21\",[]],[\"name/22\",[14,32.321]],[\"comment/22\",[]],[\"name/23\",[15,32.321]],[\"comment/23\",[]],[\"name/24\",[16,32.321]],[\"comment/24\",[]],[\"name/25\",[17,32.321]],[\"comment/25\",[]],[\"name/26\",[18,32.321]],[\"comment/26\",[]],[\"name/27\",[19,32.321]],[\"comment/27\",[]],[\"name/28\",[20,32.321]],[\"comment/28\",[]],[\"name/29\",[21,27.213]],[\"comment/29\",[]],[\"name/30\",[22,32.321]],[\"comment/30\",[]],[\"name/31\",[21,27.213]],[\"comment/31\",[]],[\"name/32\",[23,32.321]],[\"comment/32\",[]],[\"name/33\",[3,16.227]],[\"comment/33\",[]],[\"name/34\",[24,32.321]],[\"comment/34\",[]],[\"name/35\",[25,32.321]],[\"comment/35\",[]],[\"name/36\",[26,32.321]],[\"comment/36\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":3,\"name\":{\"3\":{},\"5\":{},\"7\":{},\"10\":{},\"12\":{},\"14\":{},\"33\":{}},\"comment\":{}}],[\"asyncfunction\",{\"_index\":8,\"name\":{\"16\":{}},\"comment\":{}}],[\"asyncgeneratorfunction\",{\"_index\":10,\"name\":{\"18\":{}},\"comment\":{}}],[\"cancellable\",{\"_index\":2,\"name\":{\"2\":{},\"9\":{}},\"comment\":{}}],[\"checkcontextcancellable\",{\"_index\":13,\"name\":{\"21\":{}},\"comment\":{}}],[\"checkcontexttimed\",{\"_index\":14,\"name\":{\"22\":{}},\"comment\":{}}],[\"context\",{\"_index\":1,\"name\":{\"1\":{}},\"comment\":{}}],[\"contextcancellable\",{\"_index\":23,\"name\":{\"32\":{}},\"comment\":{}}],[\"contexts\",{\"_index\":11,\"name\":{\"19\":{}},\"comment\":{}}],[\"contexttimed\",{\"_index\":25,\"name\":{\"35\":{}},\"comment\":{}}],[\"contexttimedinput\",{\"_index\":26,\"name\":{\"36\":{}},\"comment\":{}}],[\"decorators\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"description\",{\"_index\":21,\"name\":{\"29\":{},\"31\":{}},\"comment\":{}}],[\"errorcontexts\",{\"_index\":20,\"name\":{\"28\":{}},\"comment\":{}}],[\"errorcontextstimedtimeout\",{\"_index\":22,\"name\":{\"30\":{}},\"comment\":{}}],[\"errors\",{\"_index\":19,\"name\":{\"27\":{}},\"comment\":{}}],[\"functions\",{\"_index\":6,\"name\":{\"8\":{}},\"comment\":{}}],[\"generatorfunction\",{\"_index\":9,\"name\":{\"17\":{}},\"comment\":{}}],[\"getcontextindex\",{\"_index\":12,\"name\":{\"20\":{}},\"comment\":{}}],[\"isasyncgenerator\",{\"_index\":18,\"name\":{\"26\":{}},\"comment\":{}}],[\"isgenerator\",{\"_index\":17,\"name\":{\"25\":{}},\"comment\":{}}],[\"ispromiselike\",{\"_index\":16,\"name\":{\"24\":{}},\"comment\":{}}],[\"signal\",{\"_index\":24,\"name\":{\"34\":{}},\"comment\":{}}],[\"timed\",{\"_index\":4,\"name\":{\"4\":{},\"11\":{}},\"comment\":{}}],[\"timedcancellable\",{\"_index\":5,\"name\":{\"6\":{},\"13\":{}},\"comment\":{}}],[\"timer\",{\"_index\":15,\"name\":{\"23\":{}},\"comment\":{}}],[\"utils\",{\"_index\":7,\"name\":{\"15\":{}},\"comment\":{}}]],\"pipeline\":[]}}");
\ No newline at end of file
diff --git a/docs/classes/errors.ErrorContexts.html b/docs/classes/errors.ErrorContexts.html
index ee25cc0..79ad779 100644
--- a/docs/classes/errors.ErrorContexts.html
+++ b/docs/classes/errors.ErrorContexts.html
@@ -1,4 +1,4 @@
-
ErrorContexts | @matrixai/js-contexts
@@ -31,7 +31,7 @@
key: string string
Returns number
+Defined in src/utils.ts:11
\ No newline at end of file
diff --git a/docs/functions/utils.isAsyncGenerator.html b/docs/functions/utils.isAsyncGenerator.html
index 9570937..f33dcce 100644
--- a/docs/functions/utils.isAsyncGenerator.html
+++ b/docs/functions/utils.isAsyncGenerator.html
@@ -1,4 +1,4 @@
-isAsyncGenerator | @matrixai/js-contexts
+isAsyncGenerator | @matrixai/contexts
Function isAsyncGenerator
@@ -30,7 +30,7 @@
Parameters
v: any
Returns v is AsyncGenerator < unknown , any , unknown >
+Defined in src/utils.ts:122
\ No newline at end of file
diff --git a/docs/functions/utils.isGenerator.html b/docs/functions/utils.isGenerator.html
index de83f7b..8697ed9 100644
--- a/docs/functions/utils.isGenerator.html
+++ b/docs/functions/utils.isGenerator.html
@@ -1,4 +1,4 @@
-isGenerator | @matrixai/js-contexts
+isGenerator | @matrixai/contexts
@@ -30,7 +30,7 @@
Parameters
v: any
Returns v is Generator < unknown , any , unknown >
+Defined in src/utils.ts:108
\ No newline at end of file
diff --git a/docs/functions/utils.isPromiseLike.html b/docs/functions/utils.isPromiseLike.html
index af3fd24..7738d23 100644
--- a/docs/functions/utils.isPromiseLike.html
+++ b/docs/functions/utils.isPromiseLike.html
@@ -1,4 +1,4 @@
-isPromiseLike | @matrixai/js-contexts
+isPromiseLike | @matrixai/contexts
@@ -27,7 +27,7 @@
Parameters
v: any
Returns v is PromiseLike < unknown >
+Defined in src/utils.ts:100
\ No newline at end of file
diff --git a/docs/functions/utils.timer.html b/docs/functions/utils.timer.html
new file mode 100644
index 0000000..ced7504
--- /dev/null
+++ b/docs/functions/utils.timer.html
@@ -0,0 +1,85 @@
+timer | @matrixai/contexts
+
+
+
+
+
+timer< T > ( handlerOrOpts?: { Â Â Â Â controller?: PromiseCancellableController ; Â Â Â Â delay?: number ; Â Â Â Â handler?: ( ( signal: AbortSignal ) => T | PromiseLike < T > ) ; Â Â Â Â lazy?: boolean ; } | ( ( signal: AbortSignal ) => T | PromiseLike < T > ) , delay?: number , lazy?: boolean , controller?: PromiseCancellableController ) : ResourceAcquire < Timer < T > >
+
+
+
+
+
Parameters
+
+
+Optional
handlerOrOpts: { Â Â Â Â controller?: PromiseCancellableController ; Â Â Â Â delay?: number ; Â Â Â Â handler?: ( ( signal: AbortSignal ) => T | PromiseLike < T > ) ; Â Â Â Â lazy?: boolean ; } | ( ( signal: AbortSignal ) => T | PromiseLike < T > )
+
+delay: number = 0
+
+lazy: boolean = false
+
+Optional
controller: PromiseCancellableController
+Returns ResourceAcquire < Timer < T > >
+
+
+
\ No newline at end of file
diff --git a/docs/index.html b/docs/index.html
index bc52f8b..e1cd94f 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1,4 +1,4 @@
-@matrixai/js-contexts
+@matrixai/contexts
-
@matrixai/js-contexts
+
@matrixai/contexts
+
Context Timed
+
Context Timed Input
\ No newline at end of file
diff --git a/docs/modules.html b/docs/modules.html
index 8835c1e..e2a11d6 100644
--- a/docs/modules.html
+++ b/docs/modules.html
@@ -1,4 +1,4 @@
-@matrixai/js-contexts
+@matrixai/contexts
-
@matrixai/js-contexts
+
@matrixai/contexts
Index
@@ -26,6 +26,7 @@ Namespaces
Type Aliases
\ No newline at end of file
diff --git a/docs/modules/decorators.html b/docs/modules/decorators.html
index 3048afe..8a48f58 100644
--- a/docs/modules/decorators.html
+++ b/docs/modules/decorators.html
@@ -1,4 +1,4 @@
-decorators | @matrixai/js-contexts
+decorators | @matrixai/contexts
@@ -46,7 +46,7 @@ Theme OS Modules
@@ -44,7 +44,7 @@ Theme OS Modules
-@matrixai/js- contexts
+@matrixai/contexts
decorators
errors
diff --git a/docs/modules/functions.html b/docs/modules/functions.html
index b0d10de..7a1acb2 100644
--- a/docs/modules/functions.html
+++ b/docs/modules/functions.html
@@ -1,4 +1,4 @@
-functions | @matrixai/js-contexts
+functions | @matrixai/contexts
+The search index is not available @matrixai/contexts
@@ -45,7 +45,7 @@ Theme OS Modules
\ No newline at end of file
diff --git a/docs/types/ContextCancellable.html b/docs/types/ContextCancellable.html
index 69c0583..f607bc8 100644
--- a/docs/types/ContextCancellable.html
+++ b/docs/types/ContextCancellable.html
@@ -1,4 +1,4 @@
-
ContextCancellable | @matrixai/js-contexts
+ContextCancellable | @matrixai/contexts
Type alias ContextCancellable
Context Cancellable: { Â Â Â Â signal: AbortSignal ; }
@@ -42,7 +42,7 @@
Theme OS Modules
+
Context Timed
+
Context Timed Input
\ No newline at end of file
diff --git a/docs/types/ContextTimed.html b/docs/types/ContextTimed.html
index c076794..db84b19 100644
--- a/docs/types/ContextTimed.html
+++ b/docs/types/ContextTimed.html
@@ -1,4 +1,4 @@
-ContextTimed | @matrixai/js-contexts
+ContextTimed | @matrixai/contexts
@@ -37,7 +37,7 @@ Theme OS Modules
+
Context Timed
+
Context Timed Input
\ No newline at end of file
diff --git a/docs/types/ContextTimedInput.html b/docs/types/ContextTimedInput.html
new file mode 100644
index 0000000..4916e06
--- /dev/null
+++ b/docs/types/ContextTimedInput.html
@@ -0,0 +1,53 @@
+ContextTimedInput | @matrixai/contexts
+
+
+
+
+
Type alias ContextTimedInput
+
+
+
+
\ No newline at end of file
diff --git a/docs/variables/utils.AsyncFunction.html b/docs/variables/utils.AsyncFunction.html
index af4188d..b278504 100644
--- a/docs/variables/utils.AsyncFunction.html
+++ b/docs/variables/utils.AsyncFunction.html
@@ -1,4 +1,4 @@
-AsyncFunction | @matrixai/js-contexts
+AsyncFunction | @matrixai/contexts
Variable AsyncFunctionConst
Async Function: Function = ...
+
Defined in src/utils.ts:5
\ No newline at end of file
diff --git a/docs/variables/utils.AsyncGeneratorFunction.html b/docs/variables/utils.AsyncGeneratorFunction.html
index a515dc9..ca22788 100644
--- a/docs/variables/utils.AsyncGeneratorFunction.html
+++ b/docs/variables/utils.AsyncGeneratorFunction.html
@@ -1,4 +1,4 @@
-AsyncGeneratorFunction | @matrixai/js-contexts
+AsyncGeneratorFunction | @matrixai/contexts
Variable AsyncGeneratorFunctionConst
Async Generator Function: Function = ...
+
Defined in src/utils.ts:7
\ No newline at end of file
diff --git a/docs/variables/utils.GeneratorFunction.html b/docs/variables/utils.GeneratorFunction.html
index 91abcfb..b07cec8 100644
--- a/docs/variables/utils.GeneratorFunction.html
+++ b/docs/variables/utils.GeneratorFunction.html
@@ -1,4 +1,4 @@
-GeneratorFunction | @matrixai/js-contexts
+GeneratorFunction | @matrixai/contexts
Variable GeneratorFunctionConst
Generator Function: Function = ...
+
Defined in src/utils.ts:6
\ No newline at end of file
diff --git a/docs/variables/utils.contexts.html b/docs/variables/utils.contexts.html
index c6a712c..a19652a 100644
--- a/docs/variables/utils.contexts.html
+++ b/docs/variables/utils.contexts.html
@@ -1,4 +1,4 @@
-contexts | @matrixai/js-contexts
+contexts | @matrixai/contexts
contexts: WeakMap < object , number > = ...
+
Defined in src/utils.ts:9
\ No newline at end of file
diff --git a/jest.config.js b/jest.config.js
index 90406f0..58d32f3 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -33,8 +33,21 @@ module.exports = {
roots: ['/tests'],
testMatch: ['**/?(*.)+(spec|test|unit.test).+(ts|tsx|js|jsx)'],
transform: {
- '^.+\\.tsx?$': 'ts-jest',
- '^.+\\.jsx?$': 'babel-jest',
+ "^.+\\.(t|j)sx?$": [
+ "@swc/jest",
+ {
+ jsc: {
+ parser: {
+ syntax: "typescript",
+ tsx: true,
+ decorators: compilerOptions.experimentalDecorators,
+ dynamicImport: true,
+ },
+ target: compilerOptions.target.toLowerCase(),
+ keepClassNames: true,
+ },
+ }
+ ],
},
reporters: [
'default',
diff --git a/package-lock.json b/package-lock.json
index f286516..ec2d343 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,22 +1,25 @@
{
"name": "@matrixai/contexts",
- "version": "1.0.0",
+ "version": "1.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@matrixai/contexts",
- "version": "1.0.0",
+ "version": "1.1.0",
"license": "Apache-2.0",
"dependencies": {
- "@matrixai/async-cancellable": "^1.0.6",
+ "@matrixai/async-cancellable": "^1.1.1",
+ "@matrixai/async-locks": "^4.0.0",
"@matrixai/errors": "^1.1.7",
- "@matrixai/timer": "^1.1.0"
+ "@matrixai/resources": "^1.1.5",
+ "@matrixai/timer": "^1.1.1"
},
"devDependencies": {
- "@swc/core": "^1.2.215",
+ "@swc/core": "^1.3.62",
+ "@swc/jest": "^0.2.26",
"@types/jest": "^28.1.3",
- "@types/node": "^18.11.11",
+ "@types/node": "^18.15.0",
"@typescript-eslint/eslint-plugin": "^5.45.1",
"@typescript-eslint/parser": "^5.45.1",
"eslint": "^8.15.0",
@@ -883,6 +886,43 @@
}
}
},
+ "node_modules/@jest/create-cache-key-function": {
+ "version": "27.5.1",
+ "resolved": "https://registry.npmjs.org/@jest/create-cache-key-function/-/create-cache-key-function-27.5.1.tgz",
+ "integrity": "sha512-dmH1yW+makpTSURTy8VzdUwFnfQh1G8R+DxO2Ho2FFmBbKFEVm+3jWdvFhE2VqB/LATCTokkP0dotjyQyw5/AQ==",
+ "dev": true,
+ "dependencies": {
+ "@jest/types": "^27.5.1"
+ },
+ "engines": {
+ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
+ }
+ },
+ "node_modules/@jest/create-cache-key-function/node_modules/@jest/types": {
+ "version": "27.5.1",
+ "resolved": "https://registry.npmjs.org/@jest/types/-/types-27.5.1.tgz",
+ "integrity": "sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==",
+ "dev": true,
+ "dependencies": {
+ "@types/istanbul-lib-coverage": "^2.0.0",
+ "@types/istanbul-reports": "^3.0.0",
+ "@types/node": "*",
+ "@types/yargs": "^16.0.0",
+ "chalk": "^4.0.0"
+ },
+ "engines": {
+ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
+ }
+ },
+ "node_modules/@jest/create-cache-key-function/node_modules/@types/yargs": {
+ "version": "16.0.5",
+ "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.5.tgz",
+ "integrity": "sha512-AxO/ADJOBFJScHbWhq2xAhlWP24rY4aCEG/NFaMvbT3X2MgRsLjhjQwsn0Zi5zn0LG9jUhCCZMeX9Dkuw6k+vQ==",
+ "dev": true,
+ "dependencies": {
+ "@types/yargs-parser": "*"
+ }
+ },
"node_modules/@jest/environment": {
"version": "28.1.3",
"resolved": "https://registry.npmjs.org/@jest/environment/-/environment-28.1.3.tgz",
@@ -1145,9 +1185,20 @@
}
},
"node_modules/@matrixai/async-cancellable": {
- "version": "1.0.6",
- "resolved": "https://registry.npmjs.org/@matrixai/async-cancellable/-/async-cancellable-1.0.6.tgz",
- "integrity": "sha512-DurgNGfIV/u11J94Ry5G/y2JPqKZEQdG4e0jzw/STl1MxC1D0bxKREvboKJP+fGBk4CihhU9G9iEPyaCBgM9lA=="
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@matrixai/async-cancellable/-/async-cancellable-1.1.1.tgz",
+ "integrity": "sha512-f0yxu7dHwvffZ++7aCm2WIcCJn18uLcOTdCCwEA3R3KVHYE3TG/JNoTWD9/mqBkAV1AI5vBfJzg27WnF9rOUXQ=="
+ },
+ "node_modules/@matrixai/async-locks": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@matrixai/async-locks/-/async-locks-4.0.0.tgz",
+ "integrity": "sha512-u/3fOdtjOKcDYF8dDoPR1/+7nmOkhxo42eBpXTEgfI0hLPGI37PoW7tjLvwy+O51Quy1HGOwhsR/Dgr4x+euug==",
+ "dependencies": {
+ "@matrixai/async-cancellable": "^1.1.1",
+ "@matrixai/errors": "^1.1.7",
+ "@matrixai/resources": "^1.1.5",
+ "@matrixai/timer": "^1.1.1"
+ }
},
"node_modules/@matrixai/errors": {
"version": "1.1.7",
@@ -1157,12 +1208,18 @@
"ts-custom-error": "3.2.2"
}
},
+ "node_modules/@matrixai/resources": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/@matrixai/resources/-/resources-1.1.5.tgz",
+ "integrity": "sha512-m/DEZEe3wHqWEPTyoBtzFF6U9vWYhEnQtGgwvqiAlTxTM0rk96UBpWjDZCTF/vYG11ZlmlQFtg5H+zGgbjaB3Q=="
+ },
"node_modules/@matrixai/timer": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@matrixai/timer/-/timer-1.1.0.tgz",
- "integrity": "sha512-n9ulMGJhjQyu+fhRxvP5SwY57miOLbRE6gtIzTZD6x7wFL0k5sUBMnEQ6W4QkO1atZnxKMFigg4gt/0V4XlniA==",
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@matrixai/timer/-/timer-1.1.1.tgz",
+ "integrity": "sha512-8UKDoGuwKC6BvrY/yANJVH29v71wgQKH/tJlxMPohGxmzVUQO5+JeI4lUYVHTs2vq1AyKAWloF5fOig+I1dyGA==",
"dependencies": {
- "@matrixai/async-cancellable": "^1.0.4"
+ "@matrixai/async-cancellable": "^1.1.1",
+ "@matrixai/errors": "^1.1.7"
}
},
"node_modules/@nodelib/fs.scandir": {
@@ -1225,13 +1282,11 @@
}
},
"node_modules/@swc/core": {
- "version": "1.2.215",
- "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.215.tgz",
- "integrity": "sha512-Dm6q1wP4OvG5DOHC9JQC4wAjIH4Pz8K4MfVrluojD7epDN97j2md6/QbMaL5Zcu24SsAuib8BYF4j9VelLrvtw==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.66.tgz",
+ "integrity": "sha512-Hpf91kH5ly7fHkWnApwryTQryT+TO4kMMPH3WyciUSQOWLE3UuQz1PtETHQQk7PZ/b1QF0qQurJrgfBr5bSKUA==",
"dev": true,
- "bin": {
- "swcx": "run_swcx.js"
- },
+ "hasInstallScript": true,
"engines": {
"node": ">=10"
},
@@ -1240,57 +1295,30 @@
"url": "https://opencollective.com/swc"
},
"optionalDependencies": {
- "@swc/core-android-arm-eabi": "1.2.216",
- "@swc/core-android-arm64": "1.2.216",
- "@swc/core-darwin-arm64": "1.2.216",
- "@swc/core-darwin-x64": "1.2.216",
- "@swc/core-freebsd-x64": "1.2.216",
- "@swc/core-linux-arm-gnueabihf": "1.2.216",
- "@swc/core-linux-arm64-gnu": "1.2.216",
- "@swc/core-linux-arm64-musl": "1.2.216",
- "@swc/core-linux-x64-gnu": "1.2.216",
- "@swc/core-linux-x64-musl": "1.2.216",
- "@swc/core-win32-arm64-msvc": "1.2.216",
- "@swc/core-win32-ia32-msvc": "1.2.216",
- "@swc/core-win32-x64-msvc": "1.2.216"
- }
- },
- "node_modules/@swc/core-android-arm-eabi": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.216.tgz",
- "integrity": "sha512-V8iNfyaiNROZ+rfCzuoYBUYxlJ1yIkX3w0av54eCLigRktBDozUtYEbE0I/L9/WX3JDMKxMSt9cAjyMd8tmjyA==",
- "cpu": [
- "arm"
- ],
- "dev": true,
- "optional": true,
- "os": [
- "android"
- ],
- "engines": {
- "node": ">=10"
- }
- },
- "node_modules/@swc/core-android-arm64": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.216.tgz",
- "integrity": "sha512-4N2dq2JQQTVX1rLR7p/n1ag0T9N1oRp35H7yci2bFxWbLfVvb7qShathHsr2XzkBhgmtc32zWnPPDIzolrew2g==",
- "cpu": [
- "arm64"
- ],
- "dev": true,
- "optional": true,
- "os": [
- "android"
- ],
- "engines": {
- "node": ">=10"
+ "@swc/core-darwin-arm64": "1.3.66",
+ "@swc/core-darwin-x64": "1.3.66",
+ "@swc/core-linux-arm-gnueabihf": "1.3.66",
+ "@swc/core-linux-arm64-gnu": "1.3.66",
+ "@swc/core-linux-arm64-musl": "1.3.66",
+ "@swc/core-linux-x64-gnu": "1.3.66",
+ "@swc/core-linux-x64-musl": "1.3.66",
+ "@swc/core-win32-arm64-msvc": "1.3.66",
+ "@swc/core-win32-ia32-msvc": "1.3.66",
+ "@swc/core-win32-x64-msvc": "1.3.66"
+ },
+ "peerDependencies": {
+ "@swc/helpers": "^0.5.0"
+ },
+ "peerDependenciesMeta": {
+ "@swc/helpers": {
+ "optional": true
+ }
}
},
"node_modules/@swc/core-darwin-arm64": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.216.tgz",
- "integrity": "sha512-rCof/23rLM0UEjrGhD9pqv0o50c5FMC7YCJGr4GP98iu4pGb0kgDlfu5EAO8wpXG2tMut3OHiQSefCWbtlygPA==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.66.tgz",
+ "integrity": "sha512-UijJsvuLy73vxeVYEy7urIHksXS+3BdvJ9s9AY+bRMSQW483NO7RLp8g4FdTyJbRaN0BH15SQnY0dcjQBkVuHw==",
"cpu": [
"arm64"
],
@@ -1304,9 +1332,9 @@
}
},
"node_modules/@swc/core-darwin-x64": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.216.tgz",
- "integrity": "sha512-UarehjeGDxwfDmyR8egAVntkKitIe68v2NABQFBtnFdjt0vixWbrSKFsrFxOZZVIb+S2NTxdk3l4An5Nr0MK8A==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.66.tgz",
+ "integrity": "sha512-xGsHKvViQnwTNLF30Y/5OqWdnN6RsiyUI8awZXfz1sHcXCEaLe+v+WLQ+/E8sgw0YUkYVHzzfV/sAN2CezJK5Q==",
"cpu": [
"x64"
],
@@ -1319,26 +1347,10 @@
"node": ">=10"
}
},
- "node_modules/@swc/core-freebsd-x64": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.216.tgz",
- "integrity": "sha512-+R9cKtvSCVEEqsjnyFDmK5iXub9AlDliWLgx6aMb5HtxgIsd7V+5sr0SXXLk5/1x0Fjjo8KURw3Aw/0hlElMqg==",
- "cpu": [
- "x64"
- ],
- "dev": true,
- "optional": true,
- "os": [
- "freebsd"
- ],
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/@swc/core-linux-arm-gnueabihf": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.216.tgz",
- "integrity": "sha512-ZUJDodTpfB9hlpOpUhLKAKrtZW4pzNAggj6OHjqR1Xm62Qq1wda0Kz4nx+9ltXFdnDwA3xo3ETILah4fqugVJQ==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.66.tgz",
+ "integrity": "sha512-gNbLcSIV2pq90BkMSpzvK4xPXOl8GEF3YR4NaqF0CYSzQsVXXTTqMuX/r26xNYudBKzH0345S1MpoRk2qricnA==",
"cpu": [
"arm"
],
@@ -1352,9 +1364,9 @@
}
},
"node_modules/@swc/core-linux-arm64-gnu": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.216.tgz",
- "integrity": "sha512-OhL9+FHjnOAcU/mpKEx6UP4Rq7xYeUBi2+DEO/e7b7bLOjnOoySbUp1A6ytVH+DMLPRdc8gl8fmW3Ua40LZIwg==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.66.tgz",
+ "integrity": "sha512-cJSQ0oplyWbJqy4rzVcnBYLAi6z1QT3QCcR7iAey0aAmCvfRBZJfXlyjggMjn4iosuadkauwCZR1xYNhBDRn7w==",
"cpu": [
"arm64"
],
@@ -1368,9 +1380,9 @@
}
},
"node_modules/@swc/core-linux-arm64-musl": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.216.tgz",
- "integrity": "sha512-CqocVXV2r9CUDYz0yuJAh3d8snXAztYps/Svsh9dBmXhB55IdaxcVPpxqThLlQStuzkI+8V3arxrWbbNtNd99g==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.66.tgz",
+ "integrity": "sha512-GDQZpcB9aGxG9PTA2shdIkoMZlGK5omJ8NR49uoBTtLBVYiGeXAwV0U1Uaw8kXEZj9i7wZDkvjzjSaNH3evRsg==",
"cpu": [
"arm64"
],
@@ -1384,9 +1396,9 @@
}
},
"node_modules/@swc/core-linux-x64-gnu": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.216.tgz",
- "integrity": "sha512-Lz7KKhWsg1LrZfcqxPiRhn6+j34TsVIIyCdxv497pSrY8ZvxST1JizEC7Rk48fHa+OkS9AVkoS3tElTX2oE7pg==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.66.tgz",
+ "integrity": "sha512-lg8E4O/Pd9KfK0lajdinVMuGME8dSv7V9arhEpmlfGE2eXSDCWqDn5Htk5QVBstt9lt1lsRhWHJ/YYc2eQY30Q==",
"cpu": [
"x64"
],
@@ -1400,9 +1412,9 @@
}
},
"node_modules/@swc/core-linux-x64-musl": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.216.tgz",
- "integrity": "sha512-hOQ6/++C5DZrcywKJtpQKbZHezTDUEsH4eDc1UJh6tQPWRZFPSJcFOvemJi1e7PrdFjQINamqnAlkisNCYjTmA==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.66.tgz",
+ "integrity": "sha512-lo8ZcAO/zL2pZWH+LZIyge8u2MklaeuT6+FpVVpBFktMVdYXbaVtzpvWbgRFBZHvL3SRDF+u8jxjtkXhvGUpTw==",
"cpu": [
"x64"
],
@@ -1416,9 +1428,9 @@
}
},
"node_modules/@swc/core-win32-arm64-msvc": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.216.tgz",
- "integrity": "sha512-W4K2k4tCOXGCk+DWyBvi0Cal2trVTCXaAGwRUpHcGjwGdxT7q3uCIoNoeCWdy6/5b/CnQDQ+8kWuD4NESjgt3A==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.66.tgz",
+ "integrity": "sha512-cQoVwBuJY5WkHbfpCOlndNwYr1ZThatRjQQvKy540NUIeAEk9Fa6ozlDBtU75UdaWKtUG6YQ/bWz+KTemheVxw==",
"cpu": [
"arm64"
],
@@ -1432,9 +1444,9 @@
}
},
"node_modules/@swc/core-win32-ia32-msvc": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.216.tgz",
- "integrity": "sha512-pHoCPbW8Dj0MSxtO9BPzT+AkNopapYnRBGqBnUS5pJjjRj/pnvWkvwaG95IZnklHnw8fPeuFpaGc+B2PYJuFEA==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.66.tgz",
+ "integrity": "sha512-y/FrAIINK4UBeUQQknGlWXEyjo+MBvjF7WkUf2KP7sNr9EHHy8+dXohAGd5Anz0eJrqOM1ZXR/GEjxRp7bGQ1Q==",
"cpu": [
"ia32"
],
@@ -1448,9 +1460,9 @@
}
},
"node_modules/@swc/core-win32-x64-msvc": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.216.tgz",
- "integrity": "sha512-ZDKEvCH7UGiCa93dMwzl01vKgSygf4FF/GszZEHL6CDY8YRMABycLDB0so66nOPOcSqfxSHr3eFB3KtY5OMrEA==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.66.tgz",
+ "integrity": "sha512-yI64ACzS14qFLrfyO12qW+f/UROTotzDeEbuyJAaPD2IZexoT1cICznI3sBmIfrSt33mVuW8eF5m3AG/NUImzw==",
"cpu": [
"x64"
],
@@ -1463,6 +1475,22 @@
"node": ">=10"
}
},
+ "node_modules/@swc/jest": {
+ "version": "0.2.26",
+ "resolved": "https://registry.npmjs.org/@swc/jest/-/jest-0.2.26.tgz",
+ "integrity": "sha512-7lAi7q7ShTO3E5Gt1Xqf3pIhRbERxR1DUxvtVa9WKzIB+HGQ7wZP5sYx86zqnaEoKKGhmOoZ7gyW0IRu8Br5+A==",
+ "dev": true,
+ "dependencies": {
+ "@jest/create-cache-key-function": "^27.4.2",
+ "jsonc-parser": "^3.2.0"
+ },
+ "engines": {
+ "npm": ">= 7.0.0"
+ },
+ "peerDependencies": {
+ "@swc/core": "*"
+ }
+ },
"node_modules/@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
@@ -6875,6 +6903,39 @@
"strip-ansi": "^6.0.0"
}
},
+ "@jest/create-cache-key-function": {
+ "version": "27.5.1",
+ "resolved": "https://registry.npmjs.org/@jest/create-cache-key-function/-/create-cache-key-function-27.5.1.tgz",
+ "integrity": "sha512-dmH1yW+makpTSURTy8VzdUwFnfQh1G8R+DxO2Ho2FFmBbKFEVm+3jWdvFhE2VqB/LATCTokkP0dotjyQyw5/AQ==",
+ "dev": true,
+ "requires": {
+ "@jest/types": "^27.5.1"
+ },
+ "dependencies": {
+ "@jest/types": {
+ "version": "27.5.1",
+ "resolved": "https://registry.npmjs.org/@jest/types/-/types-27.5.1.tgz",
+ "integrity": "sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==",
+ "dev": true,
+ "requires": {
+ "@types/istanbul-lib-coverage": "^2.0.0",
+ "@types/istanbul-reports": "^3.0.0",
+ "@types/node": "*",
+ "@types/yargs": "^16.0.0",
+ "chalk": "^4.0.0"
+ }
+ },
+ "@types/yargs": {
+ "version": "16.0.5",
+ "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.5.tgz",
+ "integrity": "sha512-AxO/ADJOBFJScHbWhq2xAhlWP24rY4aCEG/NFaMvbT3X2MgRsLjhjQwsn0Zi5zn0LG9jUhCCZMeX9Dkuw6k+vQ==",
+ "dev": true,
+ "requires": {
+ "@types/yargs-parser": "*"
+ }
+ }
+ }
+ },
"@jest/environment": {
"version": "28.1.3",
"resolved": "https://registry.npmjs.org/@jest/environment/-/environment-28.1.3.tgz",
@@ -7084,9 +7145,20 @@
}
},
"@matrixai/async-cancellable": {
- "version": "1.0.6",
- "resolved": "https://registry.npmjs.org/@matrixai/async-cancellable/-/async-cancellable-1.0.6.tgz",
- "integrity": "sha512-DurgNGfIV/u11J94Ry5G/y2JPqKZEQdG4e0jzw/STl1MxC1D0bxKREvboKJP+fGBk4CihhU9G9iEPyaCBgM9lA=="
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@matrixai/async-cancellable/-/async-cancellable-1.1.1.tgz",
+ "integrity": "sha512-f0yxu7dHwvffZ++7aCm2WIcCJn18uLcOTdCCwEA3R3KVHYE3TG/JNoTWD9/mqBkAV1AI5vBfJzg27WnF9rOUXQ=="
+ },
+ "@matrixai/async-locks": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@matrixai/async-locks/-/async-locks-4.0.0.tgz",
+ "integrity": "sha512-u/3fOdtjOKcDYF8dDoPR1/+7nmOkhxo42eBpXTEgfI0hLPGI37PoW7tjLvwy+O51Quy1HGOwhsR/Dgr4x+euug==",
+ "requires": {
+ "@matrixai/async-cancellable": "^1.1.1",
+ "@matrixai/errors": "^1.1.7",
+ "@matrixai/resources": "^1.1.5",
+ "@matrixai/timer": "^1.1.1"
+ }
},
"@matrixai/errors": {
"version": "1.1.7",
@@ -7096,12 +7168,18 @@
"ts-custom-error": "3.2.2"
}
},
+ "@matrixai/resources": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/@matrixai/resources/-/resources-1.1.5.tgz",
+ "integrity": "sha512-m/DEZEe3wHqWEPTyoBtzFF6U9vWYhEnQtGgwvqiAlTxTM0rk96UBpWjDZCTF/vYG11ZlmlQFtg5H+zGgbjaB3Q=="
+ },
"@matrixai/timer": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@matrixai/timer/-/timer-1.1.0.tgz",
- "integrity": "sha512-n9ulMGJhjQyu+fhRxvP5SwY57miOLbRE6gtIzTZD6x7wFL0k5sUBMnEQ6W4QkO1atZnxKMFigg4gt/0V4XlniA==",
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@matrixai/timer/-/timer-1.1.1.tgz",
+ "integrity": "sha512-8UKDoGuwKC6BvrY/yANJVH29v71wgQKH/tJlxMPohGxmzVUQO5+JeI4lUYVHTs2vq1AyKAWloF5fOig+I1dyGA==",
"requires": {
- "@matrixai/async-cancellable": "^1.0.4"
+ "@matrixai/async-cancellable": "^1.1.1",
+ "@matrixai/errors": "^1.1.7"
}
},
"@nodelib/fs.scandir": {
@@ -7155,117 +7233,103 @@
}
},
"@swc/core": {
- "version": "1.2.215",
- "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.215.tgz",
- "integrity": "sha512-Dm6q1wP4OvG5DOHC9JQC4wAjIH4Pz8K4MfVrluojD7epDN97j2md6/QbMaL5Zcu24SsAuib8BYF4j9VelLrvtw==",
- "dev": true,
- "requires": {
- "@swc/core-android-arm-eabi": "1.2.216",
- "@swc/core-android-arm64": "1.2.216",
- "@swc/core-darwin-arm64": "1.2.216",
- "@swc/core-darwin-x64": "1.2.216",
- "@swc/core-freebsd-x64": "1.2.216",
- "@swc/core-linux-arm-gnueabihf": "1.2.216",
- "@swc/core-linux-arm64-gnu": "1.2.216",
- "@swc/core-linux-arm64-musl": "1.2.216",
- "@swc/core-linux-x64-gnu": "1.2.216",
- "@swc/core-linux-x64-musl": "1.2.216",
- "@swc/core-win32-arm64-msvc": "1.2.216",
- "@swc/core-win32-ia32-msvc": "1.2.216",
- "@swc/core-win32-x64-msvc": "1.2.216"
- }
- },
- "@swc/core-android-arm-eabi": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.216.tgz",
- "integrity": "sha512-V8iNfyaiNROZ+rfCzuoYBUYxlJ1yIkX3w0av54eCLigRktBDozUtYEbE0I/L9/WX3JDMKxMSt9cAjyMd8tmjyA==",
- "dev": true,
- "optional": true
- },
- "@swc/core-android-arm64": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.216.tgz",
- "integrity": "sha512-4N2dq2JQQTVX1rLR7p/n1ag0T9N1oRp35H7yci2bFxWbLfVvb7qShathHsr2XzkBhgmtc32zWnPPDIzolrew2g==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.66.tgz",
+ "integrity": "sha512-Hpf91kH5ly7fHkWnApwryTQryT+TO4kMMPH3WyciUSQOWLE3UuQz1PtETHQQk7PZ/b1QF0qQurJrgfBr5bSKUA==",
"dev": true,
- "optional": true
+ "requires": {
+ "@swc/core-darwin-arm64": "1.3.66",
+ "@swc/core-darwin-x64": "1.3.66",
+ "@swc/core-linux-arm-gnueabihf": "1.3.66",
+ "@swc/core-linux-arm64-gnu": "1.3.66",
+ "@swc/core-linux-arm64-musl": "1.3.66",
+ "@swc/core-linux-x64-gnu": "1.3.66",
+ "@swc/core-linux-x64-musl": "1.3.66",
+ "@swc/core-win32-arm64-msvc": "1.3.66",
+ "@swc/core-win32-ia32-msvc": "1.3.66",
+ "@swc/core-win32-x64-msvc": "1.3.66"
+ }
},
"@swc/core-darwin-arm64": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.216.tgz",
- "integrity": "sha512-rCof/23rLM0UEjrGhD9pqv0o50c5FMC7YCJGr4GP98iu4pGb0kgDlfu5EAO8wpXG2tMut3OHiQSefCWbtlygPA==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.66.tgz",
+ "integrity": "sha512-UijJsvuLy73vxeVYEy7urIHksXS+3BdvJ9s9AY+bRMSQW483NO7RLp8g4FdTyJbRaN0BH15SQnY0dcjQBkVuHw==",
"dev": true,
"optional": true
},
"@swc/core-darwin-x64": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.216.tgz",
- "integrity": "sha512-UarehjeGDxwfDmyR8egAVntkKitIe68v2NABQFBtnFdjt0vixWbrSKFsrFxOZZVIb+S2NTxdk3l4An5Nr0MK8A==",
- "dev": true,
- "optional": true
- },
- "@swc/core-freebsd-x64": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.216.tgz",
- "integrity": "sha512-+R9cKtvSCVEEqsjnyFDmK5iXub9AlDliWLgx6aMb5HtxgIsd7V+5sr0SXXLk5/1x0Fjjo8KURw3Aw/0hlElMqg==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.66.tgz",
+ "integrity": "sha512-xGsHKvViQnwTNLF30Y/5OqWdnN6RsiyUI8awZXfz1sHcXCEaLe+v+WLQ+/E8sgw0YUkYVHzzfV/sAN2CezJK5Q==",
"dev": true,
"optional": true
},
"@swc/core-linux-arm-gnueabihf": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.216.tgz",
- "integrity": "sha512-ZUJDodTpfB9hlpOpUhLKAKrtZW4pzNAggj6OHjqR1Xm62Qq1wda0Kz4nx+9ltXFdnDwA3xo3ETILah4fqugVJQ==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.66.tgz",
+ "integrity": "sha512-gNbLcSIV2pq90BkMSpzvK4xPXOl8GEF3YR4NaqF0CYSzQsVXXTTqMuX/r26xNYudBKzH0345S1MpoRk2qricnA==",
"dev": true,
"optional": true
},
"@swc/core-linux-arm64-gnu": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.216.tgz",
- "integrity": "sha512-OhL9+FHjnOAcU/mpKEx6UP4Rq7xYeUBi2+DEO/e7b7bLOjnOoySbUp1A6ytVH+DMLPRdc8gl8fmW3Ua40LZIwg==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.66.tgz",
+ "integrity": "sha512-cJSQ0oplyWbJqy4rzVcnBYLAi6z1QT3QCcR7iAey0aAmCvfRBZJfXlyjggMjn4iosuadkauwCZR1xYNhBDRn7w==",
"dev": true,
"optional": true
},
"@swc/core-linux-arm64-musl": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.216.tgz",
- "integrity": "sha512-CqocVXV2r9CUDYz0yuJAh3d8snXAztYps/Svsh9dBmXhB55IdaxcVPpxqThLlQStuzkI+8V3arxrWbbNtNd99g==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.66.tgz",
+ "integrity": "sha512-GDQZpcB9aGxG9PTA2shdIkoMZlGK5omJ8NR49uoBTtLBVYiGeXAwV0U1Uaw8kXEZj9i7wZDkvjzjSaNH3evRsg==",
"dev": true,
"optional": true
},
"@swc/core-linux-x64-gnu": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.216.tgz",
- "integrity": "sha512-Lz7KKhWsg1LrZfcqxPiRhn6+j34TsVIIyCdxv497pSrY8ZvxST1JizEC7Rk48fHa+OkS9AVkoS3tElTX2oE7pg==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.66.tgz",
+ "integrity": "sha512-lg8E4O/Pd9KfK0lajdinVMuGME8dSv7V9arhEpmlfGE2eXSDCWqDn5Htk5QVBstt9lt1lsRhWHJ/YYc2eQY30Q==",
"dev": true,
"optional": true
},
"@swc/core-linux-x64-musl": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.216.tgz",
- "integrity": "sha512-hOQ6/++C5DZrcywKJtpQKbZHezTDUEsH4eDc1UJh6tQPWRZFPSJcFOvemJi1e7PrdFjQINamqnAlkisNCYjTmA==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.66.tgz",
+ "integrity": "sha512-lo8ZcAO/zL2pZWH+LZIyge8u2MklaeuT6+FpVVpBFktMVdYXbaVtzpvWbgRFBZHvL3SRDF+u8jxjtkXhvGUpTw==",
"dev": true,
"optional": true
},
"@swc/core-win32-arm64-msvc": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.216.tgz",
- "integrity": "sha512-W4K2k4tCOXGCk+DWyBvi0Cal2trVTCXaAGwRUpHcGjwGdxT7q3uCIoNoeCWdy6/5b/CnQDQ+8kWuD4NESjgt3A==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.66.tgz",
+ "integrity": "sha512-cQoVwBuJY5WkHbfpCOlndNwYr1ZThatRjQQvKy540NUIeAEk9Fa6ozlDBtU75UdaWKtUG6YQ/bWz+KTemheVxw==",
"dev": true,
"optional": true
},
"@swc/core-win32-ia32-msvc": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.216.tgz",
- "integrity": "sha512-pHoCPbW8Dj0MSxtO9BPzT+AkNopapYnRBGqBnUS5pJjjRj/pnvWkvwaG95IZnklHnw8fPeuFpaGc+B2PYJuFEA==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.66.tgz",
+ "integrity": "sha512-y/FrAIINK4UBeUQQknGlWXEyjo+MBvjF7WkUf2KP7sNr9EHHy8+dXohAGd5Anz0eJrqOM1ZXR/GEjxRp7bGQ1Q==",
"dev": true,
"optional": true
},
"@swc/core-win32-x64-msvc": {
- "version": "1.2.216",
- "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.216.tgz",
- "integrity": "sha512-ZDKEvCH7UGiCa93dMwzl01vKgSygf4FF/GszZEHL6CDY8YRMABycLDB0so66nOPOcSqfxSHr3eFB3KtY5OMrEA==",
+ "version": "1.3.66",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.66.tgz",
+ "integrity": "sha512-yI64ACzS14qFLrfyO12qW+f/UROTotzDeEbuyJAaPD2IZexoT1cICznI3sBmIfrSt33mVuW8eF5m3AG/NUImzw==",
"dev": true,
"optional": true
},
+ "@swc/jest": {
+ "version": "0.2.26",
+ "resolved": "https://registry.npmjs.org/@swc/jest/-/jest-0.2.26.tgz",
+ "integrity": "sha512-7lAi7q7ShTO3E5Gt1Xqf3pIhRbERxR1DUxvtVa9WKzIB+HGQ7wZP5sYx86zqnaEoKKGhmOoZ7gyW0IRu8Br5+A==",
+ "dev": true,
+ "requires": {
+ "@jest/create-cache-key-function": "^27.4.2",
+ "jsonc-parser": "^3.2.0"
+ }
+ },
"@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
diff --git a/package.json b/package.json
index 9a47ca8..0a1ad5b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@matrixai/contexts",
- "version": "1.0.0",
+ "version": "1.1.0",
"author": "Roger Qiu",
"description": "Asynchronous contexts",
"license": "Apache-2.0",
@@ -22,14 +22,17 @@
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"
},
"dependencies": {
- "@matrixai/async-cancellable": "^1.0.6",
+ "@matrixai/async-cancellable": "^1.1.1",
+ "@matrixai/async-locks": "^4.0.0",
"@matrixai/errors": "^1.1.7",
- "@matrixai/timer": "^1.1.0"
+ "@matrixai/resources": "^1.1.5",
+ "@matrixai/timer": "^1.1.1"
},
"devDependencies": {
- "@swc/core": "^1.2.215",
+ "@swc/core": "^1.3.62",
+ "@swc/jest": "^0.2.26",
"@types/jest": "^28.1.3",
- "@types/node": "^18.11.11",
+ "@types/node": "^18.15.0",
"@typescript-eslint/eslint-plugin": "^5.45.1",
"@typescript-eslint/parser": "^5.45.1",
"eslint": "^8.15.0",
diff --git a/scripts/build-platforms-generate.sh b/scripts/build-platforms-generate.sh
deleted file mode 100755
index fe54eb1..0000000
--- a/scripts/build-platforms-generate.sh
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/usr/bin/env bash
-
-set -o errexit # abort on nonzero exitstatus
-set -o nounset # abort on unbound variable
-set -o pipefail # don't hide errors within pipes
-
-shopt -s globstar
-shopt -s nullglob
-
-# Using shards to optimise tests
-# In the future we can incorporate test durations rather than using
-# a static value for the parallel keyword
-
-# Number of parallel shards to split the test suite into
-CI_PARALLEL=2
-
-# Quote the heredoc to prevent shell expansion
-cat << "EOF"
-variables:
- GIT_SUBMODULE_STRATEGY: "recursive"
- GH_PROJECT_PATH: "MatrixAI/${CI_PROJECT_NAME}"
- GH_PROJECT_URL: "https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git"
- # Cache .npm
- npm_config_cache: "${CI_PROJECT_DIR}/tmp/npm"
- # Prefer offline node module installation
- npm_config_prefer_offline: "true"
- # Homebrew cache only used by macos runner
- HOMEBREW_CACHE: "${CI_PROJECT_DIR}/tmp/Homebrew"
-
-default:
- interruptible: true
- before_script:
- # Replace this in windows runners that use powershell
- # with `mkdir -Force "$CI_PROJECT_DIR/tmp"`
- - mkdir -p "$CI_PROJECT_DIR/tmp"
-
-# Cached directories shared between jobs & pipelines per-branch per-runner
-cache:
- key: $CI_COMMIT_REF_SLUG
- # Preserve cache even if job fails
- when: 'always'
- paths:
- - ./tmp/npm/
- # Homebrew cache is only used by the macos runner
- - ./tmp/Homebrew
- # Chocolatey cache is only used by the windows runner
- - ./tmp/chocolatey/
- # `jest` cache is configured in jest.config.js
- - ./tmp/jest/
-
-stages:
- - build # Cross-platform library compilation, unit tests
-
-image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
-
-build:linux:
- stage: build
- needs: []
-EOF
-cat << EOF
- parallel: $CI_PARALLEL
-EOF
-cat << "EOF"
- script:
- - >
- nix-shell --arg ci true --run $'
- npm test -- --ci --coverage --shard="$CI_NODE_INDEX/$CI_NODE_TOTAL";
- '
- artifacts:
- when: always
- reports:
- junit:
- - ./tmp/junit/junit.xml
- coverage_report:
- coverage_format: cobertura
- path: ./tmp/coverage/cobertura-coverage.xml
- coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
-
-build:windows:
- stage: build
- needs: []
-EOF
-cat << EOF
- parallel: $CI_PARALLEL
-EOF
-cat << "EOF"
- tags:
- - windows
- before_script:
- - mkdir -Force "$CI_PROJECT_DIR/tmp"
- script:
- - .\scripts\choco-install.ps1
- - refreshenv
- - npm install --ignore-scripts
- - $env:Path = "$(npm root)\.bin;" + $env:Path
- - npm test -- --ci --coverage --shard="$CI_NODE_INDEX/$CI_NODE_TOTAL"
- artifacts:
- when: always
- reports:
- junit:
- - ./tmp/junit/junit.xml
- coverage_report:
- coverage_format: cobertura
- path: ./tmp/coverage/cobertura-coverage.xml
- coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
-
-build:macos:
- stage: build
- needs: []
-EOF
-cat << EOF
- parallel: $CI_PARALLEL
-EOF
-cat << "EOF"
- tags:
- - shared-macos-amd64
- image: macos-11-xcode-12
- script:
- - eval "$(brew shellenv)"
- - ./scripts/brew-install.sh
- - hash -r
- - npm install --ignore-scripts
- - export PATH="$(npm root)/.bin:$PATH"
- - npm test -- --ci --coverage --shard="$CI_NODE_INDEX/$CI_NODE_TOTAL"
- artifacts:
- when: always
- reports:
- junit:
- - ./tmp/junit/junit.xml
- coverage_report:
- coverage_format: cobertura
- path: ./tmp/coverage/cobertura-coverage.xml
- coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
-EOF
diff --git a/scripts/check-test-generate.sh b/scripts/check-test-generate.sh
deleted file mode 100755
index 66f3b52..0000000
--- a/scripts/check-test-generate.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env bash
-
-set -o errexit # abort on nonzero exitstatus
-set -o nounset # abort on unbound variable
-set -o pipefail # don't hide errors within pipes
-
-shopt -s globstar
-shopt -s nullglob
-
-# Using shards to optimise tests
-# In the future we can incorporate test durations rather than using
-# a static value for the parallel keyword
-
-# Number of parallel shards to split the test suite into
-CI_PARALLEL=2
-
-# Quote the heredoc to prevent shell expansion
-cat << "EOF"
-variables:
- GIT_SUBMODULE_STRATEGY: "recursive"
- GH_PROJECT_PATH: "MatrixAI/${CI_PROJECT_NAME}"
- GH_PROJECT_URL: "https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git"
- # Cache .npm
- npm_config_cache: "${CI_PROJECT_DIR}/tmp/npm"
- # Prefer offline node module installation
- npm_config_prefer_offline: "true"
- # Homebrew cache only used by macos runner
- HOMEBREW_CACHE: "${CI_PROJECT_DIR}/tmp/Homebrew"
-
-default:
- interruptible: true
- before_script:
- # Replace this in windows runners that use powershell
- # with `mkdir -Force "$CI_PROJECT_DIR/tmp"`
- - mkdir -p "$CI_PROJECT_DIR/tmp"
-
-# Cached directories shared between jobs & pipelines per-branch per-runner
-cache:
- key: $CI_COMMIT_REF_SLUG
- # Preserve cache even if job fails
- when: 'always'
- paths:
- - ./tmp/npm/
- # Homebrew cache is only used by the macos runner
- - ./tmp/Homebrew
- # Chocolatey cache is only used by the windows runner
- - ./tmp/chocolatey/
- # `jest` cache is configured in jest.config.js
- - ./tmp/jest/
-
-stages:
- - check # Linting, unit tests
-
-image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
-
-check:test:
- stage: check
- needs: []
-EOF
-cat << EOF
- parallel: $CI_PARALLEL
-EOF
-cat << "EOF"
- script:
- - >
- nix-shell --arg ci true --run $'
- npm test -- --ci --coverage --shard="$CI_NODE_INDEX/$CI_NODE_TOTAL";
- '
- artifacts:
- when: always
- reports:
- junit:
- - ./tmp/junit/junit.xml
- coverage_report:
- coverage_format: cobertura
- path: ./tmp/coverage/cobertura-coverage.xml
- coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
-EOF
diff --git a/src/decorators/timed.ts b/src/decorators/timed.ts
index 5cc42df..60922ee 100644
--- a/src/decorators/timed.ts
+++ b/src/decorators/timed.ts
@@ -1,4 +1,4 @@
-import type { ContextTimed } from '../types';
+import type { ContextTimedInput } from '../types';
import { setupTimedContext } from '../functions/timed';
import * as utils from '../utils';
import * as errors from '../errors';
@@ -27,7 +27,7 @@ function timed(
const contextIndex = utils.getContextIndex(target, key, targetName);
if (f instanceof utils.AsyncFunction) {
descriptor['value'] = async function (...args) {
- let ctx: Partial = args[contextIndex];
+ let ctx: Partial = args[contextIndex];
if (ctx === undefined) {
ctx = {};
} else {
@@ -51,7 +51,7 @@ function timed(
};
} else if (f instanceof utils.GeneratorFunction) {
descriptor['value'] = function* (...args) {
- let ctx: Partial = args[contextIndex];
+ let ctx: Partial = args[contextIndex];
if (ctx === undefined) {
ctx = {};
} else {
@@ -75,7 +75,7 @@ function timed(
};
} else if (f instanceof utils.AsyncGeneratorFunction) {
descriptor['value'] = async function* (...args) {
- let ctx: Partial = args[contextIndex];
+ let ctx: Partial = args[contextIndex];
if (ctx === undefined) {
ctx = {};
} else {
@@ -99,7 +99,7 @@ function timed(
};
} else {
descriptor['value'] = function (...args) {
- let ctx: Partial = args[contextIndex];
+ let ctx: Partial = args[contextIndex];
if (ctx === undefined) {
ctx = {};
} else {
diff --git a/src/decorators/timedCancellable.ts b/src/decorators/timedCancellable.ts
index 2a6dd78..787de90 100644
--- a/src/decorators/timedCancellable.ts
+++ b/src/decorators/timedCancellable.ts
@@ -1,4 +1,4 @@
-import type { ContextTimed } from '../types';
+import type { ContextTimedInput } from '../types';
import { setupTimedCancellable } from '../functions/timedCancellable';
import * as utils from '../utils';
import * as errors from '../errors';
@@ -28,7 +28,7 @@ function timedCancellable(
}
const contextIndex = utils.getContextIndex(target, key, targetName);
descriptor['value'] = function (...args) {
- let ctx: Partial = args[contextIndex];
+ let ctx: Partial = args[contextIndex];
if (ctx === undefined) {
ctx = {};
} else {
diff --git a/src/functions/timed.ts b/src/functions/timed.ts
index f74087b..f3db01c 100644
--- a/src/functions/timed.ts
+++ b/src/functions/timed.ts
@@ -1,21 +1,21 @@
-import type { ContextTimed } from '../types';
+import type { ContextTimed, ContextTimedInput } from '../types';
import { Timer } from '@matrixai/timer';
import * as errors from '../errors';
import * as utils from '../utils';
-type ContextRemaining = Omit;
+type ContextRemaining = Omit;
type ContextAndParameters<
C,
P extends Array,
> = keyof ContextRemaining extends never
- ? [Partial?, ...P]
- : [Partial & ContextRemaining, ...P];
+ ? [Partial?, ...P]
+ : [Partial & ContextRemaining, ...P];
function setupTimedContext(
delay: number,
errorTimeoutConstructor: new () => Error,
- ctx: Partial,
+ ctx: Partial,
): () => void {
// There are 3 properties of timer and signal:
//
@@ -36,11 +36,17 @@ function setupTimedContext(
// In situation 4, there's a caveat for property A: it is assumed that the
// caller has already setup the property A relationship, therefore this
// wrapper will not re-setup this property A relationship.
- if (ctx.timer === undefined && ctx.signal === undefined) {
+ if (
+ (ctx.timer === undefined || typeof ctx.timer === 'number') &&
+ ctx.signal === undefined
+ ) {
const abortController = new AbortController();
const e = new errorTimeoutConstructor();
// Property A
- const timer = new Timer(() => void abortController.abort(e), delay);
+ const timer = new Timer(
+ () => void abortController.abort(e),
+ ctx.timer ?? delay,
+ );
abortController.signal.addEventListener('abort', () => {
// Property B
timer.cancel();
@@ -51,11 +57,17 @@ function setupTimedContext(
// Property C
timer.cancel();
};
- } else if (ctx.timer === undefined && ctx.signal instanceof AbortSignal) {
+ } else if (
+ (ctx.timer === undefined || typeof ctx.timer === 'number') &&
+ ctx.signal instanceof AbortSignal
+ ) {
const abortController = new AbortController();
const e = new errorTimeoutConstructor();
// Property A
- const timer = new Timer(() => void abortController.abort(e), delay);
+ const timer = new Timer(
+ () => void abortController.abort(e),
+ ctx.timer ?? delay,
+ );
const signalUpstream = ctx.signal;
const signalHandler = () => {
// Property B
@@ -113,13 +125,22 @@ function setupTimedContext(
* Timed HOF
* This overloaded signature is external signature
*/
-function timed, R>(
- f: (ctx: C, ...params: P) => R,
+function timed<
+ C extends ContextTimedInput,
+ C_ extends ContextTimed,
+ P extends Array,
+ R,
+>(
+ f: (ctx: C_, ...params: P) => R,
delay?: number,
errorTimeoutConstructor?: new () => Error,
): (...params: ContextAndParameters) => R;
-function timed>(
- f: (ctx: C, ...params: P) => any,
+function timed<
+ C extends ContextTimedInput,
+ C_ extends ContextTimed,
+ P extends Array,
+>(
+ f: (ctx: C_, ...params: P) => any,
delay: number = Infinity,
errorTimeoutConstructor: new () => Error = errors.ErrorContextsTimedTimeOut,
): (...params: ContextAndParameters) => any {
@@ -133,7 +154,7 @@ function timed>(
ctx,
);
try {
- return await f(ctx as C, ...args);
+ return await f(ctx as C_, ...args);
} finally {
teardownContext();
}
@@ -148,7 +169,7 @@ function timed>(
ctx,
);
try {
- return yield* f(ctx as C, ...args);
+ return yield* f(ctx as C_, ...args);
} finally {
teardownContext();
}
@@ -163,7 +184,7 @@ function timed>(
ctx,
);
try {
- return yield* f(ctx as C, ...args);
+ return yield* f(ctx as C_, ...args);
} finally {
teardownContext();
}
@@ -177,7 +198,7 @@ function timed>(
errorTimeoutConstructor,
ctx,
);
- const result = f(ctx as C, ...args);
+ const result = f(ctx as C_, ...args);
if (utils.isPromiseLike(result)) {
return result.then(
(r) => {
diff --git a/src/functions/timedCancellable.ts b/src/functions/timedCancellable.ts
index 0188f21..2c8db0a 100644
--- a/src/functions/timedCancellable.ts
+++ b/src/functions/timedCancellable.ts
@@ -1,23 +1,23 @@
-import type { ContextTimed } from '../types';
+import type { ContextTimed, ContextTimedInput } from '../types';
import { PromiseCancellable } from '@matrixai/async-cancellable';
import { Timer } from '@matrixai/timer';
import * as errors from '../errors';
-type ContextRemaining = Omit;
+type ContextRemaining = Omit;
type ContextAndParameters<
C,
P extends Array,
> = keyof ContextRemaining extends never
- ? [Partial?, ...P]
- : [Partial & ContextRemaining, ...P];
+ ? [Partial?, ...P]
+ : [Partial & ContextRemaining, ...P];
function setupTimedCancellable, R>(
f: (ctx: C, ...params: P) => PromiseLike,
lazy: boolean,
delay: number,
- errorTimeoutConstructor: new () => Error = errors.ErrorContextsTimedTimeOut,
- ctx: Partial,
+ errorTimeoutConstructor: new () => Error,
+ ctx: Partial,
args: P,
): PromiseCancellable {
// There are 3 properties of timer and signal:
@@ -41,11 +41,17 @@ function setupTimedCancellable, R>(
// wrapper will not re-setup this property A relationship.
let abortController: AbortController;
let teardownContext: () => void;
- if (ctx.timer === undefined && ctx.signal === undefined) {
+ if (
+ (ctx.timer === undefined || typeof ctx.timer === 'number') &&
+ ctx.signal === undefined
+ ) {
abortController = new AbortController();
const e = new errorTimeoutConstructor();
// Property A
- const timer = new Timer(() => void abortController.abort(e), delay);
+ const timer = new Timer(
+ () => void abortController.abort(e),
+ ctx.timer ?? delay,
+ );
abortController.signal.addEventListener('abort', () => {
// Property B
timer.cancel();
@@ -56,11 +62,17 @@ function setupTimedCancellable, R>(
// Property C
timer.cancel();
};
- } else if (ctx.timer === undefined && ctx.signal instanceof AbortSignal) {
+ } else if (
+ (ctx.timer === undefined || typeof ctx.timer === 'number') &&
+ ctx.signal instanceof AbortSignal
+ ) {
abortController = new AbortController();
const e = new errorTimeoutConstructor();
// Property A
- const timer = new Timer(() => void abortController.abort(e), delay);
+ const timer = new Timer(
+ () => void abortController.abort(e),
+ ctx.timer ?? delay,
+ );
const signalUpstream = ctx.signal;
const signalHandler = () => {
// Property B
@@ -137,9 +149,13 @@ function setupTimedCancellable, R>(
if (signal.aborted) {
reject(signal.reason);
} else {
- signal.addEventListener('abort', () => {
- reject(signal.reason);
- });
+ signal.addEventListener(
+ 'abort',
+ () => {
+ reject(signal.reason);
+ },
+ { once: true },
+ );
}
}
void result.then(resolve, reject);
@@ -148,8 +164,13 @@ function setupTimedCancellable, R>(
}, abortController);
}
-function timedCancellable, R>(
- f: (ctx: C, ...params: P) => PromiseLike,
+function timedCancellable<
+ C extends ContextTimedInput,
+ C_ extends ContextTimed,
+ P extends Array,
+ R,
+>(
+ f: (ctx: C_, ...params: P) => PromiseLike,
lazy: boolean = false,
delay: number = Infinity,
errorTimeoutConstructor: new () => Error = errors.ErrorContextsTimedTimeOut,
diff --git a/src/types.ts b/src/types.ts
index 0473686..1eb8bad 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -8,4 +8,8 @@ type ContextTimed = ContextCancellable & {
timer: Timer;
};
-export type { ContextCancellable, ContextTimed };
+type ContextTimedInput = ContextCancellable & {
+ timer: Timer | number;
+};
+
+export type { ContextCancellable, ContextTimed, ContextTimedInput };
diff --git a/src/utils.ts b/src/utils.ts
index 8c78b61..0f796cb 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,3 +1,5 @@
+import type { ResourceAcquire } from '@matrixai/resources';
+import type { PromiseCancellableController } from '@matrixai/async-cancellable';
import { Timer } from '@matrixai/timer';
const AsyncFunction = (async () => {}).constructor;
@@ -52,13 +54,49 @@ function checkContextTimed(
`\`${targetName}.${key.toString()}\` decorated \`@context\` parameter's \`signal\` property is not an instance of \`AbortSignal\``,
);
}
- if (ctx.timer !== undefined && !(ctx.timer instanceof Timer)) {
+ if (
+ ctx.timer !== undefined &&
+ !(typeof ctx.timer === 'number' || ctx.timer instanceof Timer)
+ ) {
throw new TypeError(
- `\`${targetName}.${key.toString()}\` decorated \`@context\` parameter's \`timer\` property is not an instance of \`Timer\``,
+ `\`${targetName}.${key.toString()}\` decorated \`@context\` parameter's \`timer\` property is not a number nor an instance of \`Timer\``,
);
}
}
+/**
+ * Timer resource
+ * Use it with `withF` or `withG`.
+ */
+function timer(
+ handlerOrOpts?:
+ | ((signal: AbortSignal) => T | PromiseLike)
+ | {
+ handler?: (signal: AbortSignal) => T | PromiseLike;
+ delay?: number;
+ lazy?: boolean;
+ controller?: PromiseCancellableController;
+ },
+ delay: number = 0,
+ lazy: boolean = false,
+ controller?: PromiseCancellableController,
+): ResourceAcquire> {
+ return async () => {
+ let timer: Timer;
+ if (typeof handlerOrOpts === 'function') {
+ timer = new Timer(handlerOrOpts, delay, lazy, controller);
+ } else {
+ timer = new Timer(handlerOrOpts);
+ }
+ return [
+ async () => {
+ timer.cancel();
+ },
+ timer,
+ ];
+ };
+}
+
function isPromiseLike(v: any): v is PromiseLike {
return v != null && typeof v.then === 'function';
}
@@ -100,6 +138,7 @@ export {
getContextIndex,
checkContextCancellable,
checkContextTimed,
+ timer,
isPromiseLike,
isGenerator,
isAsyncGenerator,
diff --git a/tests/decorators/timed.test.ts b/tests/decorators/timed.test.ts
index b35af72..97b8535 100644
--- a/tests/decorators/timed.test.ts
+++ b/tests/decorators/timed.test.ts
@@ -1,4 +1,4 @@
-import type { ContextTimed } from '@/types';
+import type { ContextTimed, ContextTimedInput } from '@/types';
import { Timer } from '@matrixai/timer';
import context from '@/decorators/context';
import timed from '@/decorators/timed';
@@ -33,7 +33,7 @@ describe('decorators/timed', () => {
}
const c = new C();
// @ts-ignore invalid context timer
- await c.f({ timer: 1 });
+ await c.f({ timer: new Error() });
}).rejects.toThrow(TypeError);
await expect(async () => {
class C {
@@ -54,7 +54,7 @@ describe('decorators/timed', () => {
const symbolFunction = Symbol('sym');
class X {
functionValue(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): string;
@timed(1000)
@@ -69,7 +69,7 @@ describe('decorators/timed', () => {
}
functionValueArray(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): Array;
@timed(1000)
@@ -84,7 +84,7 @@ describe('decorators/timed', () => {
}
functionPromise(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): Promise;
@timed(1000)
@@ -99,7 +99,7 @@ describe('decorators/timed', () => {
}
asyncFunction(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): Promise;
@timed(Infinity)
@@ -113,7 +113,7 @@ describe('decorators/timed', () => {
}
generator(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): Generator;
@timed(0)
@@ -127,7 +127,7 @@ describe('decorators/timed', () => {
}
functionGenerator(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): Generator;
@timed(0)
@@ -139,7 +139,7 @@ describe('decorators/timed', () => {
}
asyncGenerator(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): AsyncGenerator;
@timed(NaN)
@@ -153,7 +153,7 @@ describe('decorators/timed', () => {
}
functionAsyncGenerator(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): AsyncGenerator;
@timed(NaN)
@@ -165,7 +165,7 @@ describe('decorators/timed', () => {
}
[symbolFunction](
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): Promise;
@timed()
@@ -184,7 +184,7 @@ describe('decorators/timed', () => {
expect(x.functionValue()).toBe('hello world');
expect(x.functionValue({})).toBe('hello world');
expect(
- x.functionValue({ timer: new Timer({ delay: 100 }) }, (t) => {
+ x.functionValue({ timer: 100 }, (t) => {
expect(t.delay).toBe(100);
}),
).toBe('hello world');
@@ -308,7 +308,7 @@ describe('decorators/timed', () => {
/**
* Async function
*/
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -331,7 +331,7 @@ describe('decorators/timed', () => {
/**
* Async function
*/
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50, ErrorCustom)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -351,7 +351,7 @@ describe('decorators/timed', () => {
/**
* Regular function returning promise
*/
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50)
f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -382,7 +382,7 @@ describe('decorators/timed', () => {
* Regular function that actually rejects
* when the signal is aborted
*/
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50)
f(@context ctx: ContextTimed): Promise {
return new Promise((resolve, reject) => {
@@ -412,7 +412,7 @@ describe('decorators/timed', () => {
/**
* Regular function that actually rejects immediately
*/
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(0)
f(@context ctx: ContextTimed): Promise {
return new Promise((resolve, reject) => {
@@ -438,7 +438,7 @@ describe('decorators/timed', () => {
});
test('async generator expiry', async () => {
class C {
- f(ctx?: Partial): AsyncGenerator;
+ f(ctx?: Partial): AsyncGenerator;
@timed(50)
async *f(@context ctx: ContextTimed): AsyncGenerator {
while (true) {
@@ -464,7 +464,7 @@ describe('decorators/timed', () => {
});
test('generator expiry', async () => {
class C {
- f(ctx?: Partial): Generator;
+ f(ctx?: Partial): Generator;
@timed(50)
*f(@context ctx: ContextTimed): Generator {
while (true) {
@@ -488,7 +488,7 @@ describe('decorators/timed', () => {
let timer: Timer;
let signal: AbortSignal;
class C {
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.timer).toBeInstanceOf(Timer);
@@ -500,7 +500,7 @@ describe('decorators/timed', () => {
return await this.g(ctx);
}
- g(ctx?: Partial): Promise;
+ g(ctx?: Partial): Promise;
@timed(25)
async g(@context ctx: ContextTimed): Promise {
expect(ctx.timer).toBeInstanceOf(Timer);
@@ -521,7 +521,7 @@ describe('decorators/timed', () => {
let timer: Timer;
let signal: AbortSignal;
class C {
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.timer).toBeInstanceOf(Timer);
@@ -533,7 +533,7 @@ describe('decorators/timed', () => {
return await this.g({ timer: ctx.timer });
}
- g(ctx?: Partial): Promise;
+ g(ctx?: Partial): Promise;
@timed(25)
async g(@context ctx: ContextTimed): Promise {
expect(ctx.timer).toBeInstanceOf(Timer);
@@ -553,7 +553,7 @@ describe('decorators/timed', () => {
let timer: Timer;
let signal: AbortSignal;
class C {
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.timer).toBeInstanceOf(Timer);
@@ -565,7 +565,7 @@ describe('decorators/timed', () => {
return await this.g({ signal: ctx.signal });
}
- g(ctx?: Partial): Promise;
+ g(ctx?: Partial): Promise;
@timed(25)
async g(@context ctx: ContextTimed): Promise {
expect(ctx.timer).toBeInstanceOf(Timer);
@@ -587,7 +587,7 @@ describe('decorators/timed', () => {
let timer: Timer;
let signal: AbortSignal;
class C {
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.timer).toBeInstanceOf(Timer);
@@ -599,7 +599,7 @@ describe('decorators/timed', () => {
return await this.g();
}
- g(ctx?: Partial): Promise;
+ g(ctx?: Partial): Promise;
@timed(25)
async g(@context ctx: ContextTimed): Promise {
expect(ctx.timer).toBeInstanceOf(Timer);
@@ -617,7 +617,7 @@ describe('decorators/timed', () => {
});
test('propagated expiry', async () => {
class C {
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(25)
async f(@context ctx: ContextTimed): Promise {
// The `g` will use up all the remaining time
@@ -643,7 +643,7 @@ describe('decorators/timed', () => {
return counter;
}
- h(ctx?: Partial): Promise;
+ h(ctx?: Partial): Promise;
@timed(25)
async h(@context ctx: ContextTimed): Promise {
return new Promise((resolve, reject) => {
@@ -670,7 +670,7 @@ describe('decorators/timed', () => {
// there will be no timeout error
let ctx_: ContextTimed | undefined;
class C {
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timed(50)
f(@context ctx: ContextTimed): Promise {
ctx_ = ctx;
diff --git a/tests/decorators/timedCancellable.test.ts b/tests/decorators/timedCancellable.test.ts
index e4853db..ffb63f5 100644
--- a/tests/decorators/timedCancellable.test.ts
+++ b/tests/decorators/timedCancellable.test.ts
@@ -1,4 +1,4 @@
-import type { ContextTimed } from '@/types';
+import type { ContextTimed, ContextTimedInput } from '@/types';
import { Timer } from '@matrixai/timer';
import { PromiseCancellable } from '@matrixai/async-cancellable';
import context from '@/decorators/context';
@@ -40,7 +40,7 @@ describe('decorators/timedCancellable', () => {
const symbolFunction = Symbol('sym');
class X {
functionPromise(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): PromiseCancellable;
@timedCancellable(false, 1000)
@@ -55,7 +55,7 @@ describe('decorators/timedCancellable', () => {
}
asyncFunction(
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): PromiseCancellable;
@timedCancellable(true, Infinity)
@@ -69,7 +69,7 @@ describe('decorators/timedCancellable', () => {
}
[symbolFunction](
- ctx?: Partial,
+ ctx?: Partial,
check?: (t: Timer) => any,
): PromiseCancellable;
@timedCancellable()
@@ -89,7 +89,7 @@ describe('decorators/timedCancellable', () => {
expect(pC).toBeInstanceOf(PromiseCancellable);
await pC;
await x.functionPromise({});
- await x.functionPromise({ timer: new Timer({ delay: 100 }) }, (t) => {
+ await x.functionPromise({ timer: 100 }, (t) => {
expect(t.delay).toBe(100);
});
expect(x.functionPromise).toBeInstanceOf(Function);
@@ -127,7 +127,7 @@ describe('decorators/timedCancellable', () => {
/**
* Async function
*/
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial): PromiseCancellable;
@timedCancellable(false, 50)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -152,7 +152,7 @@ describe('decorators/timedCancellable', () => {
/**
* Async function
*/
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial): PromiseCancellable;
@timedCancellable(true, 50)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -175,7 +175,7 @@ describe('decorators/timedCancellable', () => {
/**
* Async function
*/
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial): PromiseCancellable;
@timedCancellable(false, 50, ErrorCustom)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -196,7 +196,7 @@ describe('decorators/timedCancellable', () => {
/**
* Async function
*/
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial): PromiseCancellable;
@timedCancellable(true, 50, ErrorCustom)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -216,7 +216,7 @@ describe('decorators/timedCancellable', () => {
/**
* Regular function returning promise
*/
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial): PromiseCancellable;
@timedCancellable(true, 50)
f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -247,7 +247,7 @@ describe('decorators/timedCancellable', () => {
* Regular function that actually rejects
* when the signal is aborted
*/
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timedCancellable(true, 50)
f(@context ctx: ContextTimed): Promise {
return new Promise((resolve, reject) => {
@@ -277,7 +277,7 @@ describe('decorators/timedCancellable', () => {
/**
* Regular function that actually rejects immediately
*/
- f(ctx?: Partial): Promise;
+ f(ctx?: Partial): Promise;
@timedCancellable(true, 0)
f(@context ctx: ContextTimed): Promise {
return new Promise((resolve, reject) => {
@@ -305,7 +305,7 @@ describe('decorators/timedCancellable', () => {
describe('timedCancellable decorator cancellation', () => {
test('async function cancel - eager', async () => {
class C {
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial): PromiseCancellable;
@timedCancellable()
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -324,7 +324,7 @@ describe('decorators/timedCancellable', () => {
});
test('async function cancel - lazy', async () => {
class C {
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial): PromiseCancellable;
@timedCancellable(true)
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -343,7 +343,7 @@ describe('decorators/timedCancellable', () => {
});
test('async function cancel with custom error and eager rejection', async () => {
class C {
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial): PromiseCancellable;
@timedCancellable()
async f(@context ctx: ContextTimed): Promise {
expect(ctx.signal.aborted).toBe(false);
@@ -362,7 +362,7 @@ describe('decorators/timedCancellable', () => {
});
test('async function cancel with custom error and lazy rejection', async () => {
class C {
- f(ctx?: Partial): PromiseCancellable;
+ f(ctx?: Partial
Timed HOF This overloaded signature is external signature
@@ -27,7 +27,9 @@Function timed