From 6676510aaf5b551a84ded43db78da536a2360aa3 Mon Sep 17 00:00:00 2001 From: denoify_ci Date: Thu, 27 Aug 2020 23:49:38 +0000 Subject: [PATCH] Enabling shorter import paths [automatic] --- .github/workflows/ci.yaml | 102 -- .github/workflows/publish.yaml | 106 -- .gitignore | 45 +- bundle.js | 354 +++++ bundle.js.map | 1 + bundle.min.js | 1 + deno_dist/LICENSE | 22 + deno_dist/README.md | 321 +++++ deno_dist/lib/runExclusive.ts | 449 ++++++ deno_dist/mod.ts | 1 + deno_dist/test/index.ts | 37 + deno_dist/test/legacyTests/index.ts | 17 + deno_dist/test/legacyTests/test1.ts | 43 + deno_dist/test/legacyTests/test10.ts | 57 + deno_dist/test/legacyTests/test11.ts | 85 ++ deno_dist/test/legacyTests/test12.ts | 101 ++ deno_dist/test/legacyTests/test13.ts | 39 + deno_dist/test/legacyTests/test14.ts | 41 + deno_dist/test/legacyTests/test15.ts | 50 + deno_dist/test/legacyTests/test16.ts | 106 ++ deno_dist/test/legacyTests/test17.ts | 57 + deno_dist/test/legacyTests/test18.ts | 43 + deno_dist/test/legacyTests/test19.ts | 66 + deno_dist/test/legacyTests/test2.ts | 61 + deno_dist/test/legacyTests/test20.ts | 58 + deno_dist/test/legacyTests/test21.ts | 14 + deno_dist/test/legacyTests/test3.ts | 78 ++ deno_dist/test/legacyTests/test4.ts | 75 + deno_dist/test/legacyTests/test5.ts | 68 + deno_dist/test/legacyTests/test6.ts | 90 ++ deno_dist/test/legacyTests/test7.ts | 92 ++ deno_dist/test/legacyTests/test8.ts | 95 ++ deno_dist/test/legacyTests/test9.ts | 49 + deno_dist/test/mod.ts | 23 + deno_dist/test/test1.ts | 46 + deno_dist/test/test10.ts | 58 + deno_dist/test/test11.ts | 82 ++ deno_dist/test/test12.ts | 109 ++ deno_dist/test/test13.ts | 39 + deno_dist/test/test14.ts | 40 + deno_dist/test/test15.ts | 49 + deno_dist/test/test16.ts | 60 + deno_dist/test/test17.ts | 54 + deno_dist/test/test18.ts | 32 + deno_dist/test/test2.ts | 59 + deno_dist/test/test3.ts | 77 ++ deno_dist/test/test4.ts | 77 ++ deno_dist/test/test5.ts | 69 + deno_dist/test/test6.ts | 88 ++ deno_dist/test/test7.ts | 94 ++ deno_dist/test/test8.ts | 89 ++ deno_dist/test/test9.ts | 47 + deno_dist/test/testMem1.ts | 52 + deno_dist/test/testMem2.ts | 47 + lib/runExclusive.d.ts | 113 ++ lib/runExclusive.js | 280 ++++ lib/runExclusive.js.map | 1 + package.json | 26 +- test/index.d.ts | 1 + test/index.js | 24 + test/index.js.map | 1 + test/legacyTests/index.d.ts | 1 + test/legacyTests/index.js | 12 + test/legacyTests/index.js.map | 1 + test/legacyTests/test1.d.ts | 1 + test/legacyTests/test1.js | 34 + test/legacyTests/test1.js.map | 1 + test/legacyTests/test10.d.ts | 1 + test/legacyTests/test10.js | 39 + test/legacyTests/test10.js.map | 1 + test/legacyTests/test11.d.ts | 1 + test/legacyTests/test11.js | 60 + test/legacyTests/test11.js.map | 1 + test/legacyTests/test12.d.ts | 13 + test/legacyTests/test12.js | 75 + test/legacyTests/test12.js.map | 1 + test/legacyTests/test13.d.ts | 1 + test/legacyTests/test13.js | 26 + test/legacyTests/test13.js.map | 1 + test/legacyTests/test14.d.ts | 1 + test/legacyTests/test14.js | 27 + test/legacyTests/test14.js.map | 1 + test/legacyTests/test15.d.ts | 1 + test/legacyTests/test15.js | 34 + test/legacyTests/test15.js.map | 1 + test/legacyTests/test16.d.ts | 13 + test/legacyTests/test16.js | 76 + test/legacyTests/test16.js.map | 1 + test/legacyTests/test17.d.ts | 6 + test/legacyTests/test17.js | 35 + test/legacyTests/test17.js.map | 1 + test/legacyTests/test18.d.ts | 6 + test/legacyTests/test18.js | 30 + test/legacyTests/test18.js.map | 1 + test/legacyTests/test19.d.ts | 4 + test/legacyTests/test19.js | 78 ++ test/legacyTests/test19.js.map | 1 + test/legacyTests/test2.d.ts | 1 + test/legacyTests/test2.js | 42 + test/legacyTests/test2.js.map | 1 + test/legacyTests/test20.d.ts | 4 + test/legacyTests/test20.js | 79 ++ test/legacyTests/test20.js.map | 1 + test/legacyTests/test21.d.ts | 1 + test/legacyTests/test21.js | 9 + test/legacyTests/test21.js.map | 1 + test/legacyTests/test3.d.ts | 1 + test/legacyTests/test3.js | 53 + test/legacyTests/test3.js.map | 1 + test/legacyTests/test4.d.ts | 1 + test/legacyTests/test4.js | 53 + test/legacyTests/test4.js.map | 1 + test/legacyTests/test5.d.ts | 1 + test/legacyTests/test5.js | 48 + test/legacyTests/test5.js.map | 1 + test/legacyTests/test6.d.ts | 1 + test/legacyTests/test6.js | 62 + test/legacyTests/test6.js.map | 1 + test/legacyTests/test7.d.ts | 1 + test/legacyTests/test7.js | 60 + test/legacyTests/test7.js.map | 1 + test/legacyTests/test8.d.ts | 1 + test/legacyTests/test8.js | 60 + test/legacyTests/test8.js.map | 1 + test/legacyTests/test9.d.ts | 1 + test/legacyTests/test9.js | 32 + test/legacyTests/test9.js.map | 1 + test/mod.d.ts | 17 + test/mod.js | 21 + test/mod.js.map | 1 + test/test1.d.ts | 1 + test/test1.js | 36 + test/test1.js.map | 1 + test/test10.d.ts | 1 + test/test10.js | 80 ++ test/test10.js.map | 1 + test/test11.d.ts | 1 + test/test11.js | 101 ++ test/test11.js.map | 1 + test/test12.d.ts | 13 + test/test12.js | 118 ++ test/test12.js.map | 1 + test/test13.d.ts | 1 + test/test13.js | 67 + test/test13.js.map | 1 + test/test14.d.ts | 1 + test/test14.js | 68 + test/test14.js.map | 1 + test/test15.d.ts | 1 + test/test15.js | 75 + test/test15.js.map | 1 + test/test16.d.ts | 4 + test/test16.js | 86 ++ test/test16.js.map | 1 + test/test17.d.ts | 4 + test/test17.js | 85 ++ test/test17.js.map | 1 + test/test18.d.ts | 1 + test/test18.js | 69 + test/test18.js.map | 1 + test/test2.d.ts | 1 + test/test2.js | 88 ++ test/test2.js.map | 1 + test/test3.d.ts | 1 + test/test3.js | 94 ++ test/test3.js.map | 1 + test/test4.d.ts | 1 + test/test4.js | 94 ++ test/test4.js.map | 1 + test/test5.d.ts | 1 + test/test5.js | 89 ++ test/test5.js.map | 1 + test/test6.d.ts | 1 + test/test6.js | 108 ++ test/test6.js.map | 1 + test/test7.d.ts | 1 + test/test7.js | 105 ++ test/test7.js.map | 1 + test/test8.d.ts | 1 + test/test8.js | 105 ++ test/test8.js.map | 1 + test/test9.d.ts | 1 + test/test9.js | 73 + test/test9.js.map | 1 + test/testMem1.d.ts | 1 + test/testMem1.js | 95 ++ test/testMem1.js.map | 1 + test/testMem2.d.ts | 1 + test/testMem2.js | 101 ++ test/testMem2.js.map | 1 + tsconfig.tsbuildinfo | 1925 ++++++++++++++++++++++++++ 191 files changed, 9159 insertions(+), 269 deletions(-) delete mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/publish.yaml create mode 100644 bundle.js create mode 100644 bundle.js.map create mode 100644 bundle.min.js create mode 100644 deno_dist/LICENSE create mode 100644 deno_dist/README.md create mode 100644 deno_dist/lib/runExclusive.ts create mode 100644 deno_dist/mod.ts create mode 100644 deno_dist/test/index.ts create mode 100644 deno_dist/test/legacyTests/index.ts create mode 100644 deno_dist/test/legacyTests/test1.ts create mode 100644 deno_dist/test/legacyTests/test10.ts create mode 100644 deno_dist/test/legacyTests/test11.ts create mode 100644 deno_dist/test/legacyTests/test12.ts create mode 100644 deno_dist/test/legacyTests/test13.ts create mode 100644 deno_dist/test/legacyTests/test14.ts create mode 100644 deno_dist/test/legacyTests/test15.ts create mode 100644 deno_dist/test/legacyTests/test16.ts create mode 100644 deno_dist/test/legacyTests/test17.ts create mode 100644 deno_dist/test/legacyTests/test18.ts create mode 100644 deno_dist/test/legacyTests/test19.ts create mode 100644 deno_dist/test/legacyTests/test2.ts create mode 100644 deno_dist/test/legacyTests/test20.ts create mode 100644 deno_dist/test/legacyTests/test21.ts create mode 100644 deno_dist/test/legacyTests/test3.ts create mode 100644 deno_dist/test/legacyTests/test4.ts create mode 100644 deno_dist/test/legacyTests/test5.ts create mode 100644 deno_dist/test/legacyTests/test6.ts create mode 100644 deno_dist/test/legacyTests/test7.ts create mode 100644 deno_dist/test/legacyTests/test8.ts create mode 100644 deno_dist/test/legacyTests/test9.ts create mode 100644 deno_dist/test/mod.ts create mode 100644 deno_dist/test/test1.ts create mode 100644 deno_dist/test/test10.ts create mode 100644 deno_dist/test/test11.ts create mode 100644 deno_dist/test/test12.ts create mode 100644 deno_dist/test/test13.ts create mode 100644 deno_dist/test/test14.ts create mode 100644 deno_dist/test/test15.ts create mode 100644 deno_dist/test/test16.ts create mode 100644 deno_dist/test/test17.ts create mode 100644 deno_dist/test/test18.ts create mode 100644 deno_dist/test/test2.ts create mode 100644 deno_dist/test/test3.ts create mode 100644 deno_dist/test/test4.ts create mode 100644 deno_dist/test/test5.ts create mode 100644 deno_dist/test/test6.ts create mode 100644 deno_dist/test/test7.ts create mode 100644 deno_dist/test/test8.ts create mode 100644 deno_dist/test/test9.ts create mode 100644 deno_dist/test/testMem1.ts create mode 100644 deno_dist/test/testMem2.ts create mode 100644 lib/runExclusive.d.ts create mode 100644 lib/runExclusive.js create mode 100644 lib/runExclusive.js.map create mode 100644 test/index.d.ts create mode 100644 test/index.js create mode 100644 test/index.js.map create mode 100644 test/legacyTests/index.d.ts create mode 100644 test/legacyTests/index.js create mode 100644 test/legacyTests/index.js.map create mode 100644 test/legacyTests/test1.d.ts create mode 100644 test/legacyTests/test1.js create mode 100644 test/legacyTests/test1.js.map create mode 100644 test/legacyTests/test10.d.ts create mode 100644 test/legacyTests/test10.js create mode 100644 test/legacyTests/test10.js.map create mode 100644 test/legacyTests/test11.d.ts create mode 100644 test/legacyTests/test11.js create mode 100644 test/legacyTests/test11.js.map create mode 100644 test/legacyTests/test12.d.ts create mode 100644 test/legacyTests/test12.js create mode 100644 test/legacyTests/test12.js.map create mode 100644 test/legacyTests/test13.d.ts create mode 100644 test/legacyTests/test13.js create mode 100644 test/legacyTests/test13.js.map create mode 100644 test/legacyTests/test14.d.ts create mode 100644 test/legacyTests/test14.js create mode 100644 test/legacyTests/test14.js.map create mode 100644 test/legacyTests/test15.d.ts create mode 100644 test/legacyTests/test15.js create mode 100644 test/legacyTests/test15.js.map create mode 100644 test/legacyTests/test16.d.ts create mode 100644 test/legacyTests/test16.js create mode 100644 test/legacyTests/test16.js.map create mode 100644 test/legacyTests/test17.d.ts create mode 100644 test/legacyTests/test17.js create mode 100644 test/legacyTests/test17.js.map create mode 100644 test/legacyTests/test18.d.ts create mode 100644 test/legacyTests/test18.js create mode 100644 test/legacyTests/test18.js.map create mode 100644 test/legacyTests/test19.d.ts create mode 100644 test/legacyTests/test19.js create mode 100644 test/legacyTests/test19.js.map create mode 100644 test/legacyTests/test2.d.ts create mode 100644 test/legacyTests/test2.js create mode 100644 test/legacyTests/test2.js.map create mode 100644 test/legacyTests/test20.d.ts create mode 100644 test/legacyTests/test20.js create mode 100644 test/legacyTests/test20.js.map create mode 100644 test/legacyTests/test21.d.ts create mode 100644 test/legacyTests/test21.js create mode 100644 test/legacyTests/test21.js.map create mode 100644 test/legacyTests/test3.d.ts create mode 100644 test/legacyTests/test3.js create mode 100644 test/legacyTests/test3.js.map create mode 100644 test/legacyTests/test4.d.ts create mode 100644 test/legacyTests/test4.js create mode 100644 test/legacyTests/test4.js.map create mode 100644 test/legacyTests/test5.d.ts create mode 100644 test/legacyTests/test5.js create mode 100644 test/legacyTests/test5.js.map create mode 100644 test/legacyTests/test6.d.ts create mode 100644 test/legacyTests/test6.js create mode 100644 test/legacyTests/test6.js.map create mode 100644 test/legacyTests/test7.d.ts create mode 100644 test/legacyTests/test7.js create mode 100644 test/legacyTests/test7.js.map create mode 100644 test/legacyTests/test8.d.ts create mode 100644 test/legacyTests/test8.js create mode 100644 test/legacyTests/test8.js.map create mode 100644 test/legacyTests/test9.d.ts create mode 100644 test/legacyTests/test9.js create mode 100644 test/legacyTests/test9.js.map create mode 100644 test/mod.d.ts create mode 100644 test/mod.js create mode 100644 test/mod.js.map create mode 100644 test/test1.d.ts create mode 100644 test/test1.js create mode 100644 test/test1.js.map create mode 100644 test/test10.d.ts create mode 100644 test/test10.js create mode 100644 test/test10.js.map create mode 100644 test/test11.d.ts create mode 100644 test/test11.js create mode 100644 test/test11.js.map create mode 100644 test/test12.d.ts create mode 100644 test/test12.js create mode 100644 test/test12.js.map create mode 100644 test/test13.d.ts create mode 100644 test/test13.js create mode 100644 test/test13.js.map create mode 100644 test/test14.d.ts create mode 100644 test/test14.js create mode 100644 test/test14.js.map create mode 100644 test/test15.d.ts create mode 100644 test/test15.js create mode 100644 test/test15.js.map create mode 100644 test/test16.d.ts create mode 100644 test/test16.js create mode 100644 test/test16.js.map create mode 100644 test/test17.d.ts create mode 100644 test/test17.js create mode 100644 test/test17.js.map create mode 100644 test/test18.d.ts create mode 100644 test/test18.js create mode 100644 test/test18.js.map create mode 100644 test/test2.d.ts create mode 100644 test/test2.js create mode 100644 test/test2.js.map create mode 100644 test/test3.d.ts create mode 100644 test/test3.js create mode 100644 test/test3.js.map create mode 100644 test/test4.d.ts create mode 100644 test/test4.js create mode 100644 test/test4.js.map create mode 100644 test/test5.d.ts create mode 100644 test/test5.js create mode 100644 test/test5.js.map create mode 100644 test/test6.d.ts create mode 100644 test/test6.js create mode 100644 test/test6.js.map create mode 100644 test/test7.d.ts create mode 100644 test/test7.js create mode 100644 test/test7.js.map create mode 100644 test/test8.d.ts create mode 100644 test/test8.js create mode 100644 test/test8.js.map create mode 100644 test/test9.d.ts create mode 100644 test/test9.js create mode 100644 test/test9.js.map create mode 100644 test/testMem1.d.ts create mode 100644 test/testMem1.js create mode 100644 test/testMem1.js.map create mode 100644 test/testMem2.d.ts create mode 100644 test/testMem2.js create mode 100644 test/testMem2.js.map create mode 100644 tsconfig.tsbuildinfo diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index bfb8842..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,102 +0,0 @@ -name: ci -on: - push: - branches: - - develop - pull_request: - branches: - - develop - -jobs: - - test_node: - runs-on: ubuntu-latest - if: ${{ !github.event.created }} - strategy: - matrix: - node: [ '14', '13', '12', '11', '10', '8' ] - name: Test with Node v${{ matrix.node }} - steps: - - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node }} - - run: npm ci - - run: npx tsc - - run: npm run test:node - - test_deno: - runs-on: ubuntu-latest - if: ${{ !github.event.created }} - name: test with Deno - steps: - - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - - name: Cache - uses: actions/cache@v1 - with: - path: ~/.cache/deno - key: deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }} - restore-keys: | - deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }} - deno-${{ runner.os }}- - deno- - - uses: denolib/setup-deno@master - with: - deno-version: v1.x - - run: npm ci - - run: npm run build - - run: npm run test:deno - - trigger_publish: - name: Trigger publish.yaml workflow if package.json version updated ( and secrets.PAT is set ). - runs-on: ubuntu-latest - env: - PAT: ${{secrets.PAT}} - if: github.event_name == 'push' && github.event.head_commit.author.name != 'denoify_ci' - needs: - - test_node - - test_deno - steps: - - - name: Get version on latest - id: v_latest - uses: garronej/github_actions_toolkit@v1.4 - with: - action_name: get_package_json_version - owner: ${{github.repository_owner}} - repo: ${{github.event.repository.name}} - branch: latest - compare_to_version: '0.0.0' - - - name: Get version on develop - id: v_develop - uses: garronej/github_actions_toolkit@v1.4 - with: - action_name: get_package_json_version - owner: ${{github.repository_owner}} - repo: ${{github.event.repository.name}} - branch: ${{ github.sha }} - compare_to_version: ${{steps.v_latest.outputs.version || '0.0.0'}} - - - name: 'Trigger the ''publish'' workflow' - if: ${{ !!env.PAT && steps.v_develop.outputs.compare_result == '1' }} - uses: garronej/github_actions_toolkit@v1.4 - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - with: - action_name: dispatch_event - owner: ${{github.repository_owner}} - repo: ${{github.event.repository.name}} - event_type: publish - client_payload_json: | - ${{ - format( - '{{"from_version":"{0}","to_version":"{1}","repo":"{2}"}}', - steps.v_latest.outputs.version, - steps.v_develop.outputs.version, - github.event.repository.name - ) - }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 5b430f5..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,106 +0,0 @@ -on: - repository_dispatch: - types: publish - -jobs: - update_changelog_and_sync_package_lock_version: - name: Update CHANGELOG.md and make sure package.json and package-lock.json versions matches. - runs-on: ubuntu-latest - steps: - - name: Synchronize package.json and package-lock.json version if needed. - uses: garronej/github_actions_toolkit@v1.4 - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - with: - action_name: sync_package_and_package_lock_version - owner: ${{github.repository_owner}} - repo: ${{github.event.client_payload.repo}} - branch: develop - commit_author_email: denoify_ci@github.com - - name: Update CHANGELOG.md - if: ${{ !!github.event.client_payload.from_version }} - uses: garronej/github_actions_toolkit@v1.4 - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - with: - action_name: update_changelog - owner: ${{github.repository_owner}} - repo: ${{github.event.client_payload.repo}} - branch_behind: latest - branch_ahead: develop - commit_author_email: denoify_ci@github.com - exclude_commit_from_author_names_json: '["denoify_ci"]' - - publish: - runs-on: ubuntu-latest - needs: update_changelog_and_sync_package_lock_version - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: develop - - name: Remove .github directory, useless on 'latest' branch - run: rm -r .github - - name: Remove branch 'latest' - continue-on-error: true - run: | - git branch -d latest || true - git push origin :latest - - name: Create the new 'latest' branch - run: | - git branch latest - git checkout latest - - uses: actions/setup-node@v1 - - run: npm ci - - run: npm run enable_short_import_path - env: - DRY_RUN: "0" - - name: (DEBUG) Show how the files have been moved to enable short import - run: ls -lR - - name: Publishing on NPM - run: | - if [ "$(npm show . version)" = "$VERSION" ]; then - echo "This version is already published" - exit 0 - fi - if [ "$NPM_TOKEN" = "" ]; then - echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets" - false - fi - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc - npm publish - rm .npmrc - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - VERSION: ${{ github.event.client_payload.to_version }} - - name: Commit changes - run: | - git config --local user.email "denoify_ci@github.com" - git config --local user.name "denoify_ci" - git add -A - git commit -am "Enabling shorter import paths [automatic]" - - run: git push origin latest - - name: Release body - id: id_rb - run: | - if [ "$FROM_VERSION" = "" ]; then - echo "::set-output name=body::🚀" - else - echo "::set-output name=body::📋 [CHANGELOG](https://github.com/$OWNER/$REPO/blob/$REF/CHANGELOG.md)" - fi - env: - FROM_VERSION: ${{ github.event.client_payload.from_version }} - OWNER: ${{github.repository_owner}} - REPO: ${{github.event.client_payload.repo}} - REF: v${{github.event.client_payload.to_version}} - - name: Create Release - uses: garronej/create-release@master - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - with: - tag_name: v${{ github.event.client_payload.to_version }} - release_name: Release v${{ github.event.client_payload.to_version }} - branch: latest - draft: false - prerelease: false - body: ${{ steps.id_rb.outputs.body }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8a783f1..13be271 100644 --- a/.gitignore +++ b/.gitignore @@ -1,45 +1,2 @@ -# Logs -logs -*.log -npm-debug.log* -.DS_Store -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules -jspm_packages - -# Optional npm cache directory -.npm - -# Optional REPL history -.node_repl_history - -dist/test -.vscode - -/dist -/deno_dist +/node_modules diff --git a/bundle.js b/bundle.js new file mode 100644 index 0000000..8c45f0c --- /dev/null +++ b/bundle.js @@ -0,0 +1,354 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.runExclusive = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i>(); +function getOrCreateExecQueue(context, groupRef) { + var execQueueByGroup = clusters.get(context); + if (!execQueueByGroup) { + execQueueByGroup = new WeakMap_1.Polyfill(); + clusters.set(context, execQueueByGroup); + } + var execQueue = execQueueByGroup.get(groupRef); + if (!execQueue) { + execQueue = new ExecQueue(); + execQueueByGroup.set(groupRef, execQueue); + } + return execQueue; +} +function createGroupRef() { + return new Array(0); +} +exports.createGroupRef = createGroupRef; +function build() { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + switch (inputs.length) { + case 1: return buildFnPromise(true, createGroupRef(), inputs[0]); + case 2: return buildFnPromise(true, inputs[0], inputs[1]); + } +} +exports.build = build; +function buildMethod() { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + switch (inputs.length) { + case 1: return buildFnPromise(false, createGroupRef(), inputs[0]); + case 2: return buildFnPromise(false, inputs[0], inputs[1]); + } +} +exports.buildMethod = buildMethod; +/** + * + * Get the number of queued call of a run-exclusive function. + * Note that if you call a runExclusive function and call this + * directly after it will return 0 as there is one function call + * execution ongoing but 0 queued. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + * + * */ +function getQueuedCallCount(runExclusiveFunction, classInstanceObject) { + var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + return execQueue ? execQueue.queuedCalls.length : 0; +} +exports.getQueuedCallCount = getQueuedCallCount; +/** + * + * Cancel all queued calls of a run-exclusive function. + * Note that the current running call will not be cancelled. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + * + */ +function cancelAllQueuedCalls(runExclusiveFunction, classInstanceObject) { + var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + return execQueue ? execQueue.cancelAllQueuedCalls() : 0; +} +exports.cancelAllQueuedCalls = cancelAllQueuedCalls; +/** + * Tell if a run-exclusive function has an instance of it's call currently being + * performed. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + */ +function isRunning(runExclusiveFunction, classInstanceObject) { + var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + return execQueue ? execQueue.isRunning : false; +} +exports.isRunning = isRunning; +/** + * Return a promise that resolve when all the current queued call of a runExclusive functions + * have completed. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + */ +function getPrComplete(runExclusiveFunction, classInstanceObject) { + var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + return execQueue ? execQueue.prComplete : Promise.resolve(); +} +exports.getPrComplete = getPrComplete; +var groupByRunExclusiveFunction = new WeakMap_1.Polyfill(); +function getExecQueueByFunctionAndContext(runExclusiveFunction, context) { + if (context === void 0) { context = globalContext; } + var groupRef = groupByRunExclusiveFunction.get(runExclusiveFunction); + if (!groupRef) { + throw Error("Not a run exclusiveFunction"); + } + var execQueueByGroup = clusters.get(context); + if (!execQueueByGroup) { + return undefined; + } + return execQueueByGroup.get(groupRef); +} +function buildFnPromise(isGlobal, groupRef, fun) { + var execQueue; + var runExclusiveFunction = (function () { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + if (!isGlobal) { + if (!(this instanceof Object)) { + throw new Error("Run exclusive, should be an object"); + } + execQueue = getOrCreateExecQueue(this, groupRef); + } + return new Promise(function (resolve, reject) { + var onPrCompleteResolve; + execQueue.prComplete = new Promise(function (resolve) { + return onPrCompleteResolve = function () { return resolve(); }; + }); + var onComplete = function (result) { + onPrCompleteResolve(); + execQueue.isRunning = false; + if (execQueue.queuedCalls.length) { + execQueue.queuedCalls.shift()(); + } + if ("data" in result) { + resolve(result.data); + } + else { + reject(result.reason); + } + }; + (function callee() { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + if (execQueue.isRunning) { + execQueue.queuedCalls.push(function () { return callee.apply(_this, inputs); }); + return; + } + execQueue.isRunning = true; + try { + fun.apply(this, inputs) + .then(function (data) { return onComplete({ data: data }); })["catch"](function (reason) { return onComplete({ reason: reason }); }); + } + catch (error) { + onComplete({ "reason": error }); + } + }).apply(_this, inputs); + }); + }); + if (isGlobal) { + execQueue = getOrCreateExecQueue(globalContext, groupRef); + } + groupByRunExclusiveFunction.set(runExclusiveFunction, groupRef); + return runExclusiveFunction; +} +function buildCb() { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + switch (inputs.length) { + case 1: return buildFnCallback(true, createGroupRef(), inputs[0]); + case 2: return buildFnCallback(true, inputs[0], inputs[1]); + } +} +exports.buildCb = buildCb; +function buildMethodCb() { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + switch (inputs.length) { + case 1: return buildFnCallback(false, createGroupRef(), inputs[0]); + case 2: return buildFnCallback(false, inputs[0], inputs[1]); + } +} +exports.buildMethodCb = buildMethodCb; +function buildFnCallback(isGlobal, groupRef, fun) { + var execQueue; + var runExclusiveFunction = (function () { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + if (!isGlobal) { + if (!(this instanceof Object)) { + throw new Error("Run exclusive, should be an object"); + } + execQueue = getOrCreateExecQueue(this, groupRef); + } + var callback = undefined; + if (inputs.length && typeof inputs[inputs.length - 1] === "function") { + callback = inputs.pop(); + } + var onPrCompleteResolve; + execQueue.prComplete = new Promise(function (resolve) { + return onPrCompleteResolve = function () { return resolve(); }; + }); + var onComplete = function () { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + onPrCompleteResolve(); + execQueue.isRunning = false; + if (execQueue.queuedCalls.length) { + execQueue.queuedCalls.shift()(); + } + if (callback) { + callback.apply(_this, inputs); + } + }; + onComplete.hasCallback = !!callback; + (function callee() { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + if (execQueue.isRunning) { + execQueue.queuedCalls.push(function () { return callee.apply(_this, inputs); }); + return; + } + execQueue.isRunning = true; + try { + fun.apply(this, __spreadArrays(inputs, [onComplete])); + } + catch (error) { + error.message += " ( This exception should not have been thrown, miss use of run-exclusive buildCb )"; + throw error; + } + }).apply(this, inputs); + }); + if (isGlobal) { + execQueue = getOrCreateExecQueue(globalContext, groupRef); + } + groupByRunExclusiveFunction.set(runExclusiveFunction, groupRef); + return runExclusiveFunction; +} + +},{"minimal-polyfills/WeakMap":3}],2:[function(require,module,exports){ +"use strict"; +exports.__esModule = true; +exports.Polyfill = exports.LightMapImpl = void 0; +var LightMapImpl = /** @class */ (function () { + function LightMapImpl() { + this.record = []; + } + LightMapImpl.prototype.has = function (key) { + return this.record + .map(function (_a) { + var _key = _a[0]; + return _key; + }) + .indexOf(key) >= 0; + }; + LightMapImpl.prototype.get = function (key) { + var entry = this.record + .filter(function (_a) { + var _key = _a[0]; + return _key === key; + })[0]; + if (entry === undefined) { + return undefined; + } + return entry[1]; + }; + LightMapImpl.prototype.set = function (key, value) { + var entry = this.record + .filter(function (_a) { + var _key = _a[0]; + return _key === key; + })[0]; + if (entry === undefined) { + this.record.push([key, value]); + } + else { + entry[1] = value; + } + return this; + }; + LightMapImpl.prototype["delete"] = function (key) { + var index = this.record.map(function (_a) { + var key = _a[0]; + return key; + }).indexOf(key); + if (index < 0) { + return false; + } + this.record.splice(index, 1); + return true; + }; + LightMapImpl.prototype.keys = function () { + return this.record.map(function (_a) { + var key = _a[0]; + return key; + }); + }; + return LightMapImpl; +}()); +exports.LightMapImpl = LightMapImpl; +exports.Polyfill = typeof Map !== "undefined" ? Map : LightMapImpl; + +},{}],3:[function(require,module,exports){ +"use strict"; +exports.__esModule = true; +exports.Polyfill = void 0; +var Map_1 = require("./Map"); +exports.Polyfill = typeof WeakMap !== "undefined" ? WeakMap : Map_1.Polyfill; + +},{"./Map":2}]},{},[1])(1) +}); +//# sourceMappingURL=bundle.js.map diff --git a/bundle.js.map b/bundle.js.map new file mode 100644 index 0000000..8a51c00 --- /dev/null +++ b/bundle.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["node_modules/browser-pack/_prelude.js","lib/runExclusive.js","node_modules/minimal-polyfills/Map.js","node_modules/minimal-polyfills/WeakMap.js"],"names":[],"mappings":"AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7DA;AACA;AACA;AACA;AACA;AACA","file":"generated.js","sourceRoot":"","sourcesContent":["(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i>();\nfunction getOrCreateExecQueue(context, groupRef) {\n var execQueueByGroup = clusters.get(context);\n if (!execQueueByGroup) {\n execQueueByGroup = new WeakMap_1.Polyfill();\n clusters.set(context, execQueueByGroup);\n }\n var execQueue = execQueueByGroup.get(groupRef);\n if (!execQueue) {\n execQueue = new ExecQueue();\n execQueueByGroup.set(groupRef, execQueue);\n }\n return execQueue;\n}\nfunction createGroupRef() {\n return new Array(0);\n}\nexports.createGroupRef = createGroupRef;\nfunction build() {\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n switch (inputs.length) {\n case 1: return buildFnPromise(true, createGroupRef(), inputs[0]);\n case 2: return buildFnPromise(true, inputs[0], inputs[1]);\n }\n}\nexports.build = build;\nfunction buildMethod() {\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n switch (inputs.length) {\n case 1: return buildFnPromise(false, createGroupRef(), inputs[0]);\n case 2: return buildFnPromise(false, inputs[0], inputs[1]);\n }\n}\nexports.buildMethod = buildMethod;\n/**\n *\n * Get the number of queued call of a run-exclusive function.\n * Note that if you call a runExclusive function and call this\n * directly after it will return 0 as there is one function call\n * execution ongoing but 0 queued.\n *\n * The classInstanceObject parameter is to provide only for the run-exclusive\n * function created with 'buildMethod[Cb].\n *\n * */\nfunction getQueuedCallCount(runExclusiveFunction, classInstanceObject) {\n var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject);\n return execQueue ? execQueue.queuedCalls.length : 0;\n}\nexports.getQueuedCallCount = getQueuedCallCount;\n/**\n *\n * Cancel all queued calls of a run-exclusive function.\n * Note that the current running call will not be cancelled.\n *\n * The classInstanceObject parameter is to provide only for the run-exclusive\n * function created with 'buildMethod[Cb].\n *\n */\nfunction cancelAllQueuedCalls(runExclusiveFunction, classInstanceObject) {\n var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject);\n return execQueue ? execQueue.cancelAllQueuedCalls() : 0;\n}\nexports.cancelAllQueuedCalls = cancelAllQueuedCalls;\n/**\n * Tell if a run-exclusive function has an instance of it's call currently being\n * performed.\n *\n * The classInstanceObject parameter is to provide only for the run-exclusive\n * function created with 'buildMethod[Cb].\n */\nfunction isRunning(runExclusiveFunction, classInstanceObject) {\n var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject);\n return execQueue ? execQueue.isRunning : false;\n}\nexports.isRunning = isRunning;\n/**\n * Return a promise that resolve when all the current queued call of a runExclusive functions\n * have completed.\n *\n * The classInstanceObject parameter is to provide only for the run-exclusive\n * function created with 'buildMethod[Cb].\n */\nfunction getPrComplete(runExclusiveFunction, classInstanceObject) {\n var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject);\n return execQueue ? execQueue.prComplete : Promise.resolve();\n}\nexports.getPrComplete = getPrComplete;\nvar groupByRunExclusiveFunction = new WeakMap_1.Polyfill();\nfunction getExecQueueByFunctionAndContext(runExclusiveFunction, context) {\n if (context === void 0) { context = globalContext; }\n var groupRef = groupByRunExclusiveFunction.get(runExclusiveFunction);\n if (!groupRef) {\n throw Error(\"Not a run exclusiveFunction\");\n }\n var execQueueByGroup = clusters.get(context);\n if (!execQueueByGroup) {\n return undefined;\n }\n return execQueueByGroup.get(groupRef);\n}\nfunction buildFnPromise(isGlobal, groupRef, fun) {\n var execQueue;\n var runExclusiveFunction = (function () {\n var _this = this;\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n if (!isGlobal) {\n if (!(this instanceof Object)) {\n throw new Error(\"Run exclusive, should be an object\");\n }\n execQueue = getOrCreateExecQueue(this, groupRef);\n }\n return new Promise(function (resolve, reject) {\n var onPrCompleteResolve;\n execQueue.prComplete = new Promise(function (resolve) {\n return onPrCompleteResolve = function () { return resolve(); };\n });\n var onComplete = function (result) {\n onPrCompleteResolve();\n execQueue.isRunning = false;\n if (execQueue.queuedCalls.length) {\n execQueue.queuedCalls.shift()();\n }\n if (\"data\" in result) {\n resolve(result.data);\n }\n else {\n reject(result.reason);\n }\n };\n (function callee() {\n var _this = this;\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n if (execQueue.isRunning) {\n execQueue.queuedCalls.push(function () { return callee.apply(_this, inputs); });\n return;\n }\n execQueue.isRunning = true;\n try {\n fun.apply(this, inputs)\n .then(function (data) { return onComplete({ data: data }); })[\"catch\"](function (reason) { return onComplete({ reason: reason }); });\n }\n catch (error) {\n onComplete({ \"reason\": error });\n }\n }).apply(_this, inputs);\n });\n });\n if (isGlobal) {\n execQueue = getOrCreateExecQueue(globalContext, groupRef);\n }\n groupByRunExclusiveFunction.set(runExclusiveFunction, groupRef);\n return runExclusiveFunction;\n}\nfunction buildCb() {\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n switch (inputs.length) {\n case 1: return buildFnCallback(true, createGroupRef(), inputs[0]);\n case 2: return buildFnCallback(true, inputs[0], inputs[1]);\n }\n}\nexports.buildCb = buildCb;\nfunction buildMethodCb() {\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n switch (inputs.length) {\n case 1: return buildFnCallback(false, createGroupRef(), inputs[0]);\n case 2: return buildFnCallback(false, inputs[0], inputs[1]);\n }\n}\nexports.buildMethodCb = buildMethodCb;\nfunction buildFnCallback(isGlobal, groupRef, fun) {\n var execQueue;\n var runExclusiveFunction = (function () {\n var _this = this;\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n if (!isGlobal) {\n if (!(this instanceof Object)) {\n throw new Error(\"Run exclusive, should be an object\");\n }\n execQueue = getOrCreateExecQueue(this, groupRef);\n }\n var callback = undefined;\n if (inputs.length && typeof inputs[inputs.length - 1] === \"function\") {\n callback = inputs.pop();\n }\n var onPrCompleteResolve;\n execQueue.prComplete = new Promise(function (resolve) {\n return onPrCompleteResolve = function () { return resolve(); };\n });\n var onComplete = function () {\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n onPrCompleteResolve();\n execQueue.isRunning = false;\n if (execQueue.queuedCalls.length) {\n execQueue.queuedCalls.shift()();\n }\n if (callback) {\n callback.apply(_this, inputs);\n }\n };\n onComplete.hasCallback = !!callback;\n (function callee() {\n var _this = this;\n var inputs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n inputs[_i] = arguments[_i];\n }\n if (execQueue.isRunning) {\n execQueue.queuedCalls.push(function () { return callee.apply(_this, inputs); });\n return;\n }\n execQueue.isRunning = true;\n try {\n fun.apply(this, __spreadArrays(inputs, [onComplete]));\n }\n catch (error) {\n error.message += \" ( This exception should not have been thrown, miss use of run-exclusive buildCb )\";\n throw error;\n }\n }).apply(this, inputs);\n });\n if (isGlobal) {\n execQueue = getOrCreateExecQueue(globalContext, groupRef);\n }\n groupByRunExclusiveFunction.set(runExclusiveFunction, groupRef);\n return runExclusiveFunction;\n}\n//# sourceMappingURL=runExclusive.js.map","\"use strict\";\nexports.__esModule = true;\nexports.Polyfill = exports.LightMapImpl = void 0;\nvar LightMapImpl = /** @class */ (function () {\n function LightMapImpl() {\n this.record = [];\n }\n LightMapImpl.prototype.has = function (key) {\n return this.record\n .map(function (_a) {\n var _key = _a[0];\n return _key;\n })\n .indexOf(key) >= 0;\n };\n LightMapImpl.prototype.get = function (key) {\n var entry = this.record\n .filter(function (_a) {\n var _key = _a[0];\n return _key === key;\n })[0];\n if (entry === undefined) {\n return undefined;\n }\n return entry[1];\n };\n LightMapImpl.prototype.set = function (key, value) {\n var entry = this.record\n .filter(function (_a) {\n var _key = _a[0];\n return _key === key;\n })[0];\n if (entry === undefined) {\n this.record.push([key, value]);\n }\n else {\n entry[1] = value;\n }\n return this;\n };\n LightMapImpl.prototype[\"delete\"] = function (key) {\n var index = this.record.map(function (_a) {\n var key = _a[0];\n return key;\n }).indexOf(key);\n if (index < 0) {\n return false;\n }\n this.record.splice(index, 1);\n return true;\n };\n LightMapImpl.prototype.keys = function () {\n return this.record.map(function (_a) {\n var key = _a[0];\n return key;\n });\n };\n return LightMapImpl;\n}());\nexports.LightMapImpl = LightMapImpl;\nexports.Polyfill = typeof Map !== \"undefined\" ? Map : LightMapImpl;\n//# sourceMappingURL=Map.js.map","\"use strict\";\nexports.__esModule = true;\nexports.Polyfill = void 0;\nvar Map_1 = require(\"./Map\");\nexports.Polyfill = typeof WeakMap !== \"undefined\" ? WeakMap : Map_1.Polyfill;\n//# sourceMappingURL=WeakMap.js.map"]} \ No newline at end of file diff --git a/bundle.min.js b/bundle.min.js new file mode 100644 index 0000000..568524e --- /dev/null +++ b/bundle.min.js @@ -0,0 +1 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).runExclusive=e()}}((function(){return function e(n,t,r){function i(o,l){if(!t[o]){if(!n[o]){var s="function"==typeof require&&require;if(!l&&s)return s(o,!0);if(u)return u(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var a=t[o]={exports:{}};n[o][0].call(a.exports,(function(e){return i(n[o][1][e]||e)}),a,a.exports,e,n,t,r)}return t[o].exports}for(var u="function"==typeof require&&require,o=0;o should be an object");r=s(this,n)}return new Promise((function(e,n){var o;r.prComplete=new Promise((function(e){return o=function(){return e()}}));var l=function(t){o(),r.isRunning=!1,r.queuedCalls.length&&r.queuedCalls.shift()(),"data"in t?e(t.data):n(t.reason)};(function e(){for(var n=this,i=[],u=0;u should be an object");i=s(this,n)}var f,a=void 0;o.length&&"function"==typeof o[o.length-1]&&(a=o.pop()),i.prComplete=new Promise((function(e){return f=function(){return e()}}));var c=function(){for(var e=[],n=0;n=0},e.prototype.get=function(e){var n=this.record.filter((function(n){return n[0]===e}))[0];if(void 0!==n)return n[1]},e.prototype.set=function(e,n){var t=this.record.filter((function(n){return n[0]===e}))[0];return void 0===t?this.record.push([e,n]):t[1]=n,this},e.prototype.delete=function(e){var n=this.record.map((function(e){return e[0]})).indexOf(e);return!(n<0)&&(this.record.splice(n,1),!0)},e.prototype.keys=function(){return this.record.map((function(e){return e[0]}))},e}();t.LightMapImpl=r,t.Polyfill="undefined"!=typeof Map?Map:r},{}],3:[function(e,n,t){"use strict";t.__esModule=!0,t.Polyfill=void 0;var r=e("./Map");t.Polyfill="undefined"!=typeof WeakMap?WeakMap:r.Polyfill},{"./Map":2}]},{},[1])(1)})); \ No newline at end of file diff --git a/deno_dist/LICENSE b/deno_dist/LICENSE new file mode 100644 index 0000000..6072bac --- /dev/null +++ b/deno_dist/LICENSE @@ -0,0 +1,22 @@ +MIT License + + +Copyright (c) 2020 GitHub user u/garronej + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/deno_dist/README.md b/deno_dist/README.md new file mode 100644 index 0000000..7403d13 --- /dev/null +++ b/deno_dist/README.md @@ -0,0 +1,321 @@ +

+ +

+

+ ⚡🔒 Generate functions that do not allow parallel executions 🔒 ⚡ +
+
+ + + +

+ +--- + +Let you create functions that enforce no more than one execution happens at the same time. +If the function is called again while there is already an execution ongoing the new call will be queued and executed once all the queued calls have completed. + +This is a higher-level approach to the problem addressed by [`DirtyHairy/async-mutex`](https://www.npmjs.com/package/async-mutex). + +Suitable for any JS runtime env (deno, node, old browser, react-native ...) +- ✅ It is both a [Deno](https://deno.land/x/run_exclusive) and an [NPM](https://www.npmjs.com/run-exclusive) module. +- ✅ Lightweight, no dependency. +- ✅ No polyfills needed, the NPM module is transpiled down to ES3 + +# Install / Import + +## Deno + +```typescript +import * as runExclusive from "https://deno.land/x/run_exclusive/mod.ts"; +``` + +## Other javascript runtime environnement: + +```bash +$ npm install --save run-exclusive +``` +```typescript +import * as runExclusive from "run-exclusive"; +``` + +## Import from HTML, with CDN + +Expose a global (wider browser support): + +```html + + +``` + +*You can import a specific version* [unpkg.com](https://unpkg.com) + +# Try it now + +Thanks to Stackblitz you can try this lib within your browser like if you where in VSCode. + +![Screenshot 2020-02-14 at 12 48 04](https://user-images.githubusercontent.com/6702424/74528376-70531280-4f28-11ea-9545-46d258b74454.png) + +[__Run the example__](https://stackblitz.com/edit/run-exclusive-hello-world?embed=1&file=index.ts) + +# Table of content + +- [Documentation](#documentation) + - [``build()``](#build) + - [``createGroupRef()``](#creategroupref) + - [``buildMethod()``](#buildmethod) + - [``buildCb()`` and ``buildMethodCb()``](#buildcb-and-buildmethodcb) + - [Queued calls](#queued-calls) + - [``getQueuedCallCount()``](#getqueuedcallcount) + - [``cancelAllQueuedCalls()``](#cancelallqueuedcalls) + - [``isRunning()``](#isrunning) + - [``getPrComplete()``](#getprcomplete) + +# Documentation + +## ``build()`` + +Let us compare regular functions with `run-exclusive` functions. + +````typescript +let alphabet= ""; + +//This function wait a random time then append a letter to alphabet. +async function spell(letter: string): Promise{ + + await new Promise( + resolve=> setTimeout( + resolve, + Math.random()*100 + ) + ); + + alphabet+=letter; + + return alphabet; + +} + +spell("a"); +spell("b"); +spell("c").then( message => console.log(message)); +//We cant predict what will be printed to the console, +//it can be "c", "ca", "ac", "cb", "bc", "cab", "cba", "bac", "bca", "acb" or "abc" + +```` +Now the same example using ``run-exclusive``: + +````typescript +import * as runExclusive from "run-exclusive"; + +let alphabet= ""; + +const spell= runExclusive.build( + async (letter: string): Promise => { + + await new Promise( + resolve=>setTimeout( + resolve, + Math.random()*100 + ) + ); + + alphabet+=letter; + + return alphabet; + + } +); + +spell("a"); +spell("b"); +spell("c").then( message => console.log(message)); // Always prints "abc" + +```` + +The types definition of the function passed as argument are conserved. +![Screenshot 2020-02-08 at 15 42 09](https://user-images.githubusercontent.com/6702424/74087111-9a6c8680-4a89-11ea-99f5-d5db809835f2.png) + +## ``createGroupRef()`` + +To share a unique lock among a group of functions. + +````typescript +import * as runExclusive from "run-exclusive"; + +let alphabet= ""; + +const groupSpelling= runExclusive.createGroupRef(); + +const spellUpperCase= runExclusive.build(groupSpelling + async (letter: string) => { + + await new Promise(resolve=> setTimeout(resolve, Math.random()*100)); + + alphabet+=letter.toUpperCase(); + + } +); + +const spellLowerCase= runExclusive.build(groupSpelling + async (letter: string) => { + + await new Promise(resolve=> setTimeout(resolve, Math.random()*100)); + + alphabet+=letter.toLowerCase(); + + } +); + +spell("a"); +spellUpperCase("b"); +spell("c").then(()=> console.log(alphabet)); //prints "aBc". +```` + +## ``buildMethod()`` + +If you define run exclusive class methods chances are you want the lock to be restricted +to the class's object instance. +This is what ``buildMethod()``is for. + +````typescript + +class Student { + + public alphabet= ""; + + public spell= runExclusive.buildMethod( + async (letter: string) => { + + await new Promise(resolve=> setTimeout(resolve, 1000)); + + this.alphabet+=letter.toLowerCase(); + + } + ); + +} + +const alice= new Student(); +const bob= new Student(); + +alice.spell("A"); +bob.spell("a"); +alice.spell("B"); +bob.spell("b"); +alice.spell("C").then( ()=> console.log(alice.alphabet)); //prints after 3s: "ABC" +bob.spell("c").then( ()=> console.log(bob.alphabet)); //prints after 3s: "abc" + +```` + +## ``buildCb()`` and ``buildMethodCb()`` + +`buildCb()` is the pending of `build()` for creating run exclusive functions that complete by invoking a callback. (Instead of resolving a promise). + +The only valid reason to use this instead of `build()` is to be able to retrieve the result synchronously. + + WARNING: If you make the callback optional the argument before it cannot be a function. +Be aware that the compiler won't warn you against it. +Example: ``(getLetter: ()=> string, callback?: (message: string)=> voidA) => {..}`` +is NOT a valid function to pass to ``buildCb()`` or ``buildMethodCb()``. +*Thanks @AnyhowStep* + +WARNING: The function should never throw as the exception wont be catchable. + +````typescript + +let alphabet= ""; + +const spell= runExclusive.buildCb( + (letter: string, callback?: (message: string)=> void) => { + + setTimeout(()=>{ + + alphabet+= letter; + + /* + Callback must always be called, event if the user + does not provide one, it is the only way for the module + to know that the function has completed it's execution. + You can assume that the callback function is not undefined. + To tell if the user has provided à callback you can access (callback as any).hasCallback; + */ + callback!(alphabet); + + }, Math.rand()*100); + + } +}; + +spell("a"); +spell("b"); +spell("c", message => console.log(message)); // prints "abc" + +```` + +NOTE: ``runExclusive.buildMethodCb()`` also available. + +## Queued calls + +It is possible to check, for a given run exclusive function, if there is currently +an ongoing execution and how many calls are queued. +It is also possible to cancel the queued calls. + +### ``getQueuedCallCount()`` + + Get the number of queued call of a run-exclusive function. + Note that if you call a runExclusive function and call this + directly after it will return 0 as there is one function call + execution ongoing but 0 queued. + + The classInstanceObject parameter is to provide only for the run-exclusive + function created with 'buildMethod[Cb]. + +```typescript +export declare function getQueuedCallCount( + runExclusiveFunction: Function, + classInstanceObject?: Object +): number; +``` + +### ``cancelAllQueuedCalls()`` +Cancel all queued calls of a run-exclusive function. +Note that the current running call will not be cancelled. + +The classInstanceObject parameter is to provide only for the run-exclusive +function created with 'buildMethod[Cb]. +```typescript +export declare function cancelAllQueuedCalls( + runExclusiveFunction: Function, + classInstanceObject?: Object +): number; +``` +### ``isRunning()`` + +Tell if a run-exclusive function has an instance of it's call currently being +performed. + +The classInstanceObject parameter is to provide only for the run-exclusive +function created with 'buildMethod[Cb]. +```typescript +export declare function isRunning( + runExclusiveFunction: Function, + classInstanceObject?: Object +): boolean; +``` + +### ``getPrComplete()`` + +Return a promise that resolve when all the current queued call of a runExclusive functions have completed. +The classInstanceObject parameter is to provide only for the run-exclusive +function created with 'buildMethod[Cb]. + +````typescript +export declare function getPrComplete( + runExclusiveFunction: Function, + classInstanceObject?: Object +): Promise; +```` + diff --git a/deno_dist/lib/runExclusive.ts b/deno_dist/lib/runExclusive.ts new file mode 100644 index 0000000..1a178b1 --- /dev/null +++ b/deno_dist/lib/runExclusive.ts @@ -0,0 +1,449 @@ + +import { Polyfill as WeakMap } from "https://raw.githubusercontent.com/garronej/minimal_polyfills/v2.1.5/deno_dist/WeakMap.ts"; + +class ExecQueue { + + public readonly queuedCalls: Function[]=[]; + + public isRunning: boolean= false; + + //TODO: move where it is used. + public cancelAllQueuedCalls(): number { + + let n: number; + + this.queuedCalls.splice(0, n=this.queuedCalls.length); + + return n; + + } + + public prComplete: Promise= Promise.resolve(); + + +} + + +const globalContext: Object = {}; + +const clusters = new WeakMap>(); + +//console.log("Map version"); +//export const clusters = new Map>(); + + +function getOrCreateExecQueue( + context: Object, + groupRef: GroupRef +): ExecQueue { + + let execQueueByGroup = clusters.get(context); + + if (!execQueueByGroup) { + execQueueByGroup = new WeakMap(); + clusters.set(context, execQueueByGroup); + } + + let execQueue= execQueueByGroup.get(groupRef); + + if (!execQueue){ + execQueue= new ExecQueue(); + execQueueByGroup.set(groupRef, execQueue); + } + + return execQueue; + +} + +export type GroupRef = never[]; + +export function createGroupRef(): GroupRef { + return new Array(0); +} + +/** + * Built a run-exclusive function from a function that return a promise. + */ +export function build Promise>(fun: T): T; +/** + * Built a run-exclusive function from a function that return a promise. + * + * The group ref parameter is used when in need that two or more different functions do nor run simultaneously. + * Group refs are created by calling createGroupRef(). + */ +export function build Promise>(groupRef: GroupRef, fun: T): T; +export function build(...inputs: any[]): any { + + switch (inputs.length) { + case 1: return buildFnPromise(true, createGroupRef(), inputs[0]); + case 2: return buildFnPromise(true, inputs[0], inputs[1]); + } + +} + + +/** Same as build but to restrict the exclusion to a class instance object. */ +export function buildMethod Promise>(fun: T): T; +export function buildMethod Promise>(groupRef: GroupRef, fun: T): T; +export function buildMethod(...inputs: any[]): any { + + switch (inputs.length) { + case 1: return buildFnPromise(false, createGroupRef(), inputs[0]); + case 2: return buildFnPromise(false, inputs[0], inputs[1]); + } + +} + +/** + * + * Get the number of queued call of a run-exclusive function. + * Note that if you call a runExclusive function and call this + * directly after it will return 0 as there is one function call + * execution ongoing but 0 queued. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + * + * */ +export function getQueuedCallCount( + runExclusiveFunction: Function, + classInstanceObject?: Object +): number { + + const execQueue= getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + + return execQueue?execQueue.queuedCalls.length:0; + +} + +/** + * + * Cancel all queued calls of a run-exclusive function. + * Note that the current running call will not be cancelled. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + * + */ +export function cancelAllQueuedCalls( + runExclusiveFunction: Function, + classInstanceObject?: Object +): number { + + const execQueue= getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + + return execQueue?execQueue.cancelAllQueuedCalls():0; + +} + +/** + * Tell if a run-exclusive function has an instance of it's call currently being + * performed. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + */ +export function isRunning( + runExclusiveFunction: Function, + classInstanceObject?: Object +): boolean { + + const execQueue= getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + + return execQueue?execQueue.isRunning:false; + +} + +/** + * Return a promise that resolve when all the current queued call of a runExclusive functions + * have completed. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + */ +export function getPrComplete( + runExclusiveFunction: Function, + classInstanceObject?: Object +): Promise{ + + const execQueue= getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + + return execQueue?execQueue.prComplete:Promise.resolve(); + +} + +const groupByRunExclusiveFunction= new WeakMap(); + +function getExecQueueByFunctionAndContext( + runExclusiveFunction: Function, + context = globalContext +): ExecQueue | undefined { + + const groupRef= groupByRunExclusiveFunction.get(runExclusiveFunction); + + if( !groupRef ){ + throw Error("Not a run exclusiveFunction"); + } + + const execQueueByGroup= clusters.get(context); + + if( !execQueueByGroup ){ + return undefined; + } + + return execQueueByGroup.get(groupRef)!; + +} + + +function buildFnPromise Promise>( + isGlobal: boolean, + groupRef: GroupRef, + fun: T +): T { + + let execQueue: ExecQueue; + + const runExclusiveFunction = (function (this: any, ...inputs) { + + if (!isGlobal) { + + if (!(this instanceof Object)) { + throw new Error("Run exclusive, should be an object"); + } + + execQueue = getOrCreateExecQueue(this, groupRef); + + } + + return new Promise((resolve, reject) => { + + let onPrCompleteResolve: () => void; + + execQueue.prComplete = new Promise(resolve => + onPrCompleteResolve = () => resolve() + ); + + const onComplete = (result: { data: any } | { reason: any }) => { + + onPrCompleteResolve(); + + execQueue.isRunning = false; + + if (execQueue.queuedCalls.length) { + execQueue.queuedCalls.shift()!(); + } + + if ("data" in result) { + resolve(result.data); + } else { + reject(result.reason); + } + + }; + + (function callee(this: any,...inputs: any[]) { + + if (execQueue.isRunning) { + execQueue.queuedCalls.push(() => callee.apply(this, inputs)); + return; + } + + execQueue.isRunning = true; + + try { + + fun.apply(this, inputs) + .then(data => onComplete({ data })) + .catch(reason => onComplete({ reason })) + ; + + } catch (error) { + + onComplete({ "reason": error }); + + } + + }).apply(this, inputs); + + }); + + }) as T; + + if (isGlobal) { + + execQueue = getOrCreateExecQueue(globalContext, groupRef); + + } + + groupByRunExclusiveFunction.set(runExclusiveFunction, groupRef); + + return runExclusiveFunction; + +} + +/** + * (Read all before using) + * + * The pending of 'build' for creating run exclusive functions that complete + * via calling a callback function. (Instead of returning a promise). + * + * The only valid reason to use this instead of ``build()`` is to be able to + * retrieve the result and/or release the lock synchronously when it's possible. + * + * If you want the callback to be optional it is possible to + * define the function as such: + * ``const myRunExclusiveFunction = buildCb((callback?)=> { ... });`` + * Anyway you must call it every time and assume it has been defined: + * ``callback!(...)``. + * + * To see if the user has actually provided a callback you can access the hidden property + * ``callback.hasCallback``. + * + * WARNING: You must also make sure, if you use an optional callback + * that the argument before it cannot be a function. + * Be aware that the compiler won't warn you against it. + * Example: ``(getLetter:()=> string, callback?:(res:string)=> void)=>{..}`` + * is NOT a valid function to pass to ``buildCb()`` + * + * WARNING: the source function should NEVER throw exception! + */ +export function buildCb void>(fun: T): T; +export function buildCb void>(groupRef: GroupRef, fun: T): T; +export function buildCb(...inputs: any[]): any { + + switch (inputs.length) { + case 1: return buildFnCallback(true, createGroupRef(), inputs[0]); + case 2: return buildFnCallback(true, inputs[0], inputs[1]); + } + +} + +/** + * (Read all before using) + * + * Pending of 'buildMethod' for function that return with callback instead of promise. + * + * The pending of 'build' for creating run exclusive functions that complete + * via calling a callback function. (Instead of returning a promise). + * + * The only valid reason to use this instead of ``build()`` is to be able to + * retrieve the result and/or release the lock synchronously when it's possible. + * + * If you want the callback to be optional it is possible to + * define the function as such: + * ``const myRunExclusiveFunction = buildCb((callback?)=> { ... });`` + * Anyway you must call it every time and assume it has been defined: + * ``callback!(...)``. + * + * To see if the user has actually provided a callback you can access the hidden property + * ``callback.hasCallback``. + * + * WARNING: You must also make sure, if you use an optional callback + * that the argument before it cannot be a function. + * Be aware that the compiler won't warn you against it. + * Example: ``(getLetter:()=> string, callback?:(res:string)=> void)=>{..}`` + * is NOT a valid function to pass to ``buildMethodCb()`` + * + * WARNING: the source function should NEVER throw exception! + * + */ +export function buildMethodCb void>(fun: T): T; +export function buildMethodCb void>(groupRef: GroupRef, fun: T): T; +export function buildMethodCb(...inputs: any[]): any { + + switch (inputs.length) { + case 1: return buildFnCallback(false, createGroupRef(), inputs[0]); + case 2: return buildFnCallback(false, inputs[0], inputs[1]); + } + +} + +function buildFnCallback Promise>( + isGlobal: boolean, + groupRef: GroupRef, + fun: T +): T { + + let execQueue: ExecQueue; + + const runExclusiveFunction = (function (this: any,...inputs) { + + + if (!isGlobal) { + + if (!(this instanceof Object)) { + throw new Error("Run exclusive, should be an object"); + } + + execQueue = getOrCreateExecQueue(this, groupRef); + + } + + let callback: Function | undefined = undefined; + + if (inputs.length && typeof inputs[inputs.length - 1] === "function") { + callback = inputs.pop(); + } + + let onPrCompleteResolve: () => void; + + execQueue.prComplete = new Promise(resolve => + onPrCompleteResolve = () => resolve() + ); + + const onComplete = (...inputs: any[]) => { + + onPrCompleteResolve(); + + execQueue!.isRunning = false; + + if (execQueue.queuedCalls.length) { + execQueue.queuedCalls.shift()!(); + } + + if (callback) { + callback.apply(this, inputs); + } + + }; + + (onComplete as any).hasCallback = !!callback; + + (function callee(this: any, ...inputs: any[]) { + + if (execQueue.isRunning) { + execQueue.queuedCalls.push(() => callee.apply(this, inputs)); + return; + } + + execQueue.isRunning = true; + + try { + + fun.apply(this, [...inputs, onComplete]); + + } catch (error) { + + error.message += " ( This exception should not have been thrown, miss use of run-exclusive buildCb )"; + + throw error; + + } + + }).apply(this, inputs); + + }) as T; + + if (isGlobal) { + + execQueue = getOrCreateExecQueue(globalContext, groupRef); + + } + + groupByRunExclusiveFunction.set(runExclusiveFunction, groupRef); + + return runExclusiveFunction; + +} + diff --git a/deno_dist/mod.ts b/deno_dist/mod.ts new file mode 100644 index 0000000..676104a --- /dev/null +++ b/deno_dist/mod.ts @@ -0,0 +1 @@ +export * from "./lib/runExclusive.ts"; \ No newline at end of file diff --git a/deno_dist/test/index.ts b/deno_dist/test/index.ts new file mode 100644 index 0000000..387aead --- /dev/null +++ b/deno_dist/test/index.ts @@ -0,0 +1,37 @@ + + +process.on("unhandledRejection", error=> { + console.log("INTERNAL ERROR"); + console.log(error); + throw error; +}); + +let n = process.argv[2]; + +if (n) { + + require("./test" + n); + +} else { + + require("./legacyTests/index"); + + for (let i = 1; i <= 18; i++) { + + try { + require("./test" + i); + } catch (error) { + + console.log(`Fail test ${i}`); + + throw error; + + + } + + } + + +} + +export {} \ No newline at end of file diff --git a/deno_dist/test/legacyTests/index.ts b/deno_dist/test/legacyTests/index.ts new file mode 100644 index 0000000..ca3d9a6 --- /dev/null +++ b/deno_dist/test/legacyTests/index.ts @@ -0,0 +1,17 @@ + +for (let i = 1; i <= 21; i++) { + + try { + require("./test" + i); + } catch (error) { + + console.log(`Fail test ${i}`); + + throw error; + + + } + +} + +export {} \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test1.ts b/deno_dist/test/legacyTests/test1.ts new file mode 100644 index 0000000..c6e18a6 --- /dev/null +++ b/deno_dist/test/legacyTests/test1.ts @@ -0,0 +1,43 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + private alphabetStack = ""; + + public myMethodStack = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabetStack += char; + callback!(this.alphabetStack); + }, Math.random() * 1000); + + } + ); + + +} + +let inst = new MyClass(); + +for (let char of ["a", "b", "c", "d", "e", "f"]) + inst.myMethodStack(char, alphabet => console.log(`step ${alphabet}`)); + + +for (let char of ["g", "h", "i"]) + inst.myMethodStack(char); + +inst.myMethodStack("j", alphabet => { + + console.log(`completed ${alphabet}`); + + //cSpell: disable + console.assert(alphabet === "abcdefghij"); + //cSpell: enable + + console.log("PASS"); + +}); + diff --git a/deno_dist/test/legacyTests/test10.ts b/deno_dist/test/legacyTests/test10.ts new file mode 100644 index 0000000..9413cd5 --- /dev/null +++ b/deno_dist/test/legacyTests/test10.ts @@ -0,0 +1,57 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, 1000); + + } + ); + + +} + +let inst = new MyClass(); + + +setTimeout(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + + console.assert(inst.alphabet === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(inst.alphabet === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethod(char, alphabet => console.log(`step ${alphabet}`)); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + diff --git a/deno_dist/test/legacyTests/test11.ts b/deno_dist/test/legacyTests/test11.ts new file mode 100644 index 0000000..e3db7c2 --- /dev/null +++ b/deno_dist/test/legacyTests/test11.ts @@ -0,0 +1,85 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, 1000); + + } + ); + + +} + +class MyClassProxy { + + constructor() { }; + + private myClassInst = new MyClass(); + + public callCount = 0; + + public getAlphabet(): typeof MyClass.prototype.alphabet { + return this.myClassInst.alphabet; + } + + + public myMethod: typeof MyClass.prototype.myMethod = + runExclusive.buildMethodCb( + (...inputs) => { + + this.callCount++; + + return this.myClassInst.myMethod.apply(this.myClassInst, inputs); + + } + ); + +} + +let inst = new MyClassProxy(); + + +setTimeout(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + + console.assert(inst.getAlphabet() === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(inst.getAlphabet() === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false ); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true ); + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethod(char, alphabet => console.log(`step ${alphabet}`)); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true ); + + +console.assert(inst.callCount === 1); + diff --git a/deno_dist/test/legacyTests/test12.ts b/deno_dist/test/legacyTests/test12.ts new file mode 100644 index 0000000..2e6753c --- /dev/null +++ b/deno_dist/test/legacyTests/test12.ts @@ -0,0 +1,101 @@ +//Import ExecStack to be able to export stacked function +import * as runExclusive from "../../lib/runExclusive.ts"; +import { VoidEvt } from "https://raw.githubusercontent.com/garronej/ts-evt/v1.8.7/deno_dist/mod.ts"; + +export class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, 1000); + + } + ); + + +} + +export class MyClassProxy { + + + private myClassInst: MyClass | undefined = undefined; + + public readonly evtCreate = new VoidEvt(); + + public getAlphabet(): typeof MyClass.prototype.alphabet { + if (!this.myClassInst) return ""; + else return this.myClassInst.alphabet; + } + + constructor() { + + setTimeout(() => { + this.myClassInst = new MyClass(); + this.evtCreate.post(); + }, 1000); + + } + + public myMethod = runExclusive.buildMethodCb( + function callee(this: any, ...inputs) { + + let self = this as MyClassProxy; + + if (!self.myClassInst) { + + self.evtCreate.attachOnce(() => callee.apply(this, inputs)); + return; + + } + + self.myClassInst.myMethod.apply(self.myClassInst, inputs); + + + } as typeof MyClass.prototype.myMethod); + +} + +let inst = new MyClassProxy(); + + +setTimeout(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + + console.assert(inst.getAlphabet() === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(inst.getAlphabet() === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900 + 1000); + + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethod(char, alphabet => console.log(`step ${alphabet}`)); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + + diff --git a/deno_dist/test/legacyTests/test13.ts b/deno_dist/test/legacyTests/test13.ts new file mode 100644 index 0000000..c436744 --- /dev/null +++ b/deno_dist/test/legacyTests/test13.ts @@ -0,0 +1,39 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, 1000); + + } + ); + + +} + +let inst = new MyClass(); + + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + +inst.myMethod("a", () => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + + console.log("PASS"); + +}); + + + diff --git a/deno_dist/test/legacyTests/test14.ts b/deno_dist/test/legacyTests/test14.ts new file mode 100644 index 0000000..30c9c87 --- /dev/null +++ b/deno_dist/test/legacyTests/test14.ts @@ -0,0 +1,41 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, 1000); + + } + ); + + +} + +let inst = new MyClass(); + + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + +inst.myMethod("a", () => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + console.log("PASS"); + +}); +inst.myMethod("b"); + + + diff --git a/deno_dist/test/legacyTests/test15.ts b/deno_dist/test/legacyTests/test15.ts new file mode 100644 index 0000000..f9c32d3 --- /dev/null +++ b/deno_dist/test/legacyTests/test15.ts @@ -0,0 +1,50 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, 1000); + + } + ); + + +} + +let inst = new MyClass(); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + +inst.myMethod("a", () => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 1); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + +}); +inst.myMethod("b", () => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + +}); +inst.myMethod("c", () => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + console.log("PASS"); + +}); + + + diff --git a/deno_dist/test/legacyTests/test16.ts b/deno_dist/test/legacyTests/test16.ts new file mode 100644 index 0000000..5b6187f --- /dev/null +++ b/deno_dist/test/legacyTests/test16.ts @@ -0,0 +1,106 @@ +//Import ExecStack to be able to export stacked function +import * as runExclusive from "../../lib/runExclusive.ts"; +import { VoidEvt } from "https://raw.githubusercontent.com/garronej/ts-evt/v1.8.7/deno_dist/mod.ts"; + +export class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, 1000); + + } + ); + + +} + +export class MyClassProxy { + + + private myClassInst: MyClass | undefined = undefined; + + public readonly evtCreate = new VoidEvt(); + + public getAlphabet(): typeof MyClass.prototype.alphabet { + if (!this.myClassInst) return ""; + else return this.myClassInst.alphabet; + } + + constructor() { + + setTimeout(() => { + this.myClassInst = new MyClass(); + this.evtCreate.post(); + }, 1000); + + } + + public myMethod = runExclusive.buildMethodCb( + function callee(this: any,...inputs) { + + let self = this as MyClassProxy; + + if (!self.myClassInst) { + + self.evtCreate.attachOnce(() => callee.apply(this, inputs)); + return; + + } + + self.myClassInst.myMethod.apply(self.myClassInst, inputs); + + + } as typeof MyClass.prototype.myMethod); + + + +} + +let inst = new MyClassProxy(); + + +setTimeout(() => { + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + + console.assert(inst.getAlphabet() === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + + console.assert(inst.getAlphabet() === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900 + 1000); + + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethod(char, alphabet => console.log(`step ${alphabet}`)); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + + diff --git a/deno_dist/test/legacyTests/test17.ts b/deno_dist/test/legacyTests/test17.ts new file mode 100644 index 0000000..ce411f0 --- /dev/null +++ b/deno_dist/test/legacyTests/test17.ts @@ -0,0 +1,57 @@ +//Import ExecStack to be able to export stacked function +import * as runExclusive from "../../lib/runExclusive.ts"; +import { Evt } from "https://raw.githubusercontent.com/garronej/ts-evt/v1.8.7/deno_dist/mod.ts"; + +export class MyClass { + + constructor() { }; + + public readonly evtNoCallback = new Evt(); + + public myMethod = runExclusive.buildMethodCb( + (message: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + + if (!(callback as any).hasCallback) + this.evtNoCallback.post(message); + + + callback!(message) + }, 1000); + + } + ); + + +} + + +let inst = new MyClass(); + +let success = false + +inst.evtNoCallback.attach(message => { + + console.assert(message === "noCallback"); + + success = true; + +}); + +inst.myMethod("callback", message => console.assert("callback" === message)); +inst.myMethod("noCallback"); + +setTimeout(() => { + + console.assert(success); + + console.log("DONE"); + + +}, 2500); + + + + + diff --git a/deno_dist/test/legacyTests/test18.ts b/deno_dist/test/legacyTests/test18.ts new file mode 100644 index 0000000..83f33e5 --- /dev/null +++ b/deno_dist/test/legacyTests/test18.ts @@ -0,0 +1,43 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; +import { Evt } from "https://raw.githubusercontent.com/garronej/ts-evt/v1.8.7/deno_dist/mod.ts"; + +export class MyClass { + + constructor() { }; + + public readonly evtNoCallback = new Evt(); + + public myMethod = runExclusive.buildMethodCb( + (message: string, callback?: (alphabet: string) => void): void => { + + if (!(callback as any).hasCallback) + this.evtNoCallback.post(message); + + callback!(message) + + } + ); + + +} + + +let inst = new MyClass(); + +let success = false + +inst.evtNoCallback.attach(message => { + + console.assert(message === "noCallback"); + + success = true; + +}); + +inst.myMethod("noCallback"); +inst.myMethod("callback", message => console.assert("callback" === message)); + + +console.assert(success); + +console.log("DONE"); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test19.ts b/deno_dist/test/legacyTests/test19.ts new file mode 100644 index 0000000..80d6efe --- /dev/null +++ b/deno_dist/test/legacyTests/test19.ts @@ -0,0 +1,66 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +let runCount= 0; + +export class MyClass{ + + constructor() { }; + + public myMethod = runExclusive.buildMethodCb( + (input: string, callback?: (out1: string, out2: number) => void): Promise<[string, number]> => { + + setTimeout(()=> { + + runCount++; + + callback!(input + " 0K", 666) + + }, 1000); + + return null as any; + + } + ); + +} + +let inst= new MyClass(); + +(async()=> { + + let [ out1, out2 ]= await new Promise<[string, number]>( + resolve=> inst.myMethod("yo", (out1, out2)=> resolve([ out1, out2 ])) + ); + + console.assert(out1 === "yo 0K" && out2 === 666 ); + + inst.myMethod("ya", (out1, out2)=> console.assert(out1 == "ya 0K" && out2 === 666)); + + inst.myMethod("foo"); + + setTimeout(()=> { + + console.assert(runCount === 2); + + }, 1100); + + setTimeout(()=> { + + console.assert(runCount === 3); + + console.log("DONE"); + + }, 3100); + + +})(); + + + + + + + + + + diff --git a/deno_dist/test/legacyTests/test2.ts b/deno_dist/test/legacyTests/test2.ts new file mode 100644 index 0000000..3d3ee1c --- /dev/null +++ b/deno_dist/test/legacyTests/test2.ts @@ -0,0 +1,61 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + private alphabetStack = ""; + + private groupRef = runExclusive.createGroupRef(); + + public myMethodUpperCase = runExclusive.buildMethodCb( + this.groupRef, + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabetStack += char.toUpperCase(); + callback!(this.alphabetStack); + }, Math.random() * 1000); + + } + ); + + + public myMethod = runExclusive.buildMethodCb( + this.groupRef, + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabetStack += char; + callback!(this.alphabetStack); + }, Math.random() * 1000); + + } + ); + + +} + +let inst = new MyClass(); + + +inst.myMethod("a"); + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethodUpperCase(char, alphabet => console.log(`step ${alphabet}`)); + + +for (let char of ["g", "h", "i"]) + inst.myMethod(char, alphabet => console.log(`step ${alphabet}`)); + +inst.myMethod("j", alphabet => { + + console.log(`completed ${alphabet}`) + + //cSpell: disable + console.assert(alphabet === "aBCDEFghij"); + //cSpell: enable + + console.log("PASS"); + +}); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test20.ts b/deno_dist/test/legacyTests/test20.ts new file mode 100644 index 0000000..0326b5d --- /dev/null +++ b/deno_dist/test/legacyTests/test20.ts @@ -0,0 +1,58 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +let runCount= 0; + +export class MyClass{ + + constructor() { }; + + public myMethod = runExclusive.buildMethodCb( + (input: number, callback?: (out: string) => void): Promise => { + + setTimeout(()=> { + + runCount++; + + callback!("input: " + input.toString()) + + }, 1000); + + return null as any; + + } + ); + +} + +let inst= new MyClass(); + +(async()=> { + + let out= await new Promise( + resolve=> inst.myMethod(111, out=> resolve(out)) + ); + + console.log(out); + console.log( out === "input: 111"); + + inst.myMethod(222, out => console.log(out === "input: 222")); + + inst.myMethod(333); + + + setTimeout(()=> { + + console.assert(runCount === 2); + + }, 1100); + + setTimeout(()=> { + + console.assert(runCount === 3); + + console.log("DONE"); + + }, 3100); + + +})(); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test21.ts b/deno_dist/test/legacyTests/test21.ts new file mode 100644 index 0000000..02b1346 --- /dev/null +++ b/deno_dist/test/legacyTests/test21.ts @@ -0,0 +1,14 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +let runExclusiveFunction= runExclusive.buildCb( + (callback)=> callback() +); + +let cbTriggered= false; + + +runExclusiveFunction(()=> cbTriggered = true ); + +console.assert( cbTriggered ); + +console.log("PASS"); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test3.ts b/deno_dist/test/legacyTests/test3.ts new file mode 100644 index 0000000..540af1f --- /dev/null +++ b/deno_dist/test/legacyTests/test3.ts @@ -0,0 +1,78 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethodCb( + runExclusive.createGroupRef(), + (char: string, wait: number, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, wait); + + } + ); + + +} + + +let start = Date.now(); + +let inst1 = new MyClass(); + +inst1.myMethod("a", 1000, alphabet => console.log(alphabet)); +inst1.myMethod("b", 1000, alphabet => console.log(alphabet)); + +let inst2 = new MyClass(); + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst2.myMethod(char, wait, alphabet => console.log(alphabet)); +inst2.myMethod("a", wait, function (this: any) { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(this.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + + let expectedDuration = (rev.length + 1) * 500; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + + +}); + +inst1.myMethod("c", 1000, alphabet => console.log(alphabet)); +inst1.myMethod("d", 1000, () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + + let expectedDuration = 1000 * 4; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + +}); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test4.ts b/deno_dist/test/legacyTests/test4.ts new file mode 100644 index 0000000..8a7a163 --- /dev/null +++ b/deno_dist/test/legacyTests/test4.ts @@ -0,0 +1,75 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethodCb( + (char: string, wait: number, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, wait); + + } + ); + +} + + +let start = Date.now(); + +let inst1 = new MyClass(); + +inst1.myMethod("a", 1000, alphabet => console.log(alphabet)); +inst1.myMethod("b", 1000, alphabet => console.log(alphabet)); + +let inst2 = new MyClass(); + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst2.myMethod(char, wait, alphabet => console.log(alphabet)); +inst2.myMethod("a", wait, function (this: any) { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(this.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + + let expectedDuration = (rev.length + 1) * wait; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + + +}); + +inst1.myMethod("c", 1000, alphabet => console.log(alphabet)); +inst1.myMethod("d", 1000, () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + + let expectedDuration = 1000 * 4; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + +}); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test5.ts b/deno_dist/test/legacyTests/test5.ts new file mode 100644 index 0000000..b73c6db --- /dev/null +++ b/deno_dist/test/legacyTests/test5.ts @@ -0,0 +1,68 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public static readonly groupRef = runExclusive.createGroupRef(); + + public myMethod = runExclusive.buildMethodCb(MyClass.groupRef, + (char: string, wait: number, callback?: (alphabet: string)=> void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, wait); + + } + ); + + +} + + +let start = Date.now(); + +let inst1 = new MyClass(); + +inst1.myMethod.call(MyClass, "a", 1000, alphabet => console.log(alphabet)); +inst1.myMethod.call(MyClass, "b", 1000, alphabet => console.log(alphabet)); + +let inst2 = new MyClass(); + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst2.myMethod.call(MyClass, char, wait, alphabet => console.log(alphabet)); + +inst2.myMethod.call(MyClass, "a", wait, function () { + + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + +}); + +inst1.myMethod.call(MyClass, "c", 1000, alphabet => console.log(alphabet)); +inst1.myMethod.call(MyClass, "d", 1000, () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + + let expectedDuration = 1000 * 4 + (rev.length + 1) * wait; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + +}); diff --git a/deno_dist/test/legacyTests/test6.ts b/deno_dist/test/legacyTests/test6.ts new file mode 100644 index 0000000..0a6f5fd --- /dev/null +++ b/deno_dist/test/legacyTests/test6.ts @@ -0,0 +1,90 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +const groupRefAlphabet = runExclusive.createGroupRef(); + +class MyClass1 { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildCb(groupRefAlphabet, + (char: string, wait: number, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char.toUpperCase(); + callback!(this.alphabet); + }, wait); + + }); + +} + + + +class MyClass2 { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildCb(groupRefAlphabet, + (char: string, wait: number, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, wait); + + } + ); + +} + + + + +let start = Date.now(); + +let inst1 = new MyClass1(); + +inst1.myMethod("a", 1000, alphabet => console.log(alphabet)); +inst1.myMethod("b", 1000, alphabet => console.log(alphabet)); + +let inst2 = new MyClass2(); + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev){ + inst2.myMethod(char, wait, alphabet => console.log(alphabet)); +} + +inst2.myMethod("a", wait, function (this: any) { + + //cSpell: disable + console.assert(this.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + +}); + +inst1.myMethod("c", 1000, alphabet => console.log(alphabet)); +inst1.myMethod("d", 1000, () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst1.alphabet === "ABCD"); + //cSpell: enable + + let expectedDuration = 1000 * 4 + (rev.length + 1) * 500; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + +}); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test7.ts b/deno_dist/test/legacyTests/test7.ts new file mode 100644 index 0000000..e5a0e0d --- /dev/null +++ b/deno_dist/test/legacyTests/test7.ts @@ -0,0 +1,92 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod1 = runExclusive.buildMethodCb(runExclusive.createGroupRef(), + (char: string, wait: number, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, wait); + + } + ); + + public alphabet2 = ""; + + public myMethod2 = runExclusive.buildMethodCb( + (char: string, wait: number, callback?: (alphabet: string) => void): void => { + + let safeCallback = callback || function () { }; + + setTimeout(() => { + this.alphabet2 += char; + safeCallback(this.alphabet2); + }, wait); + + } + ); + + +} + + +let start = Date.now(); + +let inst = new MyClass(); + +inst.myMethod1("a", 1000, alphabet => console.log(alphabet)); +inst.myMethod1("b", 1000, alphabet => console.log(alphabet)); + + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst.myMethod2(char, wait, alphabet => console.log(alphabet)); +inst.myMethod2("a", wait, function (this: any) { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(this.alphabet2 === "nmlkjihgfedcba"); + //cSpell: enable + + let expectedDuration = (rev.length + 1) * wait; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + + +}); + +inst.myMethod1("c", 1000, alphabet => console.log(alphabet)); +inst.myMethod1("d", 1000, () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst.alphabet === "abcd"); + //cSpell: enable + + let expectedDuration = 1000 * 4; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + +}); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test8.ts b/deno_dist/test/legacyTests/test8.ts new file mode 100644 index 0000000..35b3203 --- /dev/null +++ b/deno_dist/test/legacyTests/test8.ts @@ -0,0 +1,95 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod1 = runExclusive.buildMethodCb( + (char: string, wait: number, callback?: (alphabet: string) => void): void => { + + let safeCallback = callback || function () { }; + + setTimeout(() => { + this.alphabet += char; + safeCallback(this.alphabet); + }, wait); + + } + ); + + + public alphabet2 = ""; + + public myMethod2 = runExclusive.buildMethodCb( + (char: string, wait: number, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet2 += char; + callback!(this.alphabet2); + }, wait); + + } + ); + + + + +} + + +let start = Date.now(); + +let inst = new MyClass(); + +inst.myMethod1("a", 1000, alphabet => console.log(alphabet)); +inst.myMethod1("b", 1000, alphabet => console.log(alphabet)); + + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst.myMethod2(char, wait, alphabet => console.log(alphabet)); +inst.myMethod2("a", wait, function (this: any) { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(this.alphabet2 === "nmlkjihgfedcba"); + //cSpell: enable + + let expectedDuration = (rev.length + 1) * 500; + + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + + +}); + +inst.myMethod1("c", 1000, alphabet => console.log(alphabet)); +inst.myMethod1("d", 1000, () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst.alphabet === "abcd"); + //cSpell: enable + + let expectedDuration = 1000 * 4; + + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + +}); \ No newline at end of file diff --git a/deno_dist/test/legacyTests/test9.ts b/deno_dist/test/legacyTests/test9.ts new file mode 100644 index 0000000..7bed597 --- /dev/null +++ b/deno_dist/test/legacyTests/test9.ts @@ -0,0 +1,49 @@ +import * as runExclusive from "../../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethodCb( + (char: string, callback?: (alphabet: string) => void): void => { + + setTimeout(() => { + this.alphabet += char; + callback!(this.alphabet); + }, 1000); + + } + ); + + +} + +let inst = new MyClass(); + + +setTimeout(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + + console.assert(inst.alphabet === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(inst.alphabet === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900); + +for (let char of ["a", "b", "c", "d", "e", "f"]){ + + inst.myMethod(char, alphabet => console.log(`step ${alphabet}`)); + +} \ No newline at end of file diff --git a/deno_dist/test/mod.ts b/deno_dist/test/mod.ts new file mode 100644 index 0000000..81fd32c --- /dev/null +++ b/deno_dist/test/mod.ts @@ -0,0 +1,23 @@ + +declare const console: any; + +console.log("DENO TEST"); + +import "./test1.ts"; +import "./test2.ts"; +import "./test3.ts"; +import "./test4.ts"; +import "./test5.ts"; +import "./test6.ts"; +import "./test7.ts"; +import "./test8.ts"; +import "./test9.ts"; +import "./test10.ts"; +import "./test11.ts"; + +import "./test13.ts"; +import "./test14.ts"; +import "./test15.ts"; +import "./test16.ts"; +import "./test17.ts"; +import "./test18.ts"; \ No newline at end of file diff --git a/deno_dist/test/test1.ts b/deno_dist/test/test1.ts new file mode 100644 index 0000000..30a8576 --- /dev/null +++ b/deno_dist/test/test1.ts @@ -0,0 +1,46 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + private alphabetStack = ""; + + public myMethodStack = runExclusive.buildMethod( + (char: string): Promise => { + + return new Promise(resolve => { + + setTimeout(() => { + this.alphabetStack += char; + resolve(this.alphabetStack); + }, Math.random() * 1000); + + }); + + } + ); + + +} + +let inst = new MyClass(); + +for (let char of ["a", "b", "c", "d", "e", "f"]) + inst.myMethodStack(char).then( alphabet => console.log(`step ${alphabet}`) ); + + +for (let char of ["g", "h", "i"]) + inst.myMethodStack(char); + +inst.myMethodStack("j").then( alphabet => { + + console.log(`completed ${alphabet}`); + + //cSpell: disable + console.assert(alphabet === "abcdefghij"); + //cSpell: enable + + console.log("PASS"); + +}); diff --git a/deno_dist/test/test10.ts b/deno_dist/test/test10.ts new file mode 100644 index 0000000..4598712 --- /dev/null +++ b/deno_dist/test/test10.ts @@ -0,0 +1,58 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethod( + async (char: string): Promise => { + + await new Promise(resolve => setTimeout(()=> resolve(), 1000)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + + +} + +let inst = new MyClass(); + + +setTimeout(() => { + + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + + console.assert(inst.alphabet === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(inst.alphabet === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900); + + + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false ); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst)===0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true ); + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethod(char).then( alphabet => console.log(`step ${alphabet}`)); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst)=== 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true ); \ No newline at end of file diff --git a/deno_dist/test/test11.ts b/deno_dist/test/test11.ts new file mode 100644 index 0000000..c64d542 --- /dev/null +++ b/deno_dist/test/test11.ts @@ -0,0 +1,82 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethod( + async (char: string): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), 1000)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + + +} + +class MyClassProxy { + + constructor() { }; + + private myClassInst = new MyClass(); + + public callCount = 0; + + public getAlphabet(): typeof MyClass.prototype.alphabet { + return this.myClassInst.alphabet; + } + + public myMethod: typeof MyClass.prototype.myMethod = + runExclusive.buildMethod( + (...inputs)=>{ + + this.callCount++; + + return this.myClassInst.myMethod.apply(this.myClassInst, inputs); + + } + ); + + +} + +let inst = new MyClassProxy(); + +setTimeout(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + + console.assert(inst.getAlphabet() === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(inst.getAlphabet() === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false ); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true ); + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethod(char).then( alphabet => console.log(`step ${alphabet}`)); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true ); + +console.assert(inst.callCount === 1); diff --git a/deno_dist/test/test12.ts b/deno_dist/test/test12.ts new file mode 100644 index 0000000..6c5e2f9 --- /dev/null +++ b/deno_dist/test/test12.ts @@ -0,0 +1,109 @@ +import * as runExclusive from "../lib/runExclusive.ts"; +import { VoidEvt } from "https://raw.githubusercontent.com/garronej/ts-evt/v1.8.7/deno_dist/mod.ts"; + +export class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethod( + async (char: string): Promise => { + + await new Promise(resolve => setTimeout(resolve, 1000)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + + +} + +export class MyClassProxy { + + private myClassInst: MyClass | undefined = undefined; + + public readonly evtCreate = new VoidEvt(); + + public getAlphabet(): typeof MyClass.prototype.alphabet { + if (!this.myClassInst) return ""; + else return this.myClassInst.alphabet; + } + + constructor() { + + setTimeout(() => { + this.myClassInst = new MyClass(); + this.evtCreate.post(); + }, 1000); + + } + + public myMethod: typeof MyClass.prototype.myMethod = + runExclusive.buildMethod( + (...inputs) => { + + let self = this; + + return new Promise(function callee(resolve, reject) { + + if (!self.myClassInst) { + + self.evtCreate.attachOnce(() => callee(resolve, reject)); + return; + + } + + self.myClassInst.myMethod.apply(self.myClassInst, inputs) + .then(resolve) + .catch(reject); + + }); + + } + ); + + +} + +let inst = new MyClassProxy(); + + +setTimeout(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + + console.assert(inst.getAlphabet() === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + + console.assert(inst.getAlphabet() === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900 + 1000); + + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethod(char).then(alphabet => console.log(`step ${alphabet}`)); + + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); diff --git a/deno_dist/test/test13.ts b/deno_dist/test/test13.ts new file mode 100644 index 0000000..68a1db3 --- /dev/null +++ b/deno_dist/test/test13.ts @@ -0,0 +1,39 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethod( + async (char: string): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), 1000)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + + +} + +let inst = new MyClass(); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + +inst.myMethod("a").then( () => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + + console.log("PASS"); + +}); + + + diff --git a/deno_dist/test/test14.ts b/deno_dist/test/test14.ts new file mode 100644 index 0000000..7b31670 --- /dev/null +++ b/deno_dist/test/test14.ts @@ -0,0 +1,40 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethod( + async (char: string): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), 1000)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + + +} + +let inst = new MyClass(); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + +inst.myMethod("a").then(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + console.log("PASS"); + +}); +inst.myMethod("b"); + + + diff --git a/deno_dist/test/test15.ts b/deno_dist/test/test15.ts new file mode 100644 index 0000000..c30063a --- /dev/null +++ b/deno_dist/test/test15.ts @@ -0,0 +1,49 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + + public myMethod = runExclusive.buildMethod( + async (char: string): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), 1000)); + + this.alphabet += char; + + return this.alphabet; + + }); + + +} + +let inst = new MyClass(); + +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + +inst.myMethod("a").then(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 1); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + +}); +inst.myMethod("b").then(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + + +}); +inst.myMethod("c").then(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + + console.log("PASS"); + +}); diff --git a/deno_dist/test/test16.ts b/deno_dist/test/test16.ts new file mode 100644 index 0000000..23dda4e --- /dev/null +++ b/deno_dist/test/test16.ts @@ -0,0 +1,60 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +let runCount= 0; + +export class MyClass{ + + constructor() { }; + + public myMethod = runExclusive.buildMethod( + async (input: string): Promise<[string, number]> => { + + await new Promise(resolve=> setTimeout(()=>resolve(), 1000)); + + runCount++; + + return [input + " 0K", 666]; + + } + ); + +} + +let inst= new MyClass(); + +(async()=> { + + let [ out1, out2 ]= await inst.myMethod("yo") + + console.assert(out1 === "yo 0K" && out2 === 666 ); + + inst.myMethod("ya").then(([out1, out2])=> console.assert(out1 == "ya 0K" && out2 === 666)); + + inst.myMethod("foo"); + + setTimeout(()=> { + + console.assert(runCount === 2); + + }, 1100); + + setTimeout(()=> { + + console.assert(runCount === 3); + + console.log("DONE"); + + }, 3100); + + +})(); + + + + + + + + + + diff --git a/deno_dist/test/test17.ts b/deno_dist/test/test17.ts new file mode 100644 index 0000000..acbc0a6 --- /dev/null +++ b/deno_dist/test/test17.ts @@ -0,0 +1,54 @@ +//Import ExecStack to be able to export stacked function + +import * as runExclusive from "../lib/runExclusive.ts"; + +let runCount = 0; + +export class MyClass { + + constructor() { }; + + public myMethod = runExclusive.buildMethod( + async (input: number): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), 1000)); + + runCount++; + + return "input: " + input.toString(); + + + } + ); + +} + +let inst = new MyClass(); + +(async () => { + + let out = await inst.myMethod(111); + + console.log(out); + console.log(out === "input: 111"); + + inst.myMethod(222).then(out => console.log(out === "input: 222")); + + inst.myMethod(333); + + setTimeout(() => { + + console.assert(runCount === 2); + + }, 1100); + + setTimeout(() => { + + console.assert(runCount === 3); + + console.log("DONE"); + + }, 3100); + + +})(); diff --git a/deno_dist/test/test18.ts b/deno_dist/test/test18.ts new file mode 100644 index 0000000..2d8ce8f --- /dev/null +++ b/deno_dist/test/test18.ts @@ -0,0 +1,32 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +let alphabet= ""; + +const myFunction = runExclusive.build( + async (char: string) => { + + await new Promise(resolve=> setTimeout(resolve, 10)); + + alphabet+= char; + + } +); + + +(async ()=>{ + + + myFunction("a"); + + myFunction("b"); + + runExclusive.getPrComplete(myFunction).then(()=> { + + console.assert(alphabet === "ab"); + }); + + await myFunction("c"); + + console.assert(alphabet === "abc"); + +})(); diff --git a/deno_dist/test/test2.ts b/deno_dist/test/test2.ts new file mode 100644 index 0000000..601c029 --- /dev/null +++ b/deno_dist/test/test2.ts @@ -0,0 +1,59 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass{ + + constructor(){}; + + private readonly groupRefAlphabet= runExclusive.createGroupRef(); + + private alphabetStack= ""; + + public myMethodUpperCase = runExclusive.buildMethod(this.groupRefAlphabet, + async (char: string ): Promise => { + + await new Promise(resolve=> setTimeout(()=>resolve(), Math.random()*1000)); + + this.alphabetStack += char.toUpperCase(); + + return this.alphabetStack; + + } + ); + + public myMethod = runExclusive.buildMethod(this.groupRefAlphabet, + async (char: string ): Promise => { + + await new Promise(resolve=> setTimeout(()=>resolve(), Math.random()*1000)); + + this.alphabetStack += char; + + return this.alphabetStack; + + } + ); + + +} + +let inst = new MyClass(); + +inst.myMethod("a"); + +for (let char of ["b", "c", "d", "e", "f"]) + inst.myMethodUpperCase(char).then( alphabet => console.log(`step ${alphabet}`)); + + +for (let char of ["g", "h", "i"]) + inst.myMethod(char).then( alphabet => console.log(`step ${alphabet}`)); + +inst.myMethod("j").then( alphabet => { + + console.log(`completed ${alphabet}`) + + //cSpell: disable + console.assert(alphabet === "aBCDEFghij"); + //cSpell: enable + + console.log("PASS"); + +}); \ No newline at end of file diff --git a/deno_dist/test/test3.ts b/deno_dist/test/test3.ts new file mode 100644 index 0000000..78002d5 --- /dev/null +++ b/deno_dist/test/test3.ts @@ -0,0 +1,77 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass{ + + constructor(){}; + + public alphabet= ""; + + public myMethod= runExclusive.buildMethod(runExclusive.createGroupRef(), + async (char: string, wait: number): Promise => { + + await new Promise(resolve=> setTimeout(()=>resolve(), wait)); + + this.alphabet += char; + + return this.alphabet; + + }); + + +} + + +let start= Date.now(); + +let inst1= new MyClass(); + +inst1.myMethod("a", 1000).then( alphabet=> console.log(alphabet)); +inst1.myMethod("b", 1000).then( alphabet=> console.log(alphabet)); + +let inst2= new MyClass(); + +let rev= [ "n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b" ]; +let wait= 500; + +for( let char of rev) + inst2.myMethod(char, wait).then( alphabet => console.log(alphabet)); + +inst2.myMethod("a", wait).then( function() { + + let duration= Date.now() - start; + + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba" ); + //cSpell: enable + + let expectedDuration= (rev.length+1)*500; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert( Math.abs( duration - expectedDuration) < 300 ); + console.assert( duration - expectedDuration >= 0 ); + + console.log("PASS"); + + +}); + +inst1.myMethod("c", 1000).then( alphabet=> console.log(alphabet)); +inst1.myMethod("d", 1000).then( ()=>{ + + let duration= Date.now() - start; + + //cSpell: disable + console.assert(inst1.alphabet === "abcd" ); + //cSpell: enable + + let expectedDuration= 1000*4; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert( Math.abs( duration - expectedDuration) < 300 ); + console.assert( duration - expectedDuration >= 0 ); + +}); \ No newline at end of file diff --git a/deno_dist/test/test4.ts b/deno_dist/test/test4.ts new file mode 100644 index 0000000..4c6f525 --- /dev/null +++ b/deno_dist/test/test4.ts @@ -0,0 +1,77 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethod( + async (char: string, wait: number): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), wait)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + +} + + +let start = Date.now(); + +let inst1 = new MyClass(); + +inst1.myMethod("a", 1000).then( alphabet => console.log(alphabet)); +inst1.myMethod("b", 1000).then( alphabet => console.log(alphabet)); + +let inst2 = new MyClass(); + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst2.myMethod(char, wait).then( alphabet => console.log(alphabet)); + +inst2.myMethod("a", wait).then( function () { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + + let expectedDuration = (rev.length + 1) * wait; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + + +}); + +inst1.myMethod("c", 1000).then( alphabet => console.log(alphabet)); +inst1.myMethod("d", 1000).then( () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + + let expectedDuration = 1000 * 4; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + +}); \ No newline at end of file diff --git a/deno_dist/test/test5.ts b/deno_dist/test/test5.ts new file mode 100644 index 0000000..7cbf6bd --- /dev/null +++ b/deno_dist/test/test5.ts @@ -0,0 +1,69 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public static readonly groupRef = runExclusive.createGroupRef(); + + public myMethod = runExclusive.buildMethod(MyClass.groupRef, + async (char: string, wait: number): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), wait)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + + +} + + +let start = Date.now(); + +let inst1 = new MyClass(); + +inst1.myMethod.call(MyClass, "a", 1000).then(alphabet => console.log(alphabet)); +inst1.myMethod.call(MyClass, "b", 1000).then(alphabet => console.log(alphabet)); + +let inst2 = new MyClass(); + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst2.myMethod.call(MyClass, char, wait).then(alphabet => console.log(alphabet)); + +inst2.myMethod.call(MyClass, "a", wait).then(function () { + + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + +}); + +inst1.myMethod.call(MyClass, "c", 1000).then(alphabet => console.log(alphabet)); +inst1.myMethod.call(MyClass, "d", 1000).then(() => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + + let expectedDuration = 1000 * 4 + (rev.length + 1) * wait; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + +}); \ No newline at end of file diff --git a/deno_dist/test/test6.ts b/deno_dist/test/test6.ts new file mode 100644 index 0000000..b97c207 --- /dev/null +++ b/deno_dist/test/test6.ts @@ -0,0 +1,88 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +const groupRefAlphabet= runExclusive.createGroupRef(); + +class MyClass1 { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.build(groupRefAlphabet, + async (char: string, wait: number): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), wait)); + + this.alphabet += char.toUpperCase(); + + return this.alphabet; + + }); + +} + +class MyClass2 { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.build(groupRefAlphabet, + async (char: string, wait: number): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), wait)); + + this.alphabet += char; + + return this.alphabet; + + }); + +} + + + + +let start = Date.now(); + +let inst1 = new MyClass1(); + +inst1.myMethod("a", 1000).then( alphabet => console.log(alphabet)); +inst1.myMethod("b", 1000).then( alphabet => console.log(alphabet)); + +let inst2 = new MyClass2(); + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst2.myMethod(char, wait).then( alphabet => console.log(alphabet)); + +inst2.myMethod("a", wait).then( function () { + + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + +}); + +inst1.myMethod("c", 1000 ).then( alphabet => console.log(alphabet)); +inst1.myMethod("d", 1000 ).then( () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst1.alphabet === "ABCD"); + //cSpell: enable + + let expectedDuration = 1000 * 4 + (rev.length + 1) * 500; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + +}); \ No newline at end of file diff --git a/deno_dist/test/test7.ts b/deno_dist/test/test7.ts new file mode 100644 index 0000000..08ba367 --- /dev/null +++ b/deno_dist/test/test7.ts @@ -0,0 +1,94 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass{ + + constructor(){}; + + public alphabet= ""; + + public myMethod1= runExclusive.buildMethod(runExclusive.createGroupRef(), + async (char: string, wait: number): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), wait)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + + public alphabet2 = ""; + + public myMethod2 = runExclusive.buildMethod( + async (char: string, wait: number): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), wait)); + + this.alphabet2 += char; + + return this.alphabet2; + + } + ); + + + + +} + + +let start = Date.now(); + +let inst = new MyClass(); + +inst.myMethod1("a", 1000).then( alphabet => console.log(alphabet) ); +inst.myMethod1("b", 1000).then( alphabet => console.log(alphabet) ); + + +let rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +let wait = 500; + +for (let char of rev) + inst.myMethod2(char, wait).then( alphabet => console.log(alphabet)); + +inst.myMethod2("a", wait ).then( function () { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst.alphabet2 === "nmlkjihgfedcba"); + //cSpell: enable + + let expectedDuration = (rev.length + 1) * wait; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + console.log("PASS"); + + +}); + +inst.myMethod1("c", 1000).then( alphabet => console.log(alphabet)); +inst.myMethod1("d", 1000).then( () => { + + let duration = Date.now() - start; + + //cSpell: disable + console.assert(inst.alphabet === "abcd"); + //cSpell: enable + + let expectedDuration = 1000 * 4; + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + + +}); \ No newline at end of file diff --git a/deno_dist/test/test8.ts b/deno_dist/test/test8.ts new file mode 100644 index 0000000..330422c --- /dev/null +++ b/deno_dist/test/test8.ts @@ -0,0 +1,89 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass{ + + constructor(){}; + + public alphabet= ""; + + public myMethod1= runExclusive.buildMethod( + async (char: string, wait: number): Promise => { + + await new Promise(resolve=>setTimeout(()=>resolve(),wait)); + + this.alphabet+= char; + + return this.alphabet; + + }); + + public alphabet2= ""; + + public myMethod2= runExclusive.buildMethod( + async (char: string, wait: number): Promise => { + + await new Promise(resolve=>setTimeout(()=>resolve(),wait)); + + this.alphabet2+= char; + + return this.alphabet2; + + }); + +} + + +let start= Date.now(); + +let inst= new MyClass(); + +inst.myMethod1("a", 1000).then( alphabet=> console.log(alphabet)); +inst.myMethod1("b", 1000).then( alphabet=> console.log(alphabet)); + + +let rev= [ "n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b" ]; +let wait= 500; + +for( let char of rev) + inst.myMethod2(char, wait ).then( alphabet => console.log(alphabet)); +inst.myMethod2("a", wait ).then( function() { + + let duration= Date.now() - start; + + //cSpell: disable + console.assert(inst.alphabet2 === "nmlkjihgfedcba" ); + //cSpell: enable + + let expectedDuration= (rev.length+1)*500; + + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert( Math.abs(duration - expectedDuration) < 300 ); + console.assert( duration - expectedDuration >= 0 ); + + console.log("PASS"); + + +}); + +inst.myMethod1("c", 1000).then( alphabet=> console.log(alphabet)); +inst.myMethod1("d", 1000).then( ()=>{ + + let duration= Date.now() - start; + + //cSpell: disable + console.assert(inst.alphabet === "abcd" ); + //cSpell: enable + + let expectedDuration= 1000*4; + + + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + + console.assert( Math.abs(duration - expectedDuration) < 300 ); + console.assert( duration - expectedDuration >= 0 ); + +}); \ No newline at end of file diff --git a/deno_dist/test/test9.ts b/deno_dist/test/test9.ts new file mode 100644 index 0000000..16ae227 --- /dev/null +++ b/deno_dist/test/test9.ts @@ -0,0 +1,47 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +class MyClass { + + constructor() { }; + + public alphabet = ""; + + public myMethod = runExclusive.buildMethod( + async (char: string): Promise => { + + await new Promise(resolve => setTimeout(()=>resolve(), 1000)); + + this.alphabet += char; + + return this.alphabet; + + } + ); + + +} + +let inst = new MyClass(); + +setTimeout(() => { + + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3) + + console.assert(inst.alphabet === "ab"); + + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + + setTimeout(() => { + + console.assert(inst.alphabet === "abc"); + + console.log("PASS"); + + }, 2000); + +}, 2900); + +for (let char of ["a", "b", "c", "d", "e", "f"]){ + inst.myMethod(char).then(alphabet => console.log(`step ${alphabet}`)); +} + diff --git a/deno_dist/test/testMem1.ts b/deno_dist/test/testMem1.ts new file mode 100644 index 0000000..8c8c4e2 --- /dev/null +++ b/deno_dist/test/testMem1.ts @@ -0,0 +1,52 @@ + +import * as runExclusive from "../lib/runExclusive.ts"; + +function print_mem() { + + const used = process.memoryUsage(); + for (let key in used) { + console.log(`${key} ${Math.round((used as any)[key] / 1024 / 1024 * 100) / 100} MB`); + } + +} + +class A { + + public alphabet= ""; + + public myMethod = runExclusive.buildMethod( + async (char: string) => { + + if( char === "a" ){ + + await new Promise(resolve => process.nextTick(resolve)); + //await new Promise(resolve => setTimeout(resolve,0)); + + } + + this.alphabet+= char; + } + ); + +} + +(async () => { + + while (true) { + + for (let i = 0; i < 7000; i++) { + + const a = new A(); + + a.myMethod("a"); + await a.myMethod("b"); + + console.assert(a.alphabet === "ab"); + + } + + print_mem(); + + } + +})(); \ No newline at end of file diff --git a/deno_dist/test/testMem2.ts b/deno_dist/test/testMem2.ts new file mode 100644 index 0000000..135b07a --- /dev/null +++ b/deno_dist/test/testMem2.ts @@ -0,0 +1,47 @@ +import * as runExclusive from "../lib/runExclusive.ts"; + +function print_mem() { + + const used = process.memoryUsage(); + for (let key in used) { + console.log(`${key} ${Math.round((used as any)[key] / 1024 / 1024 * 100) / 100} MB`); + } + +} + +console.log("GLOBAL"); + +(async () => { + + while (true) { + + for (let i = 0; i < 7000; i++) { + + let alphabet= ""; + + const myFunction= runExclusive.build(async (char: string)=> { + + if( char === "a" ){ + + await new Promise(resolve=> process.nextTick(resolve)); + + } + + alphabet+= char + + }); + + myFunction("a"); + await myFunction("b"); + + console.assert(alphabet === "ab"); + + } + + print_mem(); + + } + +})(); + + diff --git a/lib/runExclusive.d.ts b/lib/runExclusive.d.ts new file mode 100644 index 0000000..bc08843 --- /dev/null +++ b/lib/runExclusive.d.ts @@ -0,0 +1,113 @@ +export declare type GroupRef = never[]; +export declare function createGroupRef(): GroupRef; +/** + * Built a run-exclusive function from a function that return a promise. + */ +export declare function build Promise>(fun: T): T; +/** + * Built a run-exclusive function from a function that return a promise. + * + * The group ref parameter is used when in need that two or more different functions do nor run simultaneously. + * Group refs are created by calling createGroupRef(). + */ +export declare function build Promise>(groupRef: GroupRef, fun: T): T; +/** Same as build but to restrict the exclusion to a class instance object. */ +export declare function buildMethod Promise>(fun: T): T; +export declare function buildMethod Promise>(groupRef: GroupRef, fun: T): T; +/** + * + * Get the number of queued call of a run-exclusive function. + * Note that if you call a runExclusive function and call this + * directly after it will return 0 as there is one function call + * execution ongoing but 0 queued. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + * + * */ +export declare function getQueuedCallCount(runExclusiveFunction: Function, classInstanceObject?: Object): number; +/** + * + * Cancel all queued calls of a run-exclusive function. + * Note that the current running call will not be cancelled. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + * + */ +export declare function cancelAllQueuedCalls(runExclusiveFunction: Function, classInstanceObject?: Object): number; +/** + * Tell if a run-exclusive function has an instance of it's call currently being + * performed. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + */ +export declare function isRunning(runExclusiveFunction: Function, classInstanceObject?: Object): boolean; +/** + * Return a promise that resolve when all the current queued call of a runExclusive functions + * have completed. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + */ +export declare function getPrComplete(runExclusiveFunction: Function, classInstanceObject?: Object): Promise; +/** + * (Read all before using) + * + * The pending of 'build' for creating run exclusive functions that complete + * via calling a callback function. (Instead of returning a promise). + * + * The only valid reason to use this instead of ``build()`` is to be able to + * retrieve the result and/or release the lock synchronously when it's possible. + * + * If you want the callback to be optional it is possible to + * define the function as such: + * ``const myRunExclusiveFunction = buildCb((callback?)=> { ... });`` + * Anyway you must call it every time and assume it has been defined: + * ``callback!(...)``. + * + * To see if the user has actually provided a callback you can access the hidden property + * ``callback.hasCallback``. + * + * WARNING: You must also make sure, if you use an optional callback + * that the argument before it cannot be a function. + * Be aware that the compiler won't warn you against it. + * Example: ``(getLetter:()=> string, callback?:(res:string)=> void)=>{..}`` + * is NOT a valid function to pass to ``buildCb()`` + * + * WARNING: the source function should NEVER throw exception! + */ +export declare function buildCb void>(fun: T): T; +export declare function buildCb void>(groupRef: GroupRef, fun: T): T; +/** + * (Read all before using) + * + * Pending of 'buildMethod' for function that return with callback instead of promise. + * + * The pending of 'build' for creating run exclusive functions that complete + * via calling a callback function. (Instead of returning a promise). + * + * The only valid reason to use this instead of ``build()`` is to be able to + * retrieve the result and/or release the lock synchronously when it's possible. + * + * If you want the callback to be optional it is possible to + * define the function as such: + * ``const myRunExclusiveFunction = buildCb((callback?)=> { ... });`` + * Anyway you must call it every time and assume it has been defined: + * ``callback!(...)``. + * + * To see if the user has actually provided a callback you can access the hidden property + * ``callback.hasCallback``. + * + * WARNING: You must also make sure, if you use an optional callback + * that the argument before it cannot be a function. + * Be aware that the compiler won't warn you against it. + * Example: ``(getLetter:()=> string, callback?:(res:string)=> void)=>{..}`` + * is NOT a valid function to pass to ``buildMethodCb()`` + * + * WARNING: the source function should NEVER throw exception! + * + */ +export declare function buildMethodCb void>(fun: T): T; +export declare function buildMethodCb void>(groupRef: GroupRef, fun: T): T; diff --git a/lib/runExclusive.js b/lib/runExclusive.js new file mode 100644 index 0000000..0e8106c --- /dev/null +++ b/lib/runExclusive.js @@ -0,0 +1,280 @@ +"use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; +exports.__esModule = true; +exports.buildMethodCb = exports.buildCb = exports.getPrComplete = exports.isRunning = exports.cancelAllQueuedCalls = exports.getQueuedCallCount = exports.buildMethod = exports.build = exports.createGroupRef = void 0; +var WeakMap_1 = require("minimal-polyfills/WeakMap"); +var ExecQueue = /** @class */ (function () { + function ExecQueue() { + this.queuedCalls = []; + this.isRunning = false; + this.prComplete = Promise.resolve(); + } + //TODO: move where it is used. + ExecQueue.prototype.cancelAllQueuedCalls = function () { + var n; + this.queuedCalls.splice(0, n = this.queuedCalls.length); + return n; + }; + return ExecQueue; +}()); +var globalContext = {}; +var clusters = new WeakMap_1.Polyfill(); +//console.log("Map version"); +//export const clusters = new Map>(); +function getOrCreateExecQueue(context, groupRef) { + var execQueueByGroup = clusters.get(context); + if (!execQueueByGroup) { + execQueueByGroup = new WeakMap_1.Polyfill(); + clusters.set(context, execQueueByGroup); + } + var execQueue = execQueueByGroup.get(groupRef); + if (!execQueue) { + execQueue = new ExecQueue(); + execQueueByGroup.set(groupRef, execQueue); + } + return execQueue; +} +function createGroupRef() { + return new Array(0); +} +exports.createGroupRef = createGroupRef; +function build() { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + switch (inputs.length) { + case 1: return buildFnPromise(true, createGroupRef(), inputs[0]); + case 2: return buildFnPromise(true, inputs[0], inputs[1]); + } +} +exports.build = build; +function buildMethod() { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + switch (inputs.length) { + case 1: return buildFnPromise(false, createGroupRef(), inputs[0]); + case 2: return buildFnPromise(false, inputs[0], inputs[1]); + } +} +exports.buildMethod = buildMethod; +/** + * + * Get the number of queued call of a run-exclusive function. + * Note that if you call a runExclusive function and call this + * directly after it will return 0 as there is one function call + * execution ongoing but 0 queued. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + * + * */ +function getQueuedCallCount(runExclusiveFunction, classInstanceObject) { + var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + return execQueue ? execQueue.queuedCalls.length : 0; +} +exports.getQueuedCallCount = getQueuedCallCount; +/** + * + * Cancel all queued calls of a run-exclusive function. + * Note that the current running call will not be cancelled. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + * + */ +function cancelAllQueuedCalls(runExclusiveFunction, classInstanceObject) { + var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + return execQueue ? execQueue.cancelAllQueuedCalls() : 0; +} +exports.cancelAllQueuedCalls = cancelAllQueuedCalls; +/** + * Tell if a run-exclusive function has an instance of it's call currently being + * performed. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + */ +function isRunning(runExclusiveFunction, classInstanceObject) { + var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + return execQueue ? execQueue.isRunning : false; +} +exports.isRunning = isRunning; +/** + * Return a promise that resolve when all the current queued call of a runExclusive functions + * have completed. + * + * The classInstanceObject parameter is to provide only for the run-exclusive + * function created with 'buildMethod[Cb]. + */ +function getPrComplete(runExclusiveFunction, classInstanceObject) { + var execQueue = getExecQueueByFunctionAndContext(runExclusiveFunction, classInstanceObject); + return execQueue ? execQueue.prComplete : Promise.resolve(); +} +exports.getPrComplete = getPrComplete; +var groupByRunExclusiveFunction = new WeakMap_1.Polyfill(); +function getExecQueueByFunctionAndContext(runExclusiveFunction, context) { + if (context === void 0) { context = globalContext; } + var groupRef = groupByRunExclusiveFunction.get(runExclusiveFunction); + if (!groupRef) { + throw Error("Not a run exclusiveFunction"); + } + var execQueueByGroup = clusters.get(context); + if (!execQueueByGroup) { + return undefined; + } + return execQueueByGroup.get(groupRef); +} +function buildFnPromise(isGlobal, groupRef, fun) { + var execQueue; + var runExclusiveFunction = (function () { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + if (!isGlobal) { + if (!(this instanceof Object)) { + throw new Error("Run exclusive, should be an object"); + } + execQueue = getOrCreateExecQueue(this, groupRef); + } + return new Promise(function (resolve, reject) { + var onPrCompleteResolve; + execQueue.prComplete = new Promise(function (resolve) { + return onPrCompleteResolve = function () { return resolve(); }; + }); + var onComplete = function (result) { + onPrCompleteResolve(); + execQueue.isRunning = false; + if (execQueue.queuedCalls.length) { + execQueue.queuedCalls.shift()(); + } + if ("data" in result) { + resolve(result.data); + } + else { + reject(result.reason); + } + }; + (function callee() { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + if (execQueue.isRunning) { + execQueue.queuedCalls.push(function () { return callee.apply(_this, inputs); }); + return; + } + execQueue.isRunning = true; + try { + fun.apply(this, inputs) + .then(function (data) { return onComplete({ data: data }); })["catch"](function (reason) { return onComplete({ reason: reason }); }); + } + catch (error) { + onComplete({ "reason": error }); + } + }).apply(_this, inputs); + }); + }); + if (isGlobal) { + execQueue = getOrCreateExecQueue(globalContext, groupRef); + } + groupByRunExclusiveFunction.set(runExclusiveFunction, groupRef); + return runExclusiveFunction; +} +function buildCb() { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + switch (inputs.length) { + case 1: return buildFnCallback(true, createGroupRef(), inputs[0]); + case 2: return buildFnCallback(true, inputs[0], inputs[1]); + } +} +exports.buildCb = buildCb; +function buildMethodCb() { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + switch (inputs.length) { + case 1: return buildFnCallback(false, createGroupRef(), inputs[0]); + case 2: return buildFnCallback(false, inputs[0], inputs[1]); + } +} +exports.buildMethodCb = buildMethodCb; +function buildFnCallback(isGlobal, groupRef, fun) { + var execQueue; + var runExclusiveFunction = (function () { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + if (!isGlobal) { + if (!(this instanceof Object)) { + throw new Error("Run exclusive, should be an object"); + } + execQueue = getOrCreateExecQueue(this, groupRef); + } + var callback = undefined; + if (inputs.length && typeof inputs[inputs.length - 1] === "function") { + callback = inputs.pop(); + } + var onPrCompleteResolve; + execQueue.prComplete = new Promise(function (resolve) { + return onPrCompleteResolve = function () { return resolve(); }; + }); + var onComplete = function () { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + onPrCompleteResolve(); + execQueue.isRunning = false; + if (execQueue.queuedCalls.length) { + execQueue.queuedCalls.shift()(); + } + if (callback) { + callback.apply(_this, inputs); + } + }; + onComplete.hasCallback = !!callback; + (function callee() { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + if (execQueue.isRunning) { + execQueue.queuedCalls.push(function () { return callee.apply(_this, inputs); }); + return; + } + execQueue.isRunning = true; + try { + fun.apply(this, __spreadArrays(inputs, [onComplete])); + } + catch (error) { + error.message += " ( This exception should not have been thrown, miss use of run-exclusive buildCb )"; + throw error; + } + }).apply(this, inputs); + }); + if (isGlobal) { + execQueue = getOrCreateExecQueue(globalContext, groupRef); + } + groupByRunExclusiveFunction.set(runExclusiveFunction, groupRef); + return runExclusiveFunction; +} +//# sourceMappingURL=runExclusive.js.map \ No newline at end of file diff --git a/lib/runExclusive.js.map b/lib/runExclusive.js.map new file mode 100644 index 0000000..d6121e8 --- /dev/null +++ b/lib/runExclusive.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runExclusive.js","sourceRoot":"","sources":["../src/lib/runExclusive.ts"],"names":[],"mappings":";;;;;;;;;;AACA,qDAAgE;AAEhE;IAAA;QAEoB,gBAAW,GAAa,EAAE,CAAC;QAEpC,cAAS,GAAW,KAAK,CAAC;QAa1B,eAAU,GAAiB,OAAO,CAAC,OAAO,EAAE,CAAC;IAGxD,CAAC;IAdG,8BAA8B;IACvB,wCAAoB,GAA3B;QAEI,IAAI,CAAS,CAAC;QAEd,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAEtD,OAAO,CAAC,CAAC;IAEb,CAAC;IAKL,gBAAC;AAAD,CAAC,AApBD,IAoBC;AAGD,IAAM,aAAa,GAAW,EAAE,CAAC;AAEjC,IAAM,QAAQ,GAAG,IAAI,kBAAO,EAAuC,CAAC;AAEpE,6BAA6B;AAC7B,qEAAqE;AAGrE,SAAS,oBAAoB,CACzB,OAAe,EACf,QAAkB;IAGlB,IAAI,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,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AAC,IAAI,iBAAM,MAAM,GAAE,UAAU,GAAE,CAAC;aAE5C;YAAC,OAAO,KAAK,EAAE;gBAEZ,KAAK,CAAC,OAAO,IAAI,oFAAoF,CAAC;gBAEtG,MAAM,KAAK,CAAC;aAEf;QAEL,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE3B,CAAC,CAAM,CAAC;IAER,IAAI,QAAQ,EAAE;QAEV,SAAS,GAAG,oBAAoB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;KAE7D;IAED,2BAA2B,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAEhE,OAAO,oBAAoB,CAAC;AAEhC,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 3ed8351..b25bf49 100755 --- a/package.json +++ b/package.json @@ -6,20 +6,8 @@ "type": "git", "url": "git://github.com/garronej/run_exclusive.git" }, - "main": "dist/lib/runExclusive.js", - "types": "dist/lib/runExclusive.d.ts", - "scripts": { - "test:node": "node ./dist/test", - "test:deno": "deno run --reload ./deno_dist/test/mod.ts", - "test": "npm run test:node && npm run test:deno", - "tsc": "npx tsc", - "denoify": "npx denoify", - "cdn:.js": "simplifyify dist/lib/runExclusive.js -s runExclusive -o dist/bundle.js --debug --bundle", - "cdn:.min.js": "terser dist/bundle.js -cmo dist/bundle.min.js", - "cdn": "npm run cdn:.js && npm run cdn:.min.js", - "build": "tsc && denoify && npm run cdn", - "enable_short_import_path": "npm run build && npx denoify_enable_short_npm_import_path" - }, + "main": "lib/runExclusive.js", + "types": "lib/runExclusive.d.ts", "author": "u/garronej", "license": "MIT", "keywords": [ @@ -45,8 +33,12 @@ "terser": "4.6.13" }, "files": [ - "/dist/lib/", - "/dist/bundle.{js,js.map,min.js}", - "/src/lib/" + "lib/runExclusive.d.ts", + "lib/runExclusive.js", + "lib/runExclusive.js.map", + "bundle.js", + "bundle.js.map", + "bundle.min.js", + "src/lib/runExclusive.ts" ] } diff --git a/test/index.d.ts b/test/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/index.js b/test/index.js new file mode 100644 index 0000000..eff3711 --- /dev/null +++ b/test/index.js @@ -0,0 +1,24 @@ +"use strict"; +exports.__esModule = true; +process.on("unhandledRejection", function (error) { + console.log("INTERNAL ERROR"); + console.log(error); + throw error; +}); +var n = process.argv[2]; +if (n) { + require("./test" + n); +} +else { + require("./legacyTests/index"); + for (var i = 1; i <= 18; i++) { + try { + require("./test" + i); + } + catch (error) { + console.log("Fail test " + i); + throw error; + } + } +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/test/index.js.map b/test/index.js.map new file mode 100644 index 0000000..1072783 --- /dev/null +++ b/test/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/test/index.ts"],"names":[],"mappings":";;AAEA,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAA,KAAK;IAClC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,MAAM,KAAK,CAAC;AAChB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAExB,IAAI,CAAC,EAAE;IAEH,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;CAEzB;KAAM;IAEH,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAE/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;QAE1B,IAAI;YACA,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;SACzB;QAAC,OAAO,KAAK,EAAE;YAEZ,OAAO,CAAC,GAAG,CAAC,eAAa,CAAG,CAAC,CAAC;YAE9B,MAAM,KAAK,CAAC;SAGf;KAEJ;CAGJ"} \ No newline at end of file diff --git a/test/legacyTests/index.d.ts b/test/legacyTests/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/index.js b/test/legacyTests/index.js new file mode 100644 index 0000000..308ff74 --- /dev/null +++ b/test/legacyTests/index.js @@ -0,0 +1,12 @@ +"use strict"; +exports.__esModule = true; +for (var i = 1; i <= 21; i++) { + try { + require("./test" + i); + } + catch (error) { + console.log("Fail test " + i); + throw error; + } +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/test/legacyTests/index.js.map b/test/legacyTests/index.js.map new file mode 100644 index 0000000..a3b6b61 --- /dev/null +++ b/test/legacyTests/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/legacyTests/index.ts"],"names":[],"mappings":";;AACA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IAE1B,IAAI;QACA,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;KACzB;IAAC,OAAO,KAAK,EAAE;QAEZ,OAAO,CAAC,GAAG,CAAC,eAAa,CAAG,CAAC,CAAC;QAE9B,MAAM,KAAK,CAAC;KAGf;CAEJ"} \ No newline at end of file diff --git a/test/legacyTests/test1.d.ts b/test/legacyTests/test1.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test1.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test1.js b/test/legacyTests/test1.js new file mode 100644 index 0000000..5c6d02b --- /dev/null +++ b/test/legacyTests/test1.js @@ -0,0 +1,34 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabetStack = ""; + this.myMethodStack = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabetStack += char; + callback(_this.alphabetStack); + }, Math.random() * 1000); + }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +for (var _i = 0, _a = ["a", "b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethodStack(char, function (alphabet) { return console.log("step " + alphabet); }); +} +for (var _b = 0, _c = ["g", "h", "i"]; _b < _c.length; _b++) { + var char = _c[_b]; + inst.myMethodStack(char); +} +inst.myMethodStack("j", function (alphabet) { + console.log("completed " + alphabet); + //cSpell: disable + console.assert(alphabet === "abcdefghij"); + //cSpell: enable + console.log("PASS"); +}); +//# sourceMappingURL=test1.js.map \ No newline at end of file diff --git a/test/legacyTests/test1.js.map b/test/legacyTests/test1.js.map new file mode 100644 index 0000000..e3ad8dd --- /dev/null +++ b/test/legacyTests/test1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test1.js","sourceRoot":"","sources":["../../src/test/legacyTests/test1.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAET,kBAAa,GAAG,EAAE,CAAC;QAEpB,kBAAa,GAAG,YAAY,CAAC,aAAa,CAC7C,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,aAAa,IAAI,IAAI,CAAC;gBAC3B,QAAS,CAAC,KAAI,CAAC,aAAa,CAAC,CAAC;YAClC,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QAE7B,CAAC,CACJ,CAAC;IAbc,CAAC;IAAA,CAAC;IAgBtB,cAAC;AAAD,CAAC,AAlBD,IAkBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,KAAiB,UAA8B,EAA9B,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAA9B,cAA8B,EAA9B,IAA8B;IAA1C,IAAI,IAAI,SAAA;IACT,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,UAAQ,QAAU,CAAC,EAA/B,CAA+B,CAAC,CAAC;CAAA;AAG1E,KAAiB,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe;IAA3B,IAAI,IAAI,SAAA;IACT,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;CAAA;AAE7B,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,UAAA,QAAQ;IAE5B,OAAO,CAAC,GAAG,CAAC,eAAa,QAAU,CAAC,CAAC;IAErC,iBAAiB;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC;IAC1C,gBAAgB;IAEhB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test10.d.ts b/test/legacyTests/test10.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test10.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test10.js b/test/legacyTests/test10.js new file mode 100644 index 0000000..ae3751e --- /dev/null +++ b/test/legacyTests/test10.js @@ -0,0 +1,39 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, 1000); + }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.alphabet === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(inst.alphabet === "abc"); + console.log("PASS"); + }, 2000); +}, 2900); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char, function (alphabet) { return console.log("step " + alphabet); }); +} +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +//# sourceMappingURL=test10.js.map \ No newline at end of file diff --git a/test/legacyTests/test10.js.map b/test/legacyTests/test10.js.map new file mode 100644 index 0000000..4a6570d --- /dev/null +++ b/test/legacyTests/test10.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test10.js","sourceRoot":"","sources":["../../src/test/legacyTests/test10.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAGzB,UAAU,CAAC;IAEP,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAE3E,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;I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,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test11.d.ts b/test/legacyTests/test11.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test11.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test11.js b/test/legacyTests/test11.js new file mode 100644 index 0000000..70200bd --- /dev/null +++ b/test/legacyTests/test11.js @@ -0,0 +1,60 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, 1000); + }); + } + ; + return MyClass; +}()); +var MyClassProxy = /** @class */ (function () { + function MyClassProxy() { + var _this = this; + this.myClassInst = new MyClass(); + this.callCount = 0; + this.myMethod = runExclusive.buildMethodCb(function () { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + _this.callCount++; + return _this.myClassInst.myMethod.apply(_this.myClassInst, inputs); + }); + } + ; + MyClassProxy.prototype.getAlphabet = function () { + return this.myClassInst.alphabet; + }; + return MyClassProxy; +}()); +var inst = new MyClassProxy(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.getAlphabet() === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(inst.getAlphabet() === "abc"); + console.log("PASS"); + }, 2000); +}, 2900); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char, function (alphabet) { return console.log("step " + alphabet); }); +} +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +console.assert(inst.callCount === 1); +//# sourceMappingURL=test11.js.map \ No newline at end of file diff --git a/test/legacyTests/test11.js.map b/test/legacyTests/test11.js.map new file mode 100644 index 0000000..9130e5c --- /dev/null +++ b/test/legacyTests/test11.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test11.js","sourceRoot":"","sources":["../../src/test/legacyTests/test11.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED;IAEI;QAAA,iBAAiB;QAET,gBAAW,GAAG,IAAI,OAAO,EAAE,CAAC;QAE7B,cAAS,GAAG,CAAC,CAAC;QAOd,aAAQ,GACf,YAAY,CAAC,aAAa,CACtB;YAAC,gBAAS;iBAAT,UAAS,EAAT,qBAAS,EAAT,IAAS;gBAAT,2BAAS;;YAEN,KAAI,CAAC,SAAS,EAAE,CAAC;YAEjB,OAAO,KAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAErE,CAAC,CACJ,CAAC;IApBc,CAAC;IAAA,CAAC;IAMX,kCAAW,GAAlB;QACI,O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AG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAzB,cAAyB,EAAzB,IAAyB;IAArC,IAAI,IAAI,SAAA;IACT,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,UAAQ,QAAU,CAAC,EAA/B,CAA+B,CAAC,CAAC;CAAA;AAErE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAE,CAAC;AAGtE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test12.d.ts b/test/legacyTests/test12.d.ts new file mode 100644 index 0000000..ea3965c --- /dev/null +++ b/test/legacyTests/test12.d.ts @@ -0,0 +1,13 @@ +import { VoidEvt } from "ts-evt"; +export declare class MyClass { + constructor(); + alphabet: string; + myMethod: (char: string, callback?: ((alphabet: string) => void) | undefined) => void; +} +export declare class MyClassProxy { + private myClassInst; + readonly evtCreate: VoidEvt; + getAlphabet(): typeof MyClass.prototype.alphabet; + constructor(); + myMethod: (char: string, callback?: ((alphabet: string) => void) | undefined) => void; +} diff --git a/test/legacyTests/test12.js b/test/legacyTests/test12.js new file mode 100644 index 0000000..7bdac40 --- /dev/null +++ b/test/legacyTests/test12.js @@ -0,0 +1,75 @@ +"use strict"; +exports.__esModule = true; +exports.MyClassProxy = exports.MyClass = void 0; +//Import ExecStack to be able to export stacked function +var runExclusive = require("../../lib/runExclusive"); +var ts_evt_1 = require("ts-evt"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, 1000); + }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var MyClassProxy = /** @class */ (function () { + function MyClassProxy() { + var _this = this; + this.myClassInst = undefined; + this.evtCreate = new ts_evt_1.VoidEvt(); + this.myMethod = runExclusive.buildMethodCb(function callee() { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + var self = this; + if (!self.myClassInst) { + self.evtCreate.attachOnce(function () { return callee.apply(_this, inputs); }); + return; + } + self.myClassInst.myMethod.apply(self.myClassInst, inputs); + }); + setTimeout(function () { + _this.myClassInst = new MyClass(); + _this.evtCreate.post(); + }, 1000); + } + MyClassProxy.prototype.getAlphabet = function () { + if (!this.myClassInst) + return ""; + else + return this.myClassInst.alphabet; + }; + return MyClassProxy; +}()); +exports.MyClassProxy = MyClassProxy; +var inst = new MyClassProxy(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.getAlphabet() === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(inst.getAlphabet() === "abc"); + console.log("PASS"); + }, 2000); +}, 2900 + 1000); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char, function (alphabet) { return console.log("step " + alphabet); }); +} +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +//# sourceMappingURL=test12.js.map \ No newline at end of file diff --git a/test/legacyTests/test12.js.map b/test/legacyTests/test12.js.map new file mode 100644 index 0000000..9daaac3 --- /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AC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AAGrE,KAAiB,UAAyB,EAAzB,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAzB,cAAyB,EAAzB,IAAyB;IAArC,IAAI,IAAI,SAAA;IACT,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,UAAQ,QAAU,CAAC,EAA/B,CAA+B,CAAC,CAAC;CAAA;AAErE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test13.d.ts b/test/legacyTests/test13.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test13.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test13.js b/test/legacyTests/test13.js new file mode 100644 index 0000000..045ef2b --- /dev/null +++ b/test/legacyTests/test13.js @@ -0,0 +1,26 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, 1000); + }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a", function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + console.log("PASS"); +}); +//# sourceMappingURL=test13.js.map \ No newline at end of file diff --git a/test/legacyTests/test13.js.map b/test/legacyTests/test13.js.map new file mode 100644 index 0000000..0b160e3 --- /dev/null +++ b/test/legacyTests/test13.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test13.js","sourceRoot":"","sources":["../../src/test/legacyTests/test13.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAbc,CAAC;IAAA,CAAC;IAgBtB,cAAC;AAAD,CAAC,AAlBD,IAkBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAGzB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAEtE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;IAEf,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;IAEtE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test14.d.ts b/test/legacyTests/test14.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test14.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test14.js b/test/legacyTests/test14.js new file mode 100644 index 0000000..2c3ebbc --- /dev/null +++ b/test/legacyTests/test14.js @@ -0,0 +1,27 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, 1000); + }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a", function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + console.log("PASS"); +}); +inst.myMethod("b"); +//# sourceMappingURL=test14.js.map \ No newline at end of file diff --git a/test/legacyTests/test14.js.map b/test/legacyTests/test14.js.map new file mode 100644 index 0000000..64dd68d --- /dev/null +++ b/test/legacyTests/test14.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test14.js","sourceRoot":"","sources":["../../src/test/legacyTests/test14.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAGzB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAEtE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;IAEf,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAErE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test15.d.ts b/test/legacyTests/test15.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test15.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test15.js b/test/legacyTests/test15.js new file mode 100644 index 0000000..4b8e77d --- /dev/null +++ b/test/legacyTests/test15.js @@ -0,0 +1,34 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, 1000); + }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a", function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 1); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +}); +inst.myMethod("b", function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +}); +inst.myMethod("c", function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + console.log("PASS"); +}); +//# sourceMappingURL=test15.js.map \ No newline at end of file diff --git a/test/legacyTests/test15.js.map b/test/legacyTests/test15.js.map new file mode 100644 index 0000000..384d54b --- /dev/null +++ b/test/legacyTests/test15.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test15.js","sourceRoot":"","sources":["../../src/test/legacyTests/test15.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAEtE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;IAEf,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AAEzE,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;IAEf,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AAEzE,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;IAEf,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test16.d.ts b/test/legacyTests/test16.d.ts new file mode 100644 index 0000000..ea3965c --- /dev/null +++ b/test/legacyTests/test16.d.ts @@ -0,0 +1,13 @@ +import { VoidEvt } from "ts-evt"; +export declare class MyClass { + constructor(); + alphabet: string; + myMethod: (char: string, callback?: ((alphabet: string) => void) | undefined) => void; +} +export declare class MyClassProxy { + private myClassInst; + readonly evtCreate: VoidEvt; + getAlphabet(): typeof MyClass.prototype.alphabet; + constructor(); + myMethod: (char: string, callback?: ((alphabet: string) => void) | undefined) => void; +} diff --git a/test/legacyTests/test16.js b/test/legacyTests/test16.js new file mode 100644 index 0000000..76ce7b2 --- /dev/null +++ b/test/legacyTests/test16.js @@ -0,0 +1,76 @@ +"use strict"; +exports.__esModule = true; +exports.MyClassProxy = exports.MyClass = void 0; +//Import ExecStack to be able to export stacked function +var runExclusive = require("../../lib/runExclusive"); +var ts_evt_1 = require("ts-evt"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, 1000); + }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var MyClassProxy = /** @class */ (function () { + function MyClassProxy() { + var _this = this; + this.myClassInst = undefined; + this.evtCreate = new ts_evt_1.VoidEvt(); + this.myMethod = runExclusive.buildMethodCb(function callee() { + var _this = this; + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + var self = this; + if (!self.myClassInst) { + self.evtCreate.attachOnce(function () { return callee.apply(_this, inputs); }); + return; + } + self.myClassInst.myMethod.apply(self.myClassInst, inputs); + }); + setTimeout(function () { + _this.myClassInst = new MyClass(); + _this.evtCreate.post(); + }, 1000); + } + MyClassProxy.prototype.getAlphabet = function () { + if (!this.myClassInst) + return ""; + else + return this.myClassInst.alphabet; + }; + return MyClassProxy; +}()); +exports.MyClassProxy = MyClassProxy; +var inst = new MyClassProxy(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.getAlphabet() === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + console.assert(inst.getAlphabet() === "abc"); + console.log("PASS"); + }, 2000); +}, 2900 + 1000); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char, function (alphabet) { return console.log("step " + alphabet); }); +} +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +//# sourceMappingURL=test16.js.map \ No newline at end of file diff --git a/test/legacyTests/test16.js.map b/test/legacyTests/test16.js.map new file mode 100644 index 0000000..c67fe51 --- /dev/null +++ b/test/legacyTests/test16.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test16.js","sourceRoot":"","sources":["../../src/test/legacyTests/test16.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AACxD,qDAAuD;AACvD,iCAAiC;AAEjC;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,0BAAO;AAqBpB;IAYI;QAAA,iBAOC;QAhBO,gBAAW,GAAwB,SAAS,CAAC;QAErC,cAAS,GAAG,IAAI,gBAAO,EAAE,CAAC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KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test17.d.ts b/test/legacyTests/test17.d.ts new file mode 100644 index 0000000..bf79d20 --- /dev/null +++ b/test/legacyTests/test17.d.ts @@ -0,0 +1,6 @@ +import { Evt } from "ts-evt"; +export declare class MyClass { + constructor(); + readonly evtNoCallback: Evt; + myMethod: (message: string, callback?: ((alphabet: string) => void) | undefined) => void; +} diff --git a/test/legacyTests/test17.js b/test/legacyTests/test17.js new file mode 100644 index 0000000..4f10546 --- /dev/null +++ b/test/legacyTests/test17.js @@ -0,0 +1,35 @@ +"use strict"; +exports.__esModule = true; +exports.MyClass = void 0; +//Import ExecStack to be able to export stacked function +var runExclusive = require("../../lib/runExclusive"); +var ts_evt_1 = require("ts-evt"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.evtNoCallback = new ts_evt_1.Evt(); + this.myMethod = runExclusive.buildMethodCb(function (message, callback) { + setTimeout(function () { + if (!callback.hasCallback) + _this.evtNoCallback.post(message); + callback(message); + }, 1000); + }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var inst = new MyClass(); +var success = false; +inst.evtNoCallback.attach(function (message) { + console.assert(message === "noCallback"); + success = true; +}); +inst.myMethod("callback", function (message) { return console.assert("callback" === message); }); +inst.myMethod("noCallback"); +setTimeout(function () { + console.assert(success); + console.log("DONE"); +}, 2500); +//# sourceMappingURL=test17.js.map \ No newline at end of file diff --git a/test/legacyTests/test17.js.map b/test/legacyTests/test17.js.map new file mode 100644 index 0000000..8e38881 --- /dev/null +++ b/test/legacyTests/test17.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test17.js","sourceRoot":"","sources":["../../src/test/legacyTests/test17.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AACxD,qDAAuD;AACvD,iCAA6B;AAE7B;IAEI;QAAA,iBAAiB;QAED,kBAAa,GAAG,IAAI,YAAG,EAAU,CAAC;QAE3C,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,OAAe,EAAE,QAAqC;YAEnD,UAAU,CAAC;gBAEP,IAAI,CAAE,QAAgB,CAAC,WAAW;oBAC9B,KAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAGrC,QAAS,CAAC,OAAO,CAAC,CAAA;YACtB,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAjBc,CAAC;IAAA,CAAC;IAoBtB,cAAC;AAAD,CAAC,AAtBD,IAsBC;AAtBY,0BAAO;AAyBpB,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,IAAI,OAAO,GAAG,KAAK,CAAA;AAEnB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAA,OAAO;IAE7B,OAAO,CAAC,MAAM,CAAC,OAAO,KAAK,YAAY,CAAC,CAAC;IAEzC,OAAO,GAAG,IAAI,CAAC;AAEnB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,MAAM,CAAC,UAAU,KAAK,OAAO,CAAC,EAAtC,CAAsC,CAAC,CAAC;AAC7E,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAE5B,UAAU,CAAC;IAEP,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAExB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAGxB,CAAC,EAAE,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test18.d.ts b/test/legacyTests/test18.d.ts new file mode 100644 index 0000000..bf79d20 --- /dev/null +++ b/test/legacyTests/test18.d.ts @@ -0,0 +1,6 @@ +import { Evt } from "ts-evt"; +export declare class MyClass { + constructor(); + readonly evtNoCallback: Evt; + myMethod: (message: string, callback?: ((alphabet: string) => void) | undefined) => void; +} diff --git a/test/legacyTests/test18.js b/test/legacyTests/test18.js new file mode 100644 index 0000000..852ed47 --- /dev/null +++ b/test/legacyTests/test18.js @@ -0,0 +1,30 @@ +"use strict"; +exports.__esModule = true; +exports.MyClass = void 0; +var runExclusive = require("../../lib/runExclusive"); +var ts_evt_1 = require("ts-evt"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.evtNoCallback = new ts_evt_1.Evt(); + this.myMethod = runExclusive.buildMethodCb(function (message, callback) { + if (!callback.hasCallback) + _this.evtNoCallback.post(message); + callback(message); + }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var inst = new MyClass(); +var success = false; +inst.evtNoCallback.attach(function (message) { + console.assert(message === "noCallback"); + success = true; +}); +inst.myMethod("noCallback"); +inst.myMethod("callback", function (message) { return console.assert("callback" === message); }); +console.assert(success); +console.log("DONE"); +//# sourceMappingURL=test18.js.map \ No newline at end of file diff --git a/test/legacyTests/test18.js.map b/test/legacyTests/test18.js.map new file mode 100644 index 0000000..8af60a6 --- /dev/null +++ b/test/legacyTests/test18.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test18.js","sourceRoot":"","sources":["../../src/test/legacyTests/test18.ts"],"names":[],"mappings":";;;AAAA,qDAAuD;AACvD,iCAA8B;AAE9B;IAEI;QAAA,iBAAiB;QAED,kBAAa,GAAG,IAAI,YAAG,EAAU,CAAC;QAE3C,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,OAAe,EAAE,QAAqC;YAEnD,IAAI,CAAE,QAAgB,CAAC,WAAW;gBAC9B,KAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAErC,QAAS,CAAC,OAAO,CAAC,CAAA;QAEtB,CAAC,CACJ,CAAC;IAbc,CAAC;IAAA,CAAC;IAgBtB,cAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,0BAAO;AAqBpB,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,IAAI,OAAO,GAAG,KAAK,CAAA;AAEnB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAA,OAAO;IAE7B,OAAO,CAAC,MAAM,CAAC,OAAO,KAAK,YAAY,CAAC,CAAC;IAEzC,OAAO,GAAG,IAAI,CAAC;AAEnB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC5B,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,MAAM,CAAC,UAAU,KAAK,OAAO,CAAC,EAAtC,CAAsC,CAAC,CAAC;AAG7E,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAExB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test19.d.ts b/test/legacyTests/test19.d.ts new file mode 100644 index 0000000..9e1777c --- /dev/null +++ b/test/legacyTests/test19.d.ts @@ -0,0 +1,4 @@ +export declare class MyClass { + constructor(); + myMethod: (input: string, callback?: ((out1: string, out2: number) => void) | undefined) => Promise<[string, number]>; +} diff --git a/test/legacyTests/test19.js b/test/legacyTests/test19.js new file mode 100644 index 0000000..50a4446 --- /dev/null +++ b/test/legacyTests/test19.js @@ -0,0 +1,78 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +exports.MyClass = void 0; +var runExclusive = require("../../lib/runExclusive"); +var runCount = 0; +var MyClass = /** @class */ (function () { + function MyClass() { + this.myMethod = runExclusive.buildMethodCb(function (input, callback) { + setTimeout(function () { + runCount++; + callback(input + " 0K", 666); + }, 1000); + return null; + }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var inst = new MyClass(); +(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, out1, out2; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return inst.myMethod("yo", function (out1, out2) { return resolve([out1, out2]); }); })]; + case 1: + _a = _b.sent(), out1 = _a[0], out2 = _a[1]; + console.assert(out1 === "yo 0K" && out2 === 666); + inst.myMethod("ya", function (out1, out2) { return console.assert(out1 == "ya 0K" && out2 === 666); }); + inst.myMethod("foo"); + setTimeout(function () { + console.assert(runCount === 2); + }, 1100); + setTimeout(function () { + console.assert(runCount === 3); + console.log("DONE"); + }, 3100); + return [2 /*return*/]; + } + }); +}); })(); +//# sourceMappingURL=test19.js.map \ No newline at end of file diff --git a/test/legacyTests/test19.js.map b/test/legacyTests/test19.js.map new file mode 100644 index 0000000..cb30ca1 --- /dev/null +++ b/test/legacyTests/test19.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test19.js","sourceRoot":"","sources":["../../src/test/legacyTests/test19.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuD;AAEvD,IAAI,QAAQ,GAAE,CAAC,CAAC;AAEhB;IAEI;QAEO,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,KAAa,EAAE,QAA+C;YAE3D,UAAU,CAAC;gBAEP,QAAQ,EAAE,CAAC;gBAEX,QAAS,CAAC,KAAK,GAAG,KAAK,EAAE,GAAG,CAAC,CAAA;YAEjC,CAAC,EAAE,IAAI,CAAC,CAAC;YAET,OAAO,IAAW,CAAC;QAEvB,CAAC,CACJ,CAAC;IAhBc,CAAC;IAAA,CAAC;IAkBtB,cAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,0BAAO;AAsBpB,IAAI,IAAI,GAAE,IAAI,OAAO,EAAE,CAAC;AAExB,CAAC;;;;oBAEuB,qBAAM,IAAI,OAAO,CACjC,UAAA,OAAO,IAAG,OAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAC,IAAI,EAAE,IAAI,IAAI,OAAA,OAAO,CAAC,CAAE,IAAI,EAAE,IAAI,CAAE,CAAC,EAAvB,CAAuB,CAAC,EAA3D,CAA2D,CACxE,EAAA;;gBAFG,KAAgB,SAEnB,EAFK,IAAI,QAAA,EAAE,IAAI,QAAA;gBAIhB,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,GAAG,CAAE,CAAC;gBAElD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAC,IAAI,EAAE,IAAI,IAAI,OAAA,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,IAAI,IAAI,KAAK,GAAG,CAAC,EAA/C,CAA+C,CAAC,CAAC;gBAEpF,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAErB,UAAU,CAAC;oBAEP,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC;gBAEnC,CAAC,EAAE,IAAI,CAAC,CAAC;gBAET,UAAU,CAAC;oBAEP,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC;oBAE/B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAExB,CAAC,EAAE,IAAI,CAAC,CAAC;;;;KAGZ,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test2.d.ts b/test/legacyTests/test2.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test2.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test2.js b/test/legacyTests/test2.js new file mode 100644 index 0000000..889767c --- /dev/null +++ b/test/legacyTests/test2.js @@ -0,0 +1,42 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabetStack = ""; + this.groupRef = runExclusive.createGroupRef(); + this.myMethodUpperCase = runExclusive.buildMethodCb(this.groupRef, function (char, callback) { + setTimeout(function () { + _this.alphabetStack += char.toUpperCase(); + callback(_this.alphabetStack); + }, Math.random() * 1000); + }); + this.myMethod = runExclusive.buildMethodCb(this.groupRef, function (char, callback) { + setTimeout(function () { + _this.alphabetStack += char; + callback(_this.alphabetStack); + }, Math.random() * 1000); + }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +inst.myMethod("a"); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethodUpperCase(char, function (alphabet) { return console.log("step " + alphabet); }); +} +for (var _b = 0, _c = ["g", "h", "i"]; _b < _c.length; _b++) { + var char = _c[_b]; + inst.myMethod(char, function (alphabet) { return console.log("step " + alphabet); }); +} +inst.myMethod("j", function (alphabet) { + console.log("completed " + alphabet); + //cSpell: disable + console.assert(alphabet === "aBCDEFghij"); + //cSpell: enable + console.log("PASS"); +}); +//# sourceMappingURL=test2.js.map \ No newline at end of file diff --git a/test/legacyTests/test2.js.map b/test/legacyTests/test2.js.map new file mode 100644 index 0000000..585bcc1 --- /dev/null +++ b/test/legacyTests/test2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test2.js","sourceRoot":"","sources":["../../src/test/legacyTests/test2.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAET,kBAAa,GAAG,EAAE,CAAC;QAEnB,aAAQ,GAAG,YAAY,CAAC,cAAc,EAAE,CAAC;QAE1C,sBAAiB,GAAG,YAAY,CAAC,aAAa,CACjD,IAAI,CAAC,QAAQ,EACb,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,aAAa,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACzC,QAAS,CAAC,KAAI,CAAC,aAAa,CAAC,CAAC;YAClC,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QAE7B,CAAC,CACJ,CAAC;QAGK,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,IAAI,CAAC,QAAQ,EACb,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,aAAa,IAAI,IAAI,CAA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 b/test/legacyTests/test20.d.ts @@ -0,0 +1,4 @@ +export declare class MyClass { + constructor(); + myMethod: (input: number, callback?: ((out: string) => void) | undefined) => Promise; +} diff --git a/test/legacyTests/test20.js b/test/legacyTests/test20.js new file mode 100644 index 0000000..cf85d32 --- /dev/null +++ b/test/legacyTests/test20.js @@ -0,0 +1,79 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +exports.MyClass = void 0; +var runExclusive = require("../../lib/runExclusive"); +var runCount = 0; +var MyClass = /** @class */ (function () { + function MyClass() { + this.myMethod = runExclusive.buildMethodCb(function (input, callback) { + setTimeout(function () { + runCount++; + callback("input: " + input.toString()); + }, 1000); + return null; + }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var inst = new MyClass(); +(function () { return __awaiter(void 0, void 0, void 0, function () { + var out; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return inst.myMethod(111, function (out) { return resolve(out); }); })]; + case 1: + out = _a.sent(); + console.log(out); + console.log(out === "input: 111"); + inst.myMethod(222, function (out) { return console.log(out === "input: 222"); }); + inst.myMethod(333); + setTimeout(function () { + console.assert(runCount === 2); + }, 1100); + setTimeout(function () { + console.assert(runCount === 3); + console.log("DONE"); + }, 3100); + return [2 /*return*/]; + } + }); +}); })(); +//# sourceMappingURL=test20.js.map \ No newline at end of file diff --git a/test/legacyTests/test20.js.map b/test/legacyTests/test20.js.map new file mode 100644 index 0000000..6892cca --- /dev/null +++ b/test/legacyTests/test20.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test20.js","sourceRoot":"","sources":["../../src/test/legacyTests/test20.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuD;AAEvD,IAAI,QAAQ,GAAE,CAAC,CAAC;AAEhB;IAEI;QAEO,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,KAAa,EAAE,QAAgC;YAE5C,UAAU,CAAC;gBAEP,QAAQ,EAAE,CAAC;gBAEX,QAAS,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;YAE3C,CAAC,EAAE,IAAI,CAAC,CAAC;YAET,OAAO,IAAW,CAAC;QAEvB,CAAC,CACJ,CAAC;IAhBc,CAAC;IAAA,CAAC;IAkBtB,cAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,0BAAO;AAsBpB,IAAI,IAAI,GAAE,IAAI,OAAO,EAAE,CAAC;AAExB,CAAC;;;;oBAEY,qBAAM,IAAI,OAAO,CACtB,UAAA,OAAO,IAAG,OAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAA,GAAG,IAAG,OAAA,OAAO,CAAC,GAAG,CAAC,EAAZ,CAAY,CAAC,EAAtC,CAAsC,CACnD,EAAA;;gBAFG,GAAG,GAAE,SAER;gBAED,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACjB,OAAO,CAAC,GAAG,CAAE,GAAG,KAAK,YAAY,CAAC,CAAC;gBAEnC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAA,GAAG,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,YAAY,CAAC,EAAjC,CAAiC,CAAC,CAAC;gBAE7D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAGnB,UAAU,CAAC;oBAEP,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC;gBAEnC,CAAC,EAAE,IAAI,CAAC,CAAC;gBAET,UAAU,CAAC;oBAEP,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC;oBAE/B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAExB,CAAC,EAAE,IAAI,CAAC,CAAC;;;;KAGZ,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test21.d.ts b/test/legacyTests/test21.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test21.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test21.js b/test/legacyTests/test21.js new file mode 100644 index 0000000..76ccc43 --- /dev/null +++ b/test/legacyTests/test21.js @@ -0,0 +1,9 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var runExclusiveFunction = runExclusive.buildCb(function (callback) { return callback(); }); +var cbTriggered = false; +runExclusiveFunction(function () { return cbTriggered = true; }); +console.assert(cbTriggered); +console.log("PASS"); +//# sourceMappingURL=test21.js.map \ No newline at end of file diff --git a/test/legacyTests/test21.js.map b/test/legacyTests/test21.js.map new file mode 100644 index 0000000..c9e08f5 --- /dev/null +++ b/test/legacyTests/test21.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test21.js","sourceRoot":"","sources":["../../src/test/legacyTests/test21.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD,IAAI,oBAAoB,GAAE,YAAY,CAAC,OAAO,CAC1C,UAAC,QAAQ,IAAI,OAAA,QAAQ,EAAE,EAAV,CAAU,CAC1B,CAAC;AAEF,IAAI,WAAW,GAAE,KAAK,CAAC;AAGvB,oBAAoB,CAAC,cAAK,OAAA,WAAW,GAAG,IAAI,EAAlB,CAAkB,CAAE,CAAC;AAE/C,OAAO,CAAC,MAAM,CAAE,WAAW,CAAE,CAAC;AAE9B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test3.d.ts b/test/legacyTests/test3.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test3.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test3.js b/test/legacyTests/test3.js new file mode 100644 index 0000000..84300c8 --- /dev/null +++ b/test/legacyTests/test3.js @@ -0,0 +1,53 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(runExclusive.createGroupRef(), function (char, wait, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, wait); + }); + } + ; + return MyClass; +}()); +var start = Date.now(); +var inst1 = new MyClass(); +inst1.myMethod("a", 1000, function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("b", 1000, function (alphabet) { return console.log(alphabet); }); +var inst2 = new MyClass(); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst2.myMethod(char, wait, function (alphabet) { return console.log(alphabet); }); +} +inst2.myMethod("a", wait, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(this.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + var expectedDuration = (rev.length + 1) * 500; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +inst1.myMethod("c", 1000, function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("d", 1000, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); +}); +//# sourceMappingURL=test3.js.map \ No newline at end of file diff --git a/test/legacyTests/test3.js.map b/test/legacyTests/test3.js.map new file mode 100644 index 0000000..e9d716d --- /dev/null +++ b/test/legacyTests/test3.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test3.js","sourceRoot":"","sources":["../../src/test/legacyTests/test3.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,YAAY,CAAC,cA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C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;AAErD,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test4.d.ts b/test/legacyTests/test4.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test4.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test4.js b/test/legacyTests/test4.js new file mode 100644 index 0000000..7aa9f9f --- /dev/null +++ b/test/legacyTests/test4.js @@ -0,0 +1,53 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, wait, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, wait); + }); + } + ; + return MyClass; +}()); +var start = Date.now(); +var inst1 = new MyClass(); +inst1.myMethod("a", 1000, function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("b", 1000, function (alphabet) { return console.log(alphabet); }); +var inst2 = new MyClass(); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst2.myMethod(char, wait, function (alphabet) { return console.log(alphabet); }); +} +inst2.myMethod("a", wait, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(this.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + var expectedDuration = (rev.length + 1) * wait; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +inst1.myMethod("c", 1000, function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("d", 1000, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); +}); +//# sourceMappingURL=test4.js.map \ No newline at end of file diff --git a/test/legacyTests/test4.js.map b/test/legacyTests/test4.js.map new file mode 100644 index 0000000..786f77c --- /dev/null +++ b/test/legacyTests/test4.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test4.js","sourceRoot":"","sources":["../../src/test/legacyTests/test4.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,IAAY,EAAE,IAAY,EAAE,QAAqC;YAE9D,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAbc,CAAC;IAAA,CAAC;IAetB,cAAC;AAAD,CAAC,AAjBD,IAiBC;AAGD,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAEvB,IAAI,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;AAE1B,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AAC7D,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AAE7D,IAAI,KAAK,GAAG,IAAI,OA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,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AAC7D,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE;IAEtB,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAElC,iBAAiB;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;IAC1C,gBAAgB;IAEhB,IAAI,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC;IAEhC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;AAErD,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test5.d.ts b/test/legacyTests/test5.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test5.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test5.js b/test/legacyTests/test5.js new file mode 100644 index 0000000..c89fb5d --- /dev/null +++ b/test/legacyTests/test5.js @@ -0,0 +1,48 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(MyClass.groupRef, function (char, wait, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, wait); + }); + } + ; + MyClass.groupRef = runExclusive.createGroupRef(); + return MyClass; +}()); +var start = Date.now(); +var inst1 = new MyClass(); +inst1.myMethod.call(MyClass, "a", 1000, function (alphabet) { return console.log(alphabet); }); +inst1.myMethod.call(MyClass, "b", 1000, function (alphabet) { return console.log(alphabet); }); +var inst2 = new MyClass(); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst2.myMethod.call(MyClass, char, wait, function (alphabet) { return console.log(alphabet); }); +} +inst2.myMethod.call(MyClass, "a", wait, function () { + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable +}); +inst1.myMethod.call(MyClass, "c", 1000, function (alphabet) { return console.log(alphabet); }); +inst1.myMethod.call(MyClass, "d", 1000, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4 + (rev.length + 1) * wait; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +//# sourceMappingURL=test5.js.map \ No newline at end of file diff --git a/test/legacyTests/test5.js.map b/test/legacyTests/test5.js.map new file mode 100644 index 0000000..8dfa117 --- /dev/null +++ b/test/legacyTests/test5.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test5.js","sourceRoot":"","sources":["../../src/test/legacyTests/test5.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAId,aAAQ,GAAG,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,EACzD,UAAC,IAAY,EAAE,IAAY,EAAE,QAAoC;YAE7D,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,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AAC,KAAK,CAAC,QAAQ,KAAK,gBAAgB,CAAC,CAAC;IACpD,gBAAgB;AAEpB,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AAC3E,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE;IAEpC,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAElC,iBAAiB;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;IAC1C,gBAAgB;IAEhB,IAAI,gBAAgB,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAE1D,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;IAEjD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test6.d.ts b/test/legacyTests/test6.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test6.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test6.js b/test/legacyTests/test6.js new file mode 100644 index 0000000..d5f91bd --- /dev/null +++ b/test/legacyTests/test6.js @@ -0,0 +1,62 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var groupRefAlphabet = runExclusive.createGroupRef(); +var MyClass1 = /** @class */ (function () { + function MyClass1() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildCb(groupRefAlphabet, function (char, wait, callback) { + setTimeout(function () { + _this.alphabet += char.toUpperCase(); + callback(_this.alphabet); + }, wait); + }); + } + ; + return MyClass1; +}()); +var MyClass2 = /** @class */ (function () { + function MyClass2() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildCb(groupRefAlphabet, function (char, wait, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, wait); + }); + } + ; + return MyClass2; +}()); +var start = Date.now(); +var inst1 = new MyClass1(); +inst1.myMethod("a", 1000, function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("b", 1000, function (alphabet) { return console.log(alphabet); }); +var inst2 = new MyClass2(); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst2.myMethod(char, wait, function (alphabet) { return console.log(alphabet); }); +} +inst2.myMethod("a", wait, function () { + //cSpell: disable + console.assert(this.alphabet === "nmlkjihgfedcba"); + //cSpell: enable +}); +inst1.myMethod("c", 1000, function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("d", 1000, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst1.alphabet === "ABCD"); + //cSpell: enable + var expectedDuration = 1000 * 4 + (rev.length + 1) * 500; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +//# sourceMappingURL=test6.js.map \ No newline at end of file diff --git a/test/legacyTests/test6.js.map b/test/legacyTests/test6.js.map new file mode 100644 index 0000000..8a2069b --- /dev/null +++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gB,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAEzD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;IAEjD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test7.d.ts b/test/legacyTests/test7.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test7.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test7.js b/test/legacyTests/test7.js new file mode 100644 index 0000000..ce3256a --- /dev/null +++ b/test/legacyTests/test7.js @@ -0,0 +1,60 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod1 = runExclusive.buildMethodCb(runExclusive.createGroupRef(), function (char, wait, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, wait); + }); + this.alphabet2 = ""; + this.myMethod2 = runExclusive.buildMethodCb(function (char, wait, callback) { + var safeCallback = callback || function () { }; + setTimeout(function () { + _this.alphabet2 += char; + safeCallback(_this.alphabet2); + }, wait); + }); + } + ; + return MyClass; +}()); +var start = Date.now(); +var inst = new MyClass(); +inst.myMethod1("a", 1000, function (alphabet) { return console.log(alphabet); }); +inst.myMethod1("b", 1000, function (alphabet) { return console.log(alphabet); }); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst.myMethod2(char, wait, function (alphabet) { return console.log(alphabet); }); +} +inst.myMethod2("a", wait, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(this.alphabet2 === "nmlkjihgfedcba"); + //cSpell: enable + var expectedDuration = (rev.length + 1) * wait; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +inst.myMethod1("c", 1000, function (alphabet) { return console.log(alphabet); }); +inst.myMethod1("d", 1000, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); +}); +//# sourceMappingURL=test7.js.map \ No newline at end of file diff --git a/test/legacyTests/test7.js.map b/test/legacyTests/test7.js.map new file mode 100644 index 0000000..2d1478c --- /dev/null +++ b/test/legacyTests/test7.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test7.js","sourceRoot":"","sources":["../../src/test/legacyTests/test7.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,cAAS,GAAG,YAAY,CAAC,aAAa,CAAC,YAAY,CAAC,cAAc,EAAE,EACvE,UAAC,IAAY,EAAE,IAAY,EAAE,QAAqC;YAE9D,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;QAEK,cAAS,GAAG,EAAE,CAAC;QAEf,c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AEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;AAGrD,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/legacyTests/test8.d.ts b/test/legacyTests/test8.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/legacyTests/test8.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test8.js b/test/legacyTests/test8.js new file mode 100644 index 0000000..f9969b0 --- /dev/null +++ b/test/legacyTests/test8.js @@ -0,0 +1,60 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod1 = runExclusive.buildMethodCb(function (char, wait, callback) { + var safeCallback = callback || function () { }; + setTimeout(function () { + _this.alphabet += char; + safeCallback(_this.alphabet); + }, wait); + }); + this.alphabet2 = ""; + this.myMethod2 = runExclusive.buildMethodCb(function (char, wait, callback) { + setTimeout(function () { + _this.alphabet2 += char; + callback(_this.alphabet2); + }, wait); + }); + } + ; + return MyClass; +}()); +var start = Date.now(); +var inst = new MyClass(); +inst.myMethod1("a", 1000, function (alphabet) { return console.log(alphabet); }); +inst.myMethod1("b", 1000, function (alphabet) { return console.log(alphabet); }); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst.myMethod2(char, wait, function (alphabet) { return console.log(alphabet); }); +} +inst.myMethod2("a", wait, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(this.alphabet2 === "nmlkjihgfedcba"); + //cSpell: enable + var expectedDuration = (rev.length + 1) * 500; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +inst.myMethod1("c", 1000, function (alphabet) { return console.log(alphabet); }); +inst.myMethod1("d", 1000, function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); +}); +//# sourceMappingURL=test8.js.map \ No newline at end of file diff --git a/test/legacyTests/test8.js.map b/test/legacyTests/test8.js.map new file mode 100644 index 0000000..6ae7d30 --- /dev/null +++ b/test/legacyTests/test8.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test8.js","sourceRoot":"","sources":["../../src/test/legacyTests/test8.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,cAAS,GAAG,YAAY,CAAC,aAAa,CACzC,UAAC,IAAY,EAAE,IAAY,EAAE,QAAqC;YAE9D,IAAI,YAAY,GAAG,QAAQ,IAAI,cAAc,CAAC,CAAC;YAE/C,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,YAAY,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;QAGK,cAAS,GAAG,EAAE,CAAC;QAEf,cAAS,GAAG,YAAY,CAAC,aAAa,CACzC,UAAC,IAAY,EAAE,IAAY,EAAE,QAAqC;YAE9D,UAAU,CAAC;gBACP,KAAI,CAAC,SAAS,IAAI,IAAI,CAAC;gBACvB,QAAS,CAAC,KAAI,CAAC,SAAS,CAAC,CAAC;YAC9B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IA7Bc,CAAC;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9.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/legacyTests/test9.js b/test/legacyTests/test9.js new file mode 100644 index 0000000..bd2bf78 --- /dev/null +++ b/test/legacyTests/test9.js @@ -0,0 +1,32 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethodCb(function (char, callback) { + setTimeout(function () { + _this.alphabet += char; + callback(_this.alphabet); + }, 1000); + }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.alphabet === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(inst.alphabet === "abc"); + console.log("PASS"); + }, 2000); +}, 2900); +for (var _i = 0, _a = ["a", "b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char, function (alphabet) { return console.log("step " + alphabet); }); +} +//# sourceMappingURL=test9.js.map \ No newline at end of file diff --git a/test/legacyTests/test9.js.map b/test/legacyTests/test9.js.map new file mode 100644 index 0000000..1b1beaf --- /dev/null +++ b/test/legacyTests/test9.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test9.js","sourceRoot":"","sources":["../../src/test/legacyTests/test9.ts"],"names":[],"mappings":";;AAAA,qDAAuD;AAEvD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,aAAa,CACxC,UAAC,IAAY,EAAE,QAAqC;YAEhD,UAAU,CAAC;gBACP,KAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACtB,QAAS,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QAEb,CAAC,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAGzB,UAAU,CAAC;IAEP,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAE3E,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;IAEvC,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAEvD,UAAU,CAAC;QAEP,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC;QAExC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAExB,CAAC,EAAE,IAAI,CAAC,CAAC;AAEb,CAAC,EAAE,IAAI,CAAC,CAAC;AAET,KAAiB,UAA8B,EAA9B,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAA9B,cAA8B,EAA9B,IAA8B,EAAC;IAA3C,IAAI,IAAI,SAAA;IAET,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,UAAQ,QAAU,CAAC,EAA/B,CAA+B,CAAC,CAAC;CAEpE"} \ No newline at end of file diff --git a/test/mod.d.ts b/test/mod.d.ts new file mode 100644 index 0000000..9a356b0 --- /dev/null +++ b/test/mod.d.ts @@ -0,0 +1,17 @@ +import "./test1"; +import "./test2"; +import "./test3"; +import "./test4"; +import "./test5"; +import "./test6"; +import "./test7"; +import "./test8"; +import "./test9"; +import "./test10"; +import "./test11"; +import "./test13"; +import "./test14"; +import "./test15"; +import "./test16"; +import "./test17"; +import "./test18"; diff --git a/test/mod.js b/test/mod.js new file mode 100644 index 0000000..969464e --- /dev/null +++ b/test/mod.js @@ -0,0 +1,21 @@ +"use strict"; +exports.__esModule = true; +console.log("DENO TEST"); +require("./test1"); +require("./test2"); +require("./test3"); +require("./test4"); +require("./test5"); +require("./test6"); +require("./test7"); +require("./test8"); +require("./test9"); +require("./test10"); +require("./test11"); +require("./test13"); +require("./test14"); +require("./test15"); +require("./test16"); +require("./test17"); +require("./test18"); +//# sourceMappingURL=mod.js.map \ No newline at end of file diff --git a/test/mod.js.map b/test/mod.js.map new file mode 100644 index 0000000..bc09238 --- /dev/null +++ b/test/mod.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/test/mod.ts"],"names":[],"mappings":";;AAGA,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAEzB,mBAAiB;AACjB,mBAAiB;AACjB,mBAAiB;AACjB,mBAAiB;AACjB,mBAAiB;AACjB,mBAAiB;AACjB,mBAAiB;AACjB,mBAAiB;AACjB,mBAAiB;AACjB,oBAAkB;AAClB,oBAAkB;AAElB,oBAAkB;AAClB,oBAAkB;AAClB,oBAAkB;AAClB,oBAAkB;AAClB,oBAAkB;AAClB,oBAAkB"} \ No newline at end of file diff --git a/test/test1.d.ts b/test/test1.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test1.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test1.js b/test/test1.js new file mode 100644 index 0000000..df7261a --- /dev/null +++ b/test/test1.js @@ -0,0 +1,36 @@ +"use strict"; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabetStack = ""; + this.myMethodStack = runExclusive.buildMethod(function (char) { + return new Promise(function (resolve) { + setTimeout(function () { + _this.alphabetStack += char; + resolve(_this.alphabetStack); + }, Math.random() * 1000); + }); + }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +for (var _i = 0, _a = ["a", "b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethodStack(char).then(function (alphabet) { return console.log("step " + alphabet); }); +} +for (var _b = 0, _c = ["g", "h", "i"]; _b < _c.length; _b++) { + var char = _c[_b]; + inst.myMethodStack(char); +} +inst.myMethodStack("j").then(function (alphabet) { + console.log("completed " + alphabet); + //cSpell: disable + console.assert(alphabet === "abcdefghij"); + //cSpell: enable + console.log("PASS"); +}); +//# sourceMappingURL=test1.js.map \ No newline at end of file diff --git a/test/test1.js.map b/test/test1.js.map new file mode 100644 index 0000000..0ae2929 --- /dev/null +++ b/test/test1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test1.js","sourceRoot":"","sources":["../src/test/test1.ts"],"names":[],"mappings":";;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAET,kBAAa,GAAG,EAAE,CAAC;QAEpB,kBAAa,GAAG,YAAY,CAAC,WAAW,CAC3C,UAAC,IAAY;YAET,OAAO,IAAI,OAAO,CAAS,UAAA,OAAO;gBAE9B,UAAU,CAAC;oBACP,KAAI,CAAC,aAAa,IAAI,IAAI,CAAC;oBAC3B,OAAO,CAAC,KAAI,CAAC,aAAa,CAAC,CAAC;gBAChC,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;YAE7B,CAAC,CAAC,CAAC;QAEP,CAAC,CACJ,CAAC;IAjBc,CAAC;IAAA,CAAC;IAoBtB,cAAC;AAAD,CAAC,AAtBD,IAsBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,KAAiB,UAA8B,EAA9B,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAA9B,cAA8B,EAA9B,IAA8B;IAA1C,IAAI,IAAI,SAAA;IACT,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,UAAQ,QAAU,CAAC,EAA/B,CAA+B,CAAE,CAAC;CAAA;AAGjF,KAAiB,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe;IAA3B,IAAI,IAAI,SAAA;IACT,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;CAAA;AAE7B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CAAE,UAAA,QAAQ;IAElC,OAAO,CAAC,GAAG,CAAC,eAAa,QAAU,CAAC,CAAC;IAErC,iBAAiB;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC;IAC1C,gBAAgB;IAEhB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test10.d.ts b/test/test10.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test10.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test10.js b/test/test10.js new file mode 100644 index 0000000..62c1591 --- /dev/null +++ b/test/test10.js @@ -0,0 +1,80 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.alphabet === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(inst.alphabet === "abc"); + console.log("PASS"); + }, 2000); +}, 2900); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char).then(function (alphabet) { return console.log("step " + alphabet); }); +} +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +//# sourceMappingURL=test10.js.map \ No newline at end of file diff --git a/test/test10.js.map b/test/test10.js.map new file mode 100644 index 0000000..f79c1fc --- /dev/null +++ b/test/test10.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test10.js","sourceRoot":"","sources":["../src/test/test10.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAK,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAAhC,CAAgC,CAAC,EAAA;;wBAApE,SAAoE,CAAC;wBAErE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAGzB,UAAU,CAAC;IAGP,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAE3E,OAAO,CAAC,MAAM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AAC,QAAQ,EAAE,IAAI,CAAC,KAAI,CAAC,CAAC,CAAC;AAC1E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAE,CAAC"} \ No newline at end of file diff --git a/test/test11.d.ts b/test/test11.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test11.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test11.js b/test/test11.js new file mode 100644 index 0000000..610816f --- /dev/null +++ b/test/test11.js @@ -0,0 +1,101 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var MyClassProxy = /** @class */ (function () { + function MyClassProxy() { + var _this = this; + this.myClassInst = new MyClass(); + this.callCount = 0; + this.myMethod = runExclusive.buildMethod(function () { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + _this.callCount++; + return _this.myClassInst.myMethod.apply(_this.myClassInst, inputs); + }); + } + ; + MyClassProxy.prototype.getAlphabet = function () { + return this.myClassInst.alphabet; + }; + return MyClassProxy; +}()); +var inst = new MyClassProxy(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.getAlphabet() === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(inst.getAlphabet() === "abc"); + console.log("PASS"); + }, 2000); +}, 2900); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char).then(function (alphabet) { return console.log("step " + alphabet); }); +} +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +console.assert(inst.callCount === 1); +//# sourceMappingURL=test11.js.map \ No newline at end of file diff --git a/test/test11.js.map b/test/test11.js.map new file mode 100644 index 0000000..174894f --- /dev/null +++ b/test/test11.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test11.js","sourceRoot":"","sources":["../src/test/test11.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED;IAEI;QAAA,iBAAiB;QAET,gBAAW,GAAG,IAAI,OAAO,EAAE,CAAC;QAE7B,cAAS,GAAG,CAAC,CAAC;QAMd,aAAQ,GACf,YAAY,CAAC,WAAW,CACpB;YAAC,gBAAS;iBAAT,UAAS,EAAT,qBAAS,EAAT,IAAS;gBAAT,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AQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAE,CAAC;AAEtE,KAAiB,UAAyB,EAAzB,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAzB,cAAyB,EAAzB,IAAyB;IAArC,IAAI,IAAI,SAAA;IACT,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,UAAQ,QAAU,CAAC,EAA/B,CAA+B,CAAC,CAAC;CAAA;AAE3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAE,CAAC;AAEtE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test12.d.ts b/test/test12.d.ts new file mode 100644 index 0000000..8e27e2d --- /dev/null +++ b/test/test12.d.ts @@ -0,0 +1,13 @@ +import { VoidEvt } from "ts-evt"; +export declare class MyClass { + constructor(); + alphabet: string; + myMethod: (char: string) => Promise; +} +export declare class MyClassProxy { + private myClassInst; + readonly evtCreate: VoidEvt; + getAlphabet(): typeof MyClass.prototype.alphabet; + constructor(); + myMethod: typeof MyClass.prototype.myMethod; +} diff --git a/test/test12.js b/test/test12.js new file mode 100644 index 0000000..9d1dc2f --- /dev/null +++ b/test/test12.js @@ -0,0 +1,118 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +exports.MyClassProxy = exports.MyClass = void 0; +var runExclusive = require("../lib/runExclusive"); +var ts_evt_1 = require("ts-evt"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1000); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var MyClassProxy = /** @class */ (function () { + function MyClassProxy() { + var _this = this; + this.myClassInst = undefined; + this.evtCreate = new ts_evt_1.VoidEvt(); + this.myMethod = runExclusive.buildMethod(function () { + var inputs = []; + for (var _i = 0; _i < arguments.length; _i++) { + inputs[_i] = arguments[_i]; + } + var self = _this; + return new Promise(function callee(resolve, reject) { + if (!self.myClassInst) { + self.evtCreate.attachOnce(function () { return callee(resolve, reject); }); + return; + } + self.myClassInst.myMethod.apply(self.myClassInst, inputs) + .then(resolve)["catch"](reject); + }); + }); + setTimeout(function () { + _this.myClassInst = new MyClass(); + _this.evtCreate.post(); + }, 1000); + } + MyClassProxy.prototype.getAlphabet = function () { + if (!this.myClassInst) + return ""; + else + return this.myClassInst.alphabet; + }; + return MyClassProxy; +}()); +exports.MyClassProxy = MyClassProxy; +var inst = new MyClassProxy(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.getAlphabet() === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + console.assert(inst.getAlphabet() === "abc"); + console.log("PASS"); + }, 2000); +}, 2900 + 1000); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a"); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char).then(function (alphabet) { return console.log("step " + alphabet); }); +} +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 5); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +//# sourceMappingURL=test12.js.map \ No newline at end of file diff --git a/test/test12.js.map b/test/test12.js.map new file mode 100644 index 0000000..40ef341 --- /dev/null +++ b/test/test12.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test12.js","sourceRoot":"","sources":["../src/test/test12.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AACpD,iCAAkC;AAElC;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAzB,CAAyB,CAAC,EAAA;;wBAA7D,SAA6D,CAAC;wBAE9D,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CACJ,CAAC;IAfc,CAAC;IAAA,CAAC;IAkBtB,cAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,0BAAO;AAsBpB;IAWI;QAAA,iBAOC;QAhBO,gBAAW,GAAwB,SAAS,CAAC;QAErC,cAAS,GAAG,IAAI,gBAAO,EAAE,CAAC;QAgBnC,aAAQ,GACf,YAAY,CAAC,WAAW,CACpB;YAAC,gBAAS;iBAAT,UAAS,EAAT,qBAAS,EAAT,IAAS;gBAAT,2BAAS;;YAEN,IAAI,IAAI,GAAG,KAAI,CAAC;YAEhB,OAAO,IAAI,OAAO,CAAM,SAAS,MAAM,CAAC,OAAO,EAAE,MAAM;gBAEnD,IAAI,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,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test13.d.ts b/test/test13.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test13.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test13.js b/test/test13.js new file mode 100644 index 0000000..d958243 --- /dev/null +++ b/test/test13.js @@ -0,0 +1,67 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a").then(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + console.log("PASS"); +}); +//# sourceMappingURL=test13.js.map \ No newline at end of file diff --git a/test/test13.js.map b/test/test13.js.map new file mode 100644 index 0000000..1f8c149 --- /dev/null +++ b/test/test13.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test13.js","sourceRoot":"","sources":["../src/test/test13.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAEtE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAE;IAErB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;IAEtE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test14.d.ts b/test/test14.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test14.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test14.js b/test/test14.js new file mode 100644 index 0000000..a5056a9 --- /dev/null +++ b/test/test14.js @@ -0,0 +1,68 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a").then(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); + console.log("PASS"); +}); +inst.myMethod("b"); +//# sourceMappingURL=test14.js.map \ No newline at end of file diff --git a/test/test14.js.map b/test/test14.js.map new file mode 100644 index 0000000..7efb226 --- /dev/null +++ b/test/test14.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test14.js","sourceRoot":"","sources":["../src/test/test14.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAEtE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAEpB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAErE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test15.d.ts b/test/test15.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test15.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test15.js b/test/test15.js new file mode 100644 index 0000000..c77d5fd --- /dev/null +++ b/test/test15.js @@ -0,0 +1,75 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); +console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); +inst.myMethod("a").then(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 1); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +}); +inst.myMethod("b").then(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === true); +}); +inst.myMethod("c").then(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 0); + console.assert(runExclusive.isRunning(inst.myMethod, inst) === false); + console.log("PASS"); +}); +//# sourceMappingURL=test15.js.map \ No newline at end of file diff --git a/test/test15.js.map b/test/test15.js.map new file mode 100644 index 0000000..4569f22 --- /dev/null +++ b/test/test15.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test15.js","sourceRoot":"","sources":["../src/test/test15.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAGd,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CAAC,CAAC;IAdS,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAEtE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAEpB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AAEzE,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAEpB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AAGzE,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAEpB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;IAEtE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test16.d.ts b/test/test16.d.ts new file mode 100644 index 0000000..d0f0282 --- /dev/null +++ b/test/test16.d.ts @@ -0,0 +1,4 @@ +export declare class MyClass { + constructor(); + myMethod: (input: string) => Promise<[string, number]>; +} diff --git a/test/test16.js b/test/test16.js new file mode 100644 index 0000000..b890f52 --- /dev/null +++ b/test/test16.js @@ -0,0 +1,86 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +exports.MyClass = void 0; +var runExclusive = require("../lib/runExclusive"); +var runCount = 0; +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.myMethod = runExclusive.buildMethod(function (input) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })]; + case 1: + _a.sent(); + runCount++; + return [2 /*return*/, [input + " 0K", 666]]; + } + }); + }); }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var inst = new MyClass(); +(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, out1, out2; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, inst.myMethod("yo")]; + case 1: + _a = _b.sent(), out1 = _a[0], out2 = _a[1]; + console.assert(out1 === "yo 0K" && out2 === 666); + inst.myMethod("ya").then(function (_a) { + var out1 = _a[0], out2 = _a[1]; + return console.assert(out1 == "ya 0K" && out2 === 666); + }); + inst.myMethod("foo"); + setTimeout(function () { + console.assert(runCount === 2); + }, 1100); + setTimeout(function () { + console.assert(runCount === 3); + console.log("DONE"); + }, 3100); + return [2 /*return*/]; + } + }); +}); })(); +//# sourceMappingURL=test16.js.map \ No newline at end of file diff --git a/test/test16.js.map b/test/test16.js.map new file mode 100644 index 0000000..db91e06 --- /dev/null +++ b/test/test16.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test16.js","sourceRoot":"","sources":["../src/test/test16.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD,IAAI,QAAQ,GAAE,CAAC,CAAC;AAEhB;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,KAAa;;;4BAEhB,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAG,OAAA,UAAU,CAAC,cAA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++ b/test/test17.d.ts @@ -0,0 +1,4 @@ +export declare class MyClass { + constructor(); + myMethod: (input: number) => Promise; +} diff --git a/test/test17.js b/test/test17.js new file mode 100644 index 0000000..1006417 --- /dev/null +++ b/test/test17.js @@ -0,0 +1,85 @@ +"use strict"; +//Import ExecStack to be able to export stacked function +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +exports.MyClass = void 0; +var runExclusive = require("../lib/runExclusive"); +var runCount = 0; +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.myMethod = runExclusive.buildMethod(function (input) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })]; + case 1: + _a.sent(); + runCount++; + return [2 /*return*/, "input: " + input.toString()]; + } + }); + }); }); + } + ; + return MyClass; +}()); +exports.MyClass = MyClass; +var inst = new MyClass(); +(function () { return __awaiter(void 0, void 0, void 0, function () { + var out; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, inst.myMethod(111)]; + case 1: + out = _a.sent(); + console.log(out); + console.log(out === "input: 111"); + inst.myMethod(222).then(function (out) { return console.log(out === "input: 222"); }); + inst.myMethod(333); + setTimeout(function () { + console.assert(runCount === 2); + }, 1100); + setTimeout(function () { + console.assert(runCount === 3); + console.log("DONE"); + }, 3100); + return [2 /*return*/]; + } + }); +}); })(); +//# sourceMappingURL=test17.js.map \ No newline at end of file diff --git a/test/test17.js.map b/test/test17.js.map new file mode 100644 index 0000000..35edc64 --- /dev/null +++ b/test/test17.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test17.js","sourceRoot":"","sources":["../src/test/test17.ts"],"names":[],"mappings":";AAAA,wDAAwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExD,kDAAoD;AAEpD,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,KAAa;;;4BAEhB,q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d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test18.js b/test/test18.js new file mode 100644 index 0000000..15f4c1a --- /dev/null +++ b/test/test18.js @@ -0,0 +1,69 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var alphabet = ""; +var myFunction = runExclusive.build(function (char) { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 10); })]; + case 1: + _a.sent(); + alphabet += char; + return [2 /*return*/]; + } + }); +}); }); +(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + myFunction("a"); + myFunction("b"); + runExclusive.getPrComplete(myFunction).then(function () { + console.assert(alphabet === "ab"); + }); + return [4 /*yield*/, myFunction("c")]; + case 1: + _a.sent(); + console.assert(alphabet === "abc"); + return [2 /*return*/]; + } + }); +}); })(); +//# sourceMappingURL=test18.js.map \ No newline at end of file diff --git a/test/test18.js.map b/test/test18.js.map new file mode 100644 index 0000000..1370e29 --- /dev/null +++ b/test/test18.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test18.js","sourceRoot":"","sources":["../src/test/test18.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD,IAAI,QAAQ,GAAE,EAAE,CAAC;AAEjB,IAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CACjC,UAAO,IAAY;;;oBAEf,qBAAM,IAAI,OAAO,CAAC,UAAA,OAAO,IAAG,OAAA,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,EAAvB,CAAuB,CAAC,EAAA;;gBAApD,SAAoD,CAAC;gBAErD,QAAQ,IAAG,IAAI,CAAC;;;;KAEnB,CACJ,CAAC;AAGF,CAAC;;;;gBAGG,UAAU,CAAC,GAAG,CAAC,CAAC;gBAEhB,UAAU,CAAC,GAAG,CAAC,CAAC;gBAEhB,YAAY,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;oBAExC,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;gBACtC,CAAC,CAAC,CAAC;gBAEH,qBAAM,UAAU,CAAC,GAAG,CAAC,EAAA;;gBAArB,SAAqB,CAAC;gBAEtB,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC;;;;KAEtC,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/test/test2.d.ts b/test/test2.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test2.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test2.js b/test/test2.js new file mode 100644 index 0000000..19e7428 --- /dev/null +++ b/test/test2.js @@ -0,0 +1,88 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.groupRefAlphabet = runExclusive.createGroupRef(); + this.alphabetStack = ""; + this.myMethodUpperCase = runExclusive.buildMethod(this.groupRefAlphabet, function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, Math.random() * 1000); })]; + case 1: + _a.sent(); + this.alphabetStack += char.toUpperCase(); + return [2 /*return*/, this.alphabetStack]; + } + }); + }); }); + this.myMethod = runExclusive.buildMethod(this.groupRefAlphabet, function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, Math.random() * 1000); })]; + case 1: + _a.sent(); + this.alphabetStack += char; + return [2 /*return*/, this.alphabetStack]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +inst.myMethod("a"); +for (var _i = 0, _a = ["b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethodUpperCase(char).then(function (alphabet) { return console.log("step " + alphabet); }); +} +for (var _b = 0, _c = ["g", "h", "i"]; _b < _c.length; _b++) { + var char = _c[_b]; + inst.myMethod(char).then(function (alphabet) { return console.log("step " + alphabet); }); +} +inst.myMethod("j").then(function (alphabet) { + console.log("completed " + alphabet); + //cSpell: disable + console.assert(alphabet === "aBCDEFghij"); + //cSpell: enable + console.log("PASS"); +}); +//# sourceMappingURL=test2.js.map \ No newline at end of file diff --git a/test/test2.js.map b/test/test2.js.map new file mode 100644 index 0000000..e62f732 --- /dev/null +++ b/test/test2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test2.js","sourceRoot":"","sources":["../src/test/test2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAe;QAEE,qBAAgB,GAAE,YAAY,CAAC,cAAc,EAAE,CAAC;QAEzD,kBAAa,GAAE,EAAE,CAAC;QAEnB,sBAAiB,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,gBAAgB,EACrE,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAG,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,MAAM,EAAE,GAAC,IAAI,CAAC,EAA7C,CAA6C,CAAC,EAAA;;wBAAhF,SAAgF,CAAC;wBAEjF,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;wBAEzC,sBAAO,IAAI,CAAC,aAAa,EAAC;;;aAE7B,CACJ,CAAC;QAEK,aAAQ,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAC5D,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAG,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,MAAM,EAAE,GAAC,IAAI,CAAC,EAA7C,CA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3.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test3.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test3.js b/test/test3.js new file mode 100644 index 0000000..f811d74 --- /dev/null +++ b/test/test3.js @@ -0,0 +1,94 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(runExclusive.createGroupRef(), function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var start = Date.now(); +var inst1 = new MyClass(); +inst1.myMethod("a", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("b", 1000).then(function (alphabet) { return console.log(alphabet); }); +var inst2 = new MyClass(); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst2.myMethod(char, wait).then(function (alphabet) { return console.log(alphabet); }); +} +inst2.myMethod("a", wait).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + var expectedDuration = (rev.length + 1) * 500; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +inst1.myMethod("c", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("d", 1000).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); +}); +//# sourceMappingURL=test3.js.map \ No newline at end of file diff --git a/test/test3.js.map b/test/test3.js.map new file mode 100644 index 0000000..4115f0b --- /dev/null +++ b/test/test3.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test3.js","sourceRoot":"","sources":["../src/test/test3.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAe;QAER,aAAQ,GAAE,EAAE,CAAC;QAEb,aAAQ,GAAE,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC,cAAc,EAAE,EACvE,UAAO,IAAY,EAAE,IAAY;;;4BAE7B,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAG,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAlE,SAAkE,CAAC;wBAEnE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CAAC,CAAC;IAbW,CAAC;IAAA,CAAC;IAgBpB,cAAC;AAAD,CAAC,AAlBD,IAkBC;AAGD,IAAI,KAAK,GAAE,IAAI,CAAC,GAAG,EAAE,CAAC;AAEtB,IAAI,KAAK,GAAE,IAAI,OAAO,EAAE,CAAC;AAEzB,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAE,UAAA,QAAQ,IAAG,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AAClE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAE,UAAA,QAAQ,IAAG,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AAElE,I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,CAAC;AAEH,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAE,UAAA,QAAQ,IAAG,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AAClE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAE;IAE5B,IAAI,QAAQ,GAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAEjC,iBAAiB;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAE,CAAC;IAC3C,gBAAgB;IAEhB,IAAI,gBAAgB,GAAE,IAAI,GAAC,CAAC,CAAC;IAE7B,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAE,IAAI,CAAC,GAAG,CAAE,QAAQ,GAAG,gBAAgB,CAAC,GAAI,GAAG,CAAE,CAAC;IAChE,OAAO,CAAC,MAAM,CAAE,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAE,CAAC;AAEvD,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test4.d.ts b/test/test4.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test4.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test4.js b/test/test4.js new file mode 100644 index 0000000..2d319c5 --- /dev/null +++ b/test/test4.js @@ -0,0 +1,94 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var start = Date.now(); +var inst1 = new MyClass(); +inst1.myMethod("a", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("b", 1000).then(function (alphabet) { return console.log(alphabet); }); +var inst2 = new MyClass(); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst2.myMethod(char, wait).then(function (alphabet) { return console.log(alphabet); }); +} +inst2.myMethod("a", wait).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable + var expectedDuration = (rev.length + 1) * wait; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +inst1.myMethod("c", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("d", 1000).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); +}); +//# sourceMappingURL=test4.js.map \ No newline at end of file diff --git a/test/test4.js.map b/test/test4.js.map new file mode 100644 index 0000000..7a747da --- /dev/null +++ b/test/test4.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test4.js","sourceRoot":"","sources":["../src/test/test4.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY,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AAG,IAAI,GAAG,CAAC,CAAC;IAEhC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;AAErD,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test5.d.ts b/test/test5.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test5.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test5.js b/test/test5.js new file mode 100644 index 0000000..fb51973 --- /dev/null +++ b/test/test5.js @@ -0,0 +1,89 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(MyClass.groupRef, function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + MyClass.groupRef = runExclusive.createGroupRef(); + return MyClass; +}()); +var start = Date.now(); +var inst1 = new MyClass(); +inst1.myMethod.call(MyClass, "a", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst1.myMethod.call(MyClass, "b", 1000).then(function (alphabet) { return console.log(alphabet); }); +var inst2 = new MyClass(); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst2.myMethod.call(MyClass, char, wait).then(function (alphabet) { return console.log(alphabet); }); +} +inst2.myMethod.call(MyClass, "a", wait).then(function () { + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable +}); +inst1.myMethod.call(MyClass, "c", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst1.myMethod.call(MyClass, "d", 1000).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst1.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4 + (rev.length + 1) * wait; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +//# sourceMappingURL=test5.js.map \ No newline at end of file diff --git a/test/test5.js.map b/test/test5.js.map new file mode 100644 index 0000000..9fd6267 --- /dev/null +++ b/test/test5.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test5.js","sourceRoot":"","sources":["../src/test/test5.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAId,aAAQ,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,EACvD,UAAO,IAAY,EAAE,IAAY;;;4BAE7B,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CACJ,CAAC;IAhBc,CAAC;IAAA,CAAC;IAIK,gBAAQ,GAAG,YAAY,CAAC,cAAc,EAAE,CAAC;IAepE,cAAC;CAAA,AArBD,IAqBC;AAGD,IAAI,KAAK,GAAG,IAAI,CAA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,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AAChF,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;IAEzC,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAElC,iBAAiB;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;IAC1C,gBAAgB;IAEhB,IAAI,gBAAgB,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAE1D,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;IAEjD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test6.d.ts b/test/test6.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test6.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test6.js b/test/test6.js new file mode 100644 index 0000000..b1a0dc5 --- /dev/null +++ b/test/test6.js @@ -0,0 +1,108 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var groupRefAlphabet = runExclusive.createGroupRef(); +var MyClass1 = /** @class */ (function () { + function MyClass1() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.build(groupRefAlphabet, function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet += char.toUpperCase(); + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass1; +}()); +var MyClass2 = /** @class */ (function () { + function MyClass2() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.build(groupRefAlphabet, function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass2; +}()); +var start = Date.now(); +var inst1 = new MyClass1(); +inst1.myMethod("a", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("b", 1000).then(function (alphabet) { return console.log(alphabet); }); +var inst2 = new MyClass2(); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst2.myMethod(char, wait).then(function (alphabet) { return console.log(alphabet); }); +} +inst2.myMethod("a", wait).then(function () { + //cSpell: disable + console.assert(inst2.alphabet === "nmlkjihgfedcba"); + //cSpell: enable +}); +inst1.myMethod("c", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst1.myMethod("d", 1000).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst1.alphabet === "ABCD"); + //cSpell: enable + var expectedDuration = 1000 * 4 + (rev.length + 1) * 500; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +//# sourceMappingURL=test6.js.map \ No newline at end of file diff --git a/test/test6.js.map b/test/test6.js.map new file mode 100644 index 0000000..65418a2 --- /dev/null +++ b/test/test6.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test6.js","sourceRoot":"","sources":["../src/test/test6.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD,IAAM,gBAAgB,GAAE,YAAY,CAAC,cAAc,EAAE,CAAC;AAEtD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,gBAAgB,EACjD,UAAO,IAAY,EAAE,IAAY;;;4BAE7B,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;wBAEpC,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CAAC,CAAC;IAbS,CAAC;IAAA,CAAC;IAetB,eAAC;AAAD,CAAC,AAjBD,IAiBC;AAED;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,gBAAgB,EACjD,UAAO,IAAY,EAAE,IAAY;;;4BAE7B,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CA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;AAEH,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAE,CAAC,IAAI,CAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AACpE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAE,CAAC,IAAI,CAAE;IAE7B,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAElC,iBAAiB;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;IAC1C,gBAAgB;IAEhB,IAAI,gBAAgB,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAEzD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;IAEjD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAExB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test7.d.ts b/test/test7.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test7.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test7.js b/test/test7.js new file mode 100644 index 0000000..36e2437 --- /dev/null +++ b/test/test7.js @@ -0,0 +1,105 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod1 = runExclusive.buildMethod(runExclusive.createGroupRef(), function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + this.alphabet2 = ""; + this.myMethod2 = runExclusive.buildMethod(function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet2 += char; + return [2 /*return*/, this.alphabet2]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var start = Date.now(); +var inst = new MyClass(); +inst.myMethod1("a", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst.myMethod1("b", 1000).then(function (alphabet) { return console.log(alphabet); }); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst.myMethod2(char, wait).then(function (alphabet) { return console.log(alphabet); }); +} +inst.myMethod2("a", wait).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst.alphabet2 === "nmlkjihgfedcba"); + //cSpell: enable + var expectedDuration = (rev.length + 1) * wait; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +inst.myMethod1("c", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst.myMethod1("d", 1000).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); +}); +//# sourceMappingURL=test7.js.map \ No newline at end of file diff --git a/test/test7.js.map b/test/test7.js.map new file mode 100644 index 0000000..c61d791 --- /dev/null +++ b/test/test7.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test7.js","sourceRoot":"","sources":["../src/test/test7.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAe;QAER,aAAQ,GAAE,EAAE,CAAC;QAEb,cAAS,GAAE,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC,cAAc,EAAE,EACpE,UAAO,IAAY,EAAE,IAAY;;;4BAE7B,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CACJ,CAAC;QAEK,cAAS,GAAG,EAAE,CAAC;QAEf,cAAS,GAAG,YAAY,CAAC,WAAW,CACvC,UAAO,IAAY,EAAE,IAAY;;;4BAE7B,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC;wBAEvB,sBAAO,IAAI,CAAC,SAAS,EAAC;;;aAEzB,CACJ,CAAC;IA5BY,CAAC;IAAA,CAAC;IAiCpB,cAAC;AAAD,CAAC,AAnCD,IAmCC;AAGD,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAEvB,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,IAAI,CAAC,SAAS,C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AEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;IAEjD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAGxB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAE,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAArB,CAAqB,CAAC,CAAC;AACnE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAE;IAE5B,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAElC,iBAAiB;IACjB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;IACzC,gBAAgB;IAEhB,IAAI,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC;IAEhC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC;AAGrD,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/test8.d.ts b/test/test8.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/test8.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test8.js b/test/test8.js new file mode 100644 index 0000000..3d7a924 --- /dev/null +++ b/test/test8.js @@ -0,0 +1,105 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod1 = runExclusive.buildMethod(function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + this.alphabet2 = ""; + this.myMethod2 = runExclusive.buildMethod(function (char, wait) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, wait); })]; + case 1: + _a.sent(); + this.alphabet2 += char; + return [2 /*return*/, this.alphabet2]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var start = Date.now(); +var inst = new MyClass(); +inst.myMethod1("a", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst.myMethod1("b", 1000).then(function (alphabet) { return console.log(alphabet); }); +var rev = ["n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b"]; +var wait = 500; +for (var _i = 0, rev_1 = rev; _i < rev_1.length; _i++) { + var char = rev_1[_i]; + inst.myMethod2(char, wait).then(function (alphabet) { return console.log(alphabet); }); +} +inst.myMethod2("a", wait).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst.alphabet2 === "nmlkjihgfedcba"); + //cSpell: enable + var expectedDuration = (rev.length + 1) * 500; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); + console.log("PASS"); +}); +inst.myMethod1("c", 1000).then(function (alphabet) { return console.log(alphabet); }); +inst.myMethod1("d", 1000).then(function () { + var duration = Date.now() - start; + //cSpell: disable + console.assert(inst.alphabet === "abcd"); + //cSpell: enable + var expectedDuration = 1000 * 4; + console.log("expectedDuration: ", expectedDuration); + console.log("duration: ", duration); + console.assert(Math.abs(duration - expectedDuration) < 300); + console.assert(duration - expectedDuration >= 0); +}); +//# sourceMappingURL=test8.js.map \ No newline at end of file diff --git a/test/test8.js.map b/test/test8.js.map new file mode 100644 index 0000000..4230054 --- /dev/null +++ b/test/test8.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test8.js","sourceRoot":"","sources":["../src/test/test8.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAe;QAER,aAAQ,GAAE,EAAE,CAAC;QAEb,cAAS,GAAE,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY,EAAE,IAAY;;;4BAE7B,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAE,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAC,IAAI,CAAC,EAA9B,CAA8B,CAAC,EAAA;;wBAAhE,SAAgE,CAAC;wBAEjE,IAAI,CAAC,QAAQ,IAAG,IAAI,CAAC;wBAErB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAE5B,CAAC,CAAC;QAEI,cAAS,GAAE,EAAE,CAAC;QAEd,cAAS,GAAE,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY,EAAE,IAAY;;;4BAE7B,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAE,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAC,IAAI,CAAC,EAA9B,CAA8B,CAAC,EAAA;;wBAAhE,SAAgE,CAAC;wBAEjE,IAAI,CAAC,SAAS,IAAG,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,SAAS,EAAC;;;aAE7B,CAAC,CAAC;IA1BW,CAAC;IAAA,CAAC;IA4BpB,cAAC;AAAD,CAAC,AA9BD,IA8BC;AAGD,IAAI,KAAK,GAAE,IAAI,CA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test/test9.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/test9.js b/test/test9.js new file mode 100644 index 0000000..8a37758 --- /dev/null +++ b/test/test9.js @@ -0,0 +1,73 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +var MyClass = /** @class */ (function () { + function MyClass() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })]; + case 1: + _a.sent(); + this.alphabet += char; + return [2 /*return*/, this.alphabet]; + } + }); + }); }); + } + ; + return MyClass; +}()); +var inst = new MyClass(); +setTimeout(function () { + console.assert(runExclusive.getQueuedCallCount(inst.myMethod, inst) === 3); + console.assert(inst.alphabet === "ab"); + runExclusive.cancelAllQueuedCalls(inst.myMethod, inst); + setTimeout(function () { + console.assert(inst.alphabet === "abc"); + console.log("PASS"); + }, 2000); +}, 2900); +for (var _i = 0, _a = ["a", "b", "c", "d", "e", "f"]; _i < _a.length; _i++) { + var char = _a[_i]; + inst.myMethod(char).then(function (alphabet) { return console.log("step " + alphabet); }); +} +//# sourceMappingURL=test9.js.map \ No newline at end of file diff --git a/test/test9.js.map b/test/test9.js.map new file mode 100644 index 0000000..a77e7d9 --- /dev/null +++ b/test/test9.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test9.js","sourceRoot":"","sources":["../src/test/test9.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD;IAEI;QAAA,iBAAiB;QAEV,aAAQ,GAAG,EAAE,CAAC;QAEd,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY;;;4BAEf,qBAAM,IAAI,OAAO,CAAO,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,cAAI,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC,EAAA;;wBAAnE,SAAmE,CAAC;wBAEpE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;wBAEtB,sBAAO,IAAI,CAAC,QAAQ,EAAC;;;aAExB,CACJ,CAAC;IAdc,CAAC;IAAA,CAAC;IAiBtB,cAAC;AAAD,CAAC,AAnBD,IAmBC;AAED,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAEzB,UAAU,CAAC;IAEP,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAE1E,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;IAEvC,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAEvD,UAAU,CAAC;QAEP,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC;QAExC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAExB,CAAC,EAAE,IAAI,CAAC,CAAC;AAEb,CAAC,EAAE,IAAI,CAAC,CAAC;AAET,KAAiB,UAA8B,EAA9B,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAA9B,cAA8B,EAA9B,IAA8B,EAAC;IAA3C,IAAI,IAAI,SAAA;IACT,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,UAAQ,QAAU,CAAC,EAA/B,CAA+B,CAAC,CAAC;CACzE"} \ No newline at end of file diff --git a/test/testMem1.d.ts b/test/testMem1.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/testMem1.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/testMem1.js b/test/testMem1.js new file mode 100644 index 0000000..d8ad309 --- /dev/null +++ b/test/testMem1.js @@ -0,0 +1,95 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +function print_mem() { + var used = process.memoryUsage(); + for (var key in used) { + console.log(key + " " + Math.round(used[key] / 1024 / 1024 * 100) / 100 + " MB"); + } +} +var A = /** @class */ (function () { + function A() { + var _this = this; + this.alphabet = ""; + this.myMethod = runExclusive.buildMethod(function (char) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!(char === "a")) return [3 /*break*/, 2]; + return [4 /*yield*/, new Promise(function (resolve) { return process.nextTick(resolve); })]; + case 1: + _a.sent(); + _a.label = 2; + case 2: + this.alphabet += char; + return [2 /*return*/]; + } + }); + }); }); + } + return A; +}()); +(function () { return __awaiter(void 0, void 0, void 0, function () { + var i, a; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!true) return [3 /*break*/, 5]; + i = 0; + _a.label = 1; + case 1: + if (!(i < 7000)) return [3 /*break*/, 4]; + a = new A(); + a.myMethod("a"); + return [4 /*yield*/, a.myMethod("b")]; + case 2: + _a.sent(); + console.assert(a.alphabet === "ab"); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: + print_mem(); + return [3 /*break*/, 0]; + case 5: return [2 /*return*/]; + } + }); +}); })(); +//# sourceMappingURL=testMem1.js.map \ No newline at end of file diff --git a/test/testMem1.js.map b/test/testMem1.js.map new file mode 100644 index 0000000..b0d7935 --- /dev/null +++ b/test/testMem1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testMem1.js","sourceRoot":"","sources":["../src/test/testMem1.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAAoD;AAEpD,SAAS,SAAS;IAEd,IAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACnC,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE;QAClB,OAAO,CAAC,GAAG,CAAI,GAAG,SAAI,IAAI,CAAC,KAAK,CAAE,IAAY,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,QAAK,CAAC,CAAC;KACxF;AAEL,CAAC;AAED;IAAA;QAAA,iBAkBC;QAhBU,aAAQ,GAAE,EAAE,CAAC;QAEb,aAAQ,GAAG,YAAY,CAAC,WAAW,CACtC,UAAO,IAAY;;;;6BAEX,CAAA,IAAI,KAAK,GAAG,CAAA,EAAZ,wBAAY;wBAEZ,qBAAM,IAAI,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAzB,CAAyB,CAAC,EAAA;;wBAAvD,SAAuD,CAAC;;;wBAK5D,IAAI,CAAC,QAAQ,IAAG,IAAI,CAAC;;;;aACxB,CACJ,CAAC;IAEN,CAAC;IAAD,QAAC;AAAD,CAAC,AAlBD,IAkBC;AAED,CAAC;;;;;qBAEU,IAAI;gBAEE,CAAC,GAAG,CAAC;;;qBAAE,CAAA,CAAC,GAAG,IAAI,CAAA;gBAEd,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;gBAElB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAChB,qBAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAA;;gBAArB,SAAqB,CAAC;gBAEtB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;;;gBAPd,CAAC,EAAE,CAAA;;;gBAW7B,SAAS,EAAE,CAAC;;;;;KAInB,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/test/testMem2.d.ts b/test/testMem2.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/testMem2.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/testMem2.js b/test/testMem2.js new file mode 100644 index 0000000..fb5d7e9 --- /dev/null +++ b/test/testMem2.js @@ -0,0 +1,101 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var runExclusive = require("../lib/runExclusive"); +function print_mem() { + var used = process.memoryUsage(); + for (var key in used) { + console.log(key + " " + Math.round(used[key] / 1024 / 1024 * 100) / 100 + " MB"); + } +} +console.log("GLOBAL"); +(function () { return __awaiter(void 0, void 0, void 0, function () { + var _loop_1, i; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!true) return [3 /*break*/, 5]; + _loop_1 = function (i) { + var alphabet, myFunction; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + alphabet = ""; + myFunction = runExclusive.build(function (char) { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!(char === "a")) return [3 /*break*/, 2]; + return [4 /*yield*/, new Promise(function (resolve) { return process.nextTick(resolve); })]; + case 1: + _a.sent(); + _a.label = 2; + case 2: + alphabet += char; + return [2 /*return*/]; + } + }); + }); }); + myFunction("a"); + return [4 /*yield*/, myFunction("b")]; + case 1: + _a.sent(); + console.assert(alphabet === "ab"); + return [2 /*return*/]; + } + }); + }; + i = 0; + _a.label = 1; + case 1: + if (!(i < 7000)) return [3 /*break*/, 4]; + return [5 /*yield**/, _loop_1(i)]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: + print_mem(); + return [3 /*break*/, 0]; + case 5: return [2 /*return*/]; + } + }); +}); })(); +//# sourceMappingURL=testMem2.js.map \ No newline at end of file diff --git a/test/testMem2.js.map b/test/testMem2.js.map new file mode 100644 index 0000000..ceef18f --- /dev/null +++ b/test/testMem2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testMem2.js","sourceRoot":"","sources":["../src/test/testMem2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoD;AAEpD,SAAS,SAAS;IAEd,IAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACnC,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE;QAClB,OAAO,CAAC,GAAG,CAAI,GAAG,SAAI,IAAI,CAAC,KAAK,CAAE,IAAY,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,QAAK,CAAC,CAAC;KACxF;AAEL,CAAC;AAED,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEtB,CAAC;;;;;qBAEU,IAAI;oCAEE,CAAC;;;;;gCAEF,QAAQ,GAAE,EAAE,CAAC;gCAEX,UAAU,GAAE,YAAY,CAAC,KAAK,CAAC,UAAO,IAAY;;;;qDAEhD,CAAA,IAAI,KAAK,GAAG,CAAA,EAAZ,wBAAY;gDAEZ,qBAAM,IAAI,OAAO,CAAC,UAAA,OAAO,IAAG,OAAA,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAzB,CAAyB,CAAC,EAAA;;gDAAtD,SAAsD,CAAC;;;gDAI3D,QAAQ,IAAG,IAAI,CAAA;;;;qCAElB,CAAC,CAAC;gCAEH,UAAU,CAAC,GAAG,CAAC,CAAC;gCAChB,qBAAM,UAAU,CAAC,GAAG,CAAC,EAAA;;gCAArB,SAAqB,CAAC;gCAEtB,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;;;;;gBAnB7B,CAAC,GAAG,CAAC;;;qBAAE,CAAA,CAAC,GAAG,IAAI,CAAA;8CAAf,CAAC;;;;;gBAAgB,CAAC,EAAE,CAAA;;;gBAuB7B,SAAS,EAAE,CAAC;;;;;KAInB,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/tsconfig.tsbuildinfo b/tsconfig.tsbuildinfo new file mode 100644 index 0000000..54a2232 --- /dev/null +++ b/tsconfig.tsbuildinfo @@ -0,0 +1,1925 @@ +{ + "program": { + "fileInfos": { + "../node_modules/typescript/lib/lib.es5.d.ts": { + "version": "70ae6416528e68c2ee7b62892200d2ca631759943d4429f8b779b947ff1e124d", + "signature": "70ae6416528e68c2ee7b62892200d2ca631759943d4429f8b779b947ff1e124d", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.d.ts": { + "version": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", + "signature": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", + "affectsGlobalScope": false + }, + "../node_modules/typescript/lib/lib.es2016.d.ts": { + "version": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", + "signature": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", + "affectsGlobalScope": false + }, + "../node_modules/typescript/lib/lib.es2017.d.ts": { + "version": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", + "signature": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", + "affectsGlobalScope": false + }, + "../node_modules/typescript/lib/lib.es2018.d.ts": { + "version": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", + "signature": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", + "affectsGlobalScope": false + }, + "../node_modules/typescript/lib/lib.es2015.core.d.ts": { + "version": "63e0cc12d0f77394094bd19e84464f9840af0071e5b9358ced30511efef1d8d2", + "signature": "63e0cc12d0f77394094bd19e84464f9840af0071e5b9358ced30511efef1d8d2", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.collection.d.ts": { + "version": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", + "signature": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.generator.d.ts": { + "version": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", + "signature": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.iterable.d.ts": { + "version": "42f5e41e5893da663dbf0394268f54f1da4b43dc0ddd2ea4bf471fe5361d6faf", + "signature": "42f5e41e5893da663dbf0394268f54f1da4b43dc0ddd2ea4bf471fe5361d6faf", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.promise.d.ts": { + "version": "0b7a905675e6cb4211c128f0a3aa47d414b275180a299a9aad5d3ec298abbfc4", + "signature": "0b7a905675e6cb4211c128f0a3aa47d414b275180a299a9aad5d3ec298abbfc4", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.proxy.d.ts": { + "version": "dfff68b3c34338f6b307a25d4566de15eed7973b0dc5d69f9fde2bcac1c25315", + "signature": "dfff68b3c34338f6b307a25d4566de15eed7973b0dc5d69f9fde2bcac1c25315", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.reflect.d.ts": { + "version": "cb609802a8698aa28b9c56331d4b53f590ca3c1c3a255350304ae3d06017779d", + "signature": "cb609802a8698aa28b9c56331d4b53f590ca3c1c3a255350304ae3d06017779d", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.symbol.d.ts": { + "version": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", + "signature": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": { + "version": "4670208dd7da9d6c774ab1b75c1527a810388c7989c4905de6aaea8561cb9dce", + "signature": "4670208dd7da9d6c774ab1b75c1527a810388c7989c4905de6aaea8561cb9dce", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2016.array.include.d.ts": { + "version": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", + "signature": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2017.object.d.ts": { + "version": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", + "signature": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": { + "version": "d0db416bccdb33975548baf09a42ee8c47eace1aac7907351a000f1e568e7232", + "signature": "d0db416bccdb33975548baf09a42ee8c47eace1aac7907351a000f1e568e7232", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2017.string.d.ts": { + "version": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", + "signature": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2017.intl.d.ts": { + "version": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", + "signature": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": { + "version": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", + "signature": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": { + "version": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", + "signature": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": { + "version": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", + "signature": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2018.intl.d.ts": { + "version": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", + "signature": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2018.promise.d.ts": { + "version": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", + "signature": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2018.regexp.d.ts": { + "version": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", + "signature": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.es2020.bigint.d.ts": { + "version": "4f435f794b7853c55e2ae7cff6206025802aa79232d2867544178f2ca8ff5eaa", + "signature": "4f435f794b7853c55e2ae7cff6206025802aa79232d2867544178f2ca8ff5eaa", + "affectsGlobalScope": true + }, + "../node_modules/typescript/lib/lib.esnext.intl.d.ts": { + "version": "89bf2b7a601b73ea4311eda9c41f86a58994fec1bee3b87c4a14d68d9adcdcbd", + "signature": "89bf2b7a601b73ea4311eda9c41f86a58994fec1bee3b87c4a14d68d9adcdcbd", + "affectsGlobalScope": true + }, + "../node_modules/minimal-polyfills/WeakMap.d.ts": { + "version": "8859f48246358af1e7e026f24ea47730737bb043c96e2228f4dfd22041fa589b", + "signature": "8859f48246358af1e7e026f24ea47730737bb043c96e2228f4dfd22041fa589b", + "affectsGlobalScope": false + }, + "../src/lib/runExclusive.ts": { + "version": "d001b8fba3b9dddd390e7be457aa025802c4b3d314b6eb07838ac6917a963734", + "signature": "b054215863e7c7889e10b9aca80a27525587560d2148645a85609dd79faa66be", + "affectsGlobalScope": false + }, + "../src/test/index.ts": { + "version": "c3e8434f2133903cf2b9377338f85ea1c97961ea3767836cca7af1a91d0b5a61", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test1.ts": { + "version": "36eda714e6a35d4ba884dac12977c808f0b6d5a8ff44a714339c6578eb79feea", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test2.ts": { + "version": "8d4504c4711e4840c62a34904e97a953607d84b357e00663ecdca8f96deb92d6", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test3.ts": { + "version": "9a0ad53f9c0fb00ab99d3494a83b360a9858a8f58b5d7b7e51d880c031d23cea", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test4.ts": { + "version": "b999ed5fb7a4e53ee266d3280445dc7cdc9a2622ea1080685465e8e732eb49bc", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test5.ts": { + "version": "73c8070ac232ece169d788e66dc33b99b96d035b8f01a67bb098d8cbe7f4da0f", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test6.ts": { + "version": "20c05b30234bdbaa7d01adb12ba98d7698b34255b5865ba02933153f3f8edf10", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test7.ts": { + "version": "0a2b6a56a2f5c9a03a573ef6428d4accff306603451d573dd2452366a9e150b9", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test8.ts": { + "version": "89307f4618ff390d514d6f604d62145426217070ad4016bcbe5157f15c46a657", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test9.ts": { + "version": "7d8d8203f93844b142c1416c3b0459374da341074e8a9b4d872fd5e3e44cb605", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test10.ts": { + "version": "194f66b074d0a06cf31505afa5f2e64de5f92e208922579fe9afdad597f2daf8", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test11.ts": { + "version": "20160ecef2bf3955a9790cab690ff7b54fdea108a1ff19e90bf82b5f7a39803c", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test13.ts": { + "version": "6fccd8805923ab1e4b5630d7a6e50d364b306f793c686737dbebad183a0589bf", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test14.ts": { + "version": "d9135f93d8785785e39ba2c714dd353191fb521cd4233a973643c80319cf355f", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test15.ts": { + "version": "6b9862d903305ef66f1bf2083845ae433570775bbe15b0a0d3be66633e66e3b7", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/test16.ts": { + "version": "663b901f30b0bbcbf3a1f91c705c6dfa1887a30d223fc6180e1c7ce5620087ac", + "signature": "025f3b82c00ed58d2d64621cf225ae657886dc122d384dc43e88bdfb27d06ed3", + "affectsGlobalScope": false + }, + "../src/test/test17.ts": { + "version": "8043badf8a879da8c7f62ecbd9ef9e8dee0a3c26ced530e553a66c924472aa79", + "signature": "9c0957c873589b6d979c4c5861e02be5e2dba7317a32dfebd23479dee416b73a", + "affectsGlobalScope": false + }, + "../src/test/test18.ts": { + "version": "8afa7ef407c3ce6dc1a8f2cb17b5c5dc6665d8666a83d14eb0df607f142a4fa2", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/mod.ts": { + "version": "c0f0905c8378039f5b42240d70485355f1f5396a9825457e4a5ca518e86a08e8", + "signature": "2be05d47e2978dbc99fd77db048fc6ae5f63668dbea3fc1395e96f18b94d72c0", + "affectsGlobalScope": false + }, + "../node_modules/ts-evt/node_modules/minimal-polyfills/dist/lib/Array.prototype.find.d.ts": { + "version": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "signature": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "affectsGlobalScope": false + }, + "../node_modules/ts-evt/dist/lib/defs.d.ts": { + "version": "b59784276dce6cc61be48b01eebd9ade2808271d5a6ec357fa087e45d8919d80", + "signature": "b59784276dce6cc61be48b01eebd9ade2808271d5a6ec357fa087e45d8919d80", + "affectsGlobalScope": false + }, + "../node_modules/ts-evt/dist/lib/EvtBaseProtected.d.ts": { + "version": "704c89efc359a5b6833660b9a9d3fde3cebc53830963f24d8ac055b3a9d788d1", + "signature": "704c89efc359a5b6833660b9a9d3fde3cebc53830963f24d8ac055b3a9d788d1", + "affectsGlobalScope": false + }, + "../node_modules/ts-evt/dist/lib/EvtBase.d.ts": { + "version": "aff5a2e71bc847398440e25d8518b60938c1ddf661abb4aaaeb141a38fe50e8e", + "signature": "aff5a2e71bc847398440e25d8518b60938c1ddf661abb4aaaeb141a38fe50e8e", + "affectsGlobalScope": false + }, + "../node_modules/ts-evt/dist/lib/Evt.d.ts": { + "version": "78824ccf723ab31ecbbe2a39fee673a6d5f313830df1eeebd5077771b016c48e", + "signature": "78824ccf723ab31ecbbe2a39fee673a6d5f313830df1eeebd5077771b016c48e", + "affectsGlobalScope": false + }, + "../node_modules/ts-evt/dist/lib/Observable.d.ts": { + "version": "b0d8bf21a19640c764f41d0f872327df5c8a1810ad536fa1c3ad33ed10c4fd89", + "signature": "b0d8bf21a19640c764f41d0f872327df5c8a1810ad536fa1c3ad33ed10c4fd89", + "affectsGlobalScope": false + }, + "../node_modules/ts-evt/dist/lib/index.d.ts": { + "version": "038e31eb88fd94b3848a5e7c3a3928b42da4cd023f6430b9beaf3abd5881bab0", + "signature": "038e31eb88fd94b3848a5e7c3a3928b42da4cd023f6430b9beaf3abd5881bab0", + "affectsGlobalScope": false + }, + "../src/test/test12.ts": { + "version": "283028aeab0b3d11f36c324d6949c993fd87400bd77dc5e4ca45bd3cf34fc0b1", + "signature": "f3e4f89c0fb7e9e1954e740c9c448a11500bb463f5569917880ee16577c52d96", + "affectsGlobalScope": false + }, + "../src/test/testMem1.ts": { + "version": "29a2d3da939dc6bf463167afa7e07fb6776fba490b9cc97d64ed852f11ca2aa9", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/testMem2.ts": { + "version": "be4c59d6afc8ac29ba0786e85b8de50c8d5641fc7a6333d96fc4e10793e13afd", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/index.ts": { + "version": "79cd82f6284444ab55d1fd7d69ba4f485045cf0ecf3886f0e76dd86a6c192015", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test1.ts": { + "version": "2f1092fc37ede4e80611ec67fe979b0f93f339eb9e6210124832fc37ea7ef4b1", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test10.ts": { + "version": "1ddd71f9b260545835b468976204f21063d8c17edec58ea853408c51d24aa181", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test11.ts": { + "version": "42383623aed6af6d340c6b7ac0ee722f50d4d1de4167fcd3ddfe05838c499f08", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test12.ts": { + "version": "b8ab8a8cc2abc02154bc3f36ca23e4791a1e4b9d31e8bef3ecf4642bc269c0eb", + "signature": "d955f1091586f470b1386d9047455cb804612fd003c2e57cf336fe55ec76e745", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test13.ts": { + "version": "b49c20e2ca15cda4a09d451b6787d4b11c3e1912436a27429a98ebe6f211bf9b", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test14.ts": { + "version": "b8ba73b1d5230bf08d831cf616a10def5b38f11dc576bf7878c20e15b1188772", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test15.ts": { + "version": "0626fedd0bca06bc15a22f6c2f4e77fdbcec98542265eebe03be5c4f753e46e8", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test16.ts": { + "version": "be0857d99935e46eabff37986a5f0d67b4c11ac09cbe9dff06819c7ffe18fdc5", + "signature": "d955f1091586f470b1386d9047455cb804612fd003c2e57cf336fe55ec76e745", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test17.ts": { + "version": "c35310022f31b5d5c3ee0c48c9eb8a23b279201c98bc279bb4644931490a5c47", + "signature": "bae4d565b470ba59e9ebbe70c7e4fa49f1e2a82ea99775a5c99ca29160fb7f03", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test18.ts": { + "version": "87ee56470e78c419fd12e2e5413d30c7bf14a94d2aeceef361125fb0c2bfb660", + "signature": "bae4d565b470ba59e9ebbe70c7e4fa49f1e2a82ea99775a5c99ca29160fb7f03", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test19.ts": { + "version": "a15884fa656831a8207e3fe6def684b51af8397d701ffa611d78bf44f5e64f2b", + "signature": "e0a469d9b3fbaeab7794fe1a1b22634f5f5849f4752cc4ef78ad4b6c3a4a1d18", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test2.ts": { + "version": "a8c335ebc493857b0e346a6e6428941c36a26b97df95caa967208913c4220d5b", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test20.ts": { + "version": "ba25af72ae4059ba56f844d1e6a147915f3ba0d725eb364d8a6f91cdb0fd522b", + "signature": "e1babf49fd8ae0439a1f1d4a5258c124b597d2708ecf6b8f712b5bec2d0ed38e", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test21.ts": { + "version": "da851c9b022b03183a7884c098d7ca759a8414a1c3f27ce3c89b1293c5eaa5a2", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test3.ts": { + "version": "a01f7b6a0845cb6aa15c20e2b8d07165bee2d1b6eaf36af8a7a01492c0858220", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test4.ts": { + "version": "24bcb868a349488afd4fd53f84e8cf75d95262d98b2d2879becb55aa027df3f8", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test5.ts": { + "version": "4e14b26ce25c307f3f6f318e63e745ef533ed1b6285868a80ac41b6ea4d2a74a", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test6.ts": { + "version": "d31bba1a57b25a31a6b1c770d89f60e8159ecf121be89292ed2417a6e1795d97", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test7.ts": { + "version": "21545f3f86f31ab70038b232162a626f7e313e050eaaec3b8f9cbb893fd65cd6", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test8.ts": { + "version": "29054369387551335451979c828165f81e2abf7ac0b6bc210d7d4b64669738e4", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../src/test/legacyTests/test9.ts": { + "version": "a8c50b74fcb942f23afa15a753a76cc479764097b1c50e97f47a5ab29f21c25f", + "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881", + "affectsGlobalScope": false + }, + "../node_modules/@types/comment-json/index.d.ts": { + "version": "c401118ea6c6daa9f196013b0622c602d4faec565bb1cc6ca751d2a8fc295498", + "signature": "c401118ea6c6daa9f196013b0622c602d4faec565bb1cc6ca751d2a8fc295498", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/globals.d.ts": { + "version": "f323beec07a17e0082bfeed95ad57d66c9a65fc799c98511993cb2112a9e1c77", + "signature": "f323beec07a17e0082bfeed95ad57d66c9a65fc799c98511993cb2112a9e1c77", + "affectsGlobalScope": true + }, + "../node_modules/@types/node/async_hooks.d.ts": { + "version": "138476cfdccbb9e2c7e06602bc216af843a56c4f3469a79106bc660ba94bd66a", + "signature": "138476cfdccbb9e2c7e06602bc216af843a56c4f3469a79106bc660ba94bd66a", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/buffer.d.ts": { + "version": "fe892fea1e75a442fffb4a604d7eeb451e858787a9f2f01c4e83bf12a3b5048d", + "signature": "fe892fea1e75a442fffb4a604d7eeb451e858787a9f2f01c4e83bf12a3b5048d", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/child_process.d.ts": { + "version": "1c6fdd94b597c15829e8a12a12c21e1cd931bb24bc5a2b0cbe2bc21474db0eee", + "signature": "1c6fdd94b597c15829e8a12a12c21e1cd931bb24bc5a2b0cbe2bc21474db0eee", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/cluster.d.ts": { + "version": "fcd718b2feb2820a9844536a1a2fbc77a3da90820e02894d40f879a789f46560", + "signature": "fcd718b2feb2820a9844536a1a2fbc77a3da90820e02894d40f879a789f46560", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/console.d.ts": { + "version": "525c8fc510d9632d2a0a9de2d41c3ac1cdd79ff44d3b45c6d81cacabb683528d", + "signature": "525c8fc510d9632d2a0a9de2d41c3ac1cdd79ff44d3b45c6d81cacabb683528d", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/constants.d.ts": { + "version": "ece75b9bfc916f9ccc4e8a9ddee1dda5c987804fbe3b60a01fc120fae731c2ce", + "signature": "ece75b9bfc916f9ccc4e8a9ddee1dda5c987804fbe3b60a01fc120fae731c2ce", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/crypto.d.ts": { + "version": "d70cf14b7dd281408be0a7a239ae92b5e26178ac269da5ed39daf86564d5af4b", + "signature": "d70cf14b7dd281408be0a7a239ae92b5e26178ac269da5ed39daf86564d5af4b", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/dgram.d.ts": { + "version": "3d1cb0eaae19fa89fe381bba6d5a149d1bf34efc0134220879f57e2061732a6d", + "signature": "3d1cb0eaae19fa89fe381bba6d5a149d1bf34efc0134220879f57e2061732a6d", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/dns.d.ts": { + "version": "05e732266b5a36789fd9eb846b1f45fec1b6e318b740e3f20fc22fd95f9ebf31", + "signature": "05e732266b5a36789fd9eb846b1f45fec1b6e318b740e3f20fc22fd95f9ebf31", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/domain.d.ts": { + "version": "ae3487bdb9b50c1d8bbeb6b55c8b2b9aa79bbc46d7afbc3483169ad8750c4304", + "signature": "ae3487bdb9b50c1d8bbeb6b55c8b2b9aa79bbc46d7afbc3483169ad8750c4304", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/events.d.ts": { + "version": "c53b63229a0b7e9d64347c4fc975dd52a9e9a81f9be099f5a21220e2a1276d28", + "signature": "c53b63229a0b7e9d64347c4fc975dd52a9e9a81f9be099f5a21220e2a1276d28", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/fs.d.ts": { + "version": "1733741cf2adc5926ac58c66004268cdc3d34b2ff6250f5114db14253ea02ce1", + "signature": "1733741cf2adc5926ac58c66004268cdc3d34b2ff6250f5114db14253ea02ce1", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/http.d.ts": { + "version": "fb069f40dcd4b7f257ece5f72cffea7f12f67c0b36686a8f9715e5df0bba1f57", + "signature": "fb069f40dcd4b7f257ece5f72cffea7f12f67c0b36686a8f9715e5df0bba1f57", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/http2.d.ts": { + "version": "c9212c26733f9b1ef963a10f6b72da02b31eb1b107cfc4b26279fcdc621e9201", + "signature": "c9212c26733f9b1ef963a10f6b72da02b31eb1b107cfc4b26279fcdc621e9201", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/https.d.ts": { + "version": "152af7c23ec219f632afa2d861abc65993f56cd39a4f3a4018515dbc05950a74", + "signature": "152af7c23ec219f632afa2d861abc65993f56cd39a4f3a4018515dbc05950a74", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/inspector.d.ts": { + "version": "3a0bdc4c5b6f84a1abb5356d7a7fa1f96ac6c5b5646eec3ef2b33c1ed095e155", + "signature": "3a0bdc4c5b6f84a1abb5356d7a7fa1f96ac6c5b5646eec3ef2b33c1ed095e155", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/module.d.ts": { + "version": "03394bf8deb8781b490ae9266a843fbdf00647947d79e25fcbf1d89a9e9c8a66", + "signature": "03394bf8deb8781b490ae9266a843fbdf00647947d79e25fcbf1d89a9e9c8a66", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/net.d.ts": { + "version": "56a15cc211894d79aa44cbb46c276bfd3f10458a61bff2dec99114db8a7e71e3", + "signature": "56a15cc211894d79aa44cbb46c276bfd3f10458a61bff2dec99114db8a7e71e3", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/os.d.ts": { + "version": "1a5366b0d4d0153955fd85777c72d35979dabc0537649da6eade09007c0d080a", + "signature": "1a5366b0d4d0153955fd85777c72d35979dabc0537649da6eade09007c0d080a", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/path.d.ts": { + "version": "61c84c3b0eb6e60196d15ae5e21793a1d4241c547f0bdd0529ffae838d1a073c", + "signature": "61c84c3b0eb6e60196d15ae5e21793a1d4241c547f0bdd0529ffae838d1a073c", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/perf_hooks.d.ts": { + "version": "981192e57b0e159c977f1d8e8b8576e9d6b4e013b902e9c0d4b178cb47e2dc86", + "signature": "981192e57b0e159c977f1d8e8b8576e9d6b4e013b902e9c0d4b178cb47e2dc86", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/process.d.ts": { + "version": "3a8848a9c307429b861402cc69bc472ffe0c05b86474fc158723169161e16389", + "signature": "3a8848a9c307429b861402cc69bc472ffe0c05b86474fc158723169161e16389", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/punycode.d.ts": { + "version": "eeb0d1ad28e70773ac57ae9fe939c3bad6af2525a463c28f9ec31b5953de6735", + "signature": "eeb0d1ad28e70773ac57ae9fe939c3bad6af2525a463c28f9ec31b5953de6735", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/querystring.d.ts": { + "version": "8969e0b4d22ca77ad011c8fc4a25ec5d515bdfae4ecbd22608ed0d5c38829c1e", + "signature": "8969e0b4d22ca77ad011c8fc4a25ec5d515bdfae4ecbd22608ed0d5c38829c1e", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/readline.d.ts": { + "version": "81ef2751228318b1c7c6b35ccae2ea39ef275add30319e746bfd4658208a0519", + "signature": "81ef2751228318b1c7c6b35ccae2ea39ef275add30319e746bfd4658208a0519", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/repl.d.ts": { + "version": "d0b0b533dc34ff7ffd019665fdc2b2aeae717bc1347e17a5bdc4d6572b5c109a", + "signature": "d0b0b533dc34ff7ffd019665fdc2b2aeae717bc1347e17a5bdc4d6572b5c109a", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/stream.d.ts": { + "version": "d773accd5b85fb3127f212218d33a262aad2d118d18c7367b4dcf65482e13906", + "signature": "d773accd5b85fb3127f212218d33a262aad2d118d18c7367b4dcf65482e13906", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/string_decoder.d.ts": { + "version": "17e157df6125098a1a34eb4d201ee4ac03bbe97e471ab5627bb2c40fce555948", + "signature": "17e157df6125098a1a34eb4d201ee4ac03bbe97e471ab5627bb2c40fce555948", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/timers.d.ts": { + "version": "b40652bf8ce4a18133b31349086523b219724dca8df3448c1a0742528e7ad5b9", + "signature": "b40652bf8ce4a18133b31349086523b219724dca8df3448c1a0742528e7ad5b9", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/tls.d.ts": { + "version": "39dec06488aa1c05aa22bde1e2d96a3beda1ae565d7429bcc8053a26e83a6a56", + "signature": "39dec06488aa1c05aa22bde1e2d96a3beda1ae565d7429bcc8053a26e83a6a56", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/trace_events.d.ts": { + "version": "978aecd2e6bc2ac094e9a35eda98ff8586713857b3655e7c98ca5ed8f7d50662", + "signature": "978aecd2e6bc2ac094e9a35eda98ff8586713857b3655e7c98ca5ed8f7d50662", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/tty.d.ts": { + "version": "a185b8e0d7a4ae078a79339d63e98177813aac39256f69f788eaf5c360aa756f", + "signature": "a185b8e0d7a4ae078a79339d63e98177813aac39256f69f788eaf5c360aa756f", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/url.d.ts": { + "version": "fc8078ae641decbc5c0ddaa864fdb5c78194554568d334db769e80a4781a79b7", + "signature": "fc8078ae641decbc5c0ddaa864fdb5c78194554568d334db769e80a4781a79b7", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/util.d.ts": { + "version": "bfe1881838ba7c651b20165e17f942689dbe6e14b26d24268990e40aef68ce37", + "signature": "bfe1881838ba7c651b20165e17f942689dbe6e14b26d24268990e40aef68ce37", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/v8.d.ts": { + "version": "e880a08fbb0d9ee2f733f9183f4d1bdb75bc9e0e64060a8a1fc30540791fcded", + "signature": "e880a08fbb0d9ee2f733f9183f4d1bdb75bc9e0e64060a8a1fc30540791fcded", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/vm.d.ts": { + "version": "80a2bcde37ee49bbc4ddcc627710ea2f60321b24adbe949a585fc29586bcdcd3", + "signature": "80a2bcde37ee49bbc4ddcc627710ea2f60321b24adbe949a585fc29586bcdcd3", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/worker_threads.d.ts": { + "version": "e761c833140e3ab6f9deab37fe034154f3eb15547dce61395d9b0b1f130f3fa3", + "signature": "e761c833140e3ab6f9deab37fe034154f3eb15547dce61395d9b0b1f130f3fa3", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/zlib.d.ts": { + "version": "58257a0147702ab415ed18164557a0feb9c5d1351792ea293a876e6b7ed0c559", + "signature": "58257a0147702ab415ed18164557a0feb9c5d1351792ea293a876e6b7ed0c559", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/base.d.ts": { + "version": "2026b7041e063d40039177d4ee3f916b2ef69a6741a0ed092301dee65eea4149", + "signature": "2026b7041e063d40039177d4ee3f916b2ef69a6741a0ed092301dee65eea4149", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/ts3.2/util.d.ts": { + "version": "4f54f0a9dd3b644c99ec32b32f8804d5978bc854799b228ae9c467bf3c84c64c", + "signature": "4f54f0a9dd3b644c99ec32b32f8804d5978bc854799b228ae9c467bf3c84c64c", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/ts3.2/globals.d.ts": { + "version": "ce6b191c382ee19f23678b8c364484627bcf424e8f408357a2f5530fb8d52a45", + "signature": "ce6b191c382ee19f23678b8c364484627bcf424e8f408357a2f5530fb8d52a45", + "affectsGlobalScope": true + }, + "../node_modules/@types/node/ts3.2/base.d.ts": { + "version": "6f44b710b2fa277aab791d53f5b72991fbc1c93313bfc78e519764ac2a9b7f0f", + "signature": "6f44b710b2fa277aab791d53f5b72991fbc1c93313bfc78e519764ac2a9b7f0f", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/ts3.7/assert.d.ts": { + "version": "53729e4ea004f63dbe9e935dba015b6e20b3473d68757463949716bf5705bd89", + "signature": "53729e4ea004f63dbe9e935dba015b6e20b3473d68757463949716bf5705bd89", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/ts3.7/base.d.ts": { + "version": "b03474e5359472103e86fca6071bf55dc2a955119559a036bdca268c2a68c418", + "signature": "b03474e5359472103e86fca6071bf55dc2a955119559a036bdca268c2a68c418", + "affectsGlobalScope": false + }, + "../node_modules/@types/node/ts3.7/index.d.ts": { + "version": "d522314e80ed71b57e3c2939d3c9594eaae63a4adf028559e6574f6b270b0fee", + "signature": "d522314e80ed71b57e3c2939d3c9594eaae63a4adf028559e6574f6b270b0fee", + "affectsGlobalScope": false + } + }, + "options": { + "module": 1, + "target": 0, + "lib": [ + "lib.es5.d.ts", + "lib.es2015.d.ts" + ], + "declaration": true, + "outDir": "./", + "sourceMap": true, + "newLine": 1, + "noUnusedLocals": true, + "noUnusedParameters": true, + "incremental": true, + "strict": true, + "isolatedModules": true, + "configFilePath": "../tsconfig.json" + }, + "referencedMap": { + "../node_modules/@types/comment-json/index.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/async_hooks.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/base.d.ts": [ + "../node_modules/@types/node/async_hooks.d.ts", + "../node_modules/@types/node/buffer.d.ts", + "../node_modules/@types/node/child_process.d.ts", + "../node_modules/@types/node/cluster.d.ts", + "../node_modules/@types/node/console.d.ts", + "../node_modules/@types/node/constants.d.ts", + "../node_modules/@types/node/crypto.d.ts", + "../node_modules/@types/node/dgram.d.ts", + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/domain.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/fs.d.ts", + "../node_modules/@types/node/globals.d.ts", + "../node_modules/@types/node/http.d.ts", + "../node_modules/@types/node/http2.d.ts", + "../node_modules/@types/node/https.d.ts", + "../node_modules/@types/node/inspector.d.ts", + "../node_modules/@types/node/module.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/os.d.ts", + "../node_modules/@types/node/path.d.ts", + "../node_modules/@types/node/perf_hooks.d.ts", + "../node_modules/@types/node/process.d.ts", + "../node_modules/@types/node/punycode.d.ts", + "../node_modules/@types/node/querystring.d.ts", + "../node_modules/@types/node/readline.d.ts", + "../node_modules/@types/node/repl.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/string_decoder.d.ts", + "../node_modules/@types/node/timers.d.ts", + "../node_modules/@types/node/tls.d.ts", + "../node_modules/@types/node/trace_events.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/tty.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/@types/node/v8.d.ts", + "../node_modules/@types/node/vm.d.ts", + "../node_modules/@types/node/worker_threads.d.ts", + "../node_modules/@types/node/zlib.d.ts" + ], + "../node_modules/@types/node/buffer.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/child_process.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/cluster.d.ts": [ + "../node_modules/@types/node/child_process.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/console.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/constants.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/crypto.d.ts": [ + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/dgram.d.ts": [ + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/dns.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/domain.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/events.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/fs.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/globals.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/http.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/http2.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/fs.d.ts", + "../node_modules/@types/node/http.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/tls.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/https.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/http.d.ts", + "../node_modules/@types/node/tls.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/inspector.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/module.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/net.d.ts": [ + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/os.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/path.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/perf_hooks.d.ts": [ + "../node_modules/@types/node/async_hooks.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/process.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/punycode.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/querystring.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/readline.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/repl.d.ts": [ + "../node_modules/@types/node/readline.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/@types/node/vm.d.ts" + ], + "../node_modules/@types/node/stream.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/string_decoder.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/timers.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/tls.d.ts": [ + "../node_modules/@types/node/crypto.d.ts", + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/trace_events.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.2/base.d.ts": [ + "../node_modules/@types/node/base.d.ts", + "../node_modules/@types/node/ts3.2/globals.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.2/globals.d.ts": [ + "../node_modules/@types/node/globals.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.2/util.d.ts": [ + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.7/assert.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.7/base.d.ts": [ + "../node_modules/@types/node/ts3.2/base.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/ts3.7/assert.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.7/index.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/ts3.7/base.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/tty.d.ts": [ + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/url.d.ts": [ + "../node_modules/@types/node/querystring.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/util.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts" + ], + "../node_modules/@types/node/v8.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/vm.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/worker_threads.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/zlib.d.ts": [ + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/minimal-polyfills/WeakMap.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/ts-evt/dist/lib/Evt.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/EvtBase.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts" + ], + "../node_modules/ts-evt/dist/lib/EvtBase.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/EvtBaseProtected.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts" + ], + "../node_modules/ts-evt/dist/lib/EvtBaseProtected.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts" + ], + "../node_modules/ts-evt/dist/lib/Observable.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/Evt.d.ts" + ], + "../node_modules/ts-evt/dist/lib/defs.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/ts-evt/dist/lib/index.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/Evt.d.ts", + "../node_modules/ts-evt/dist/lib/Observable.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts" + ], + "../node_modules/ts-evt/node_modules/minimal-polyfills/dist/lib/Array.prototype.find.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.collection.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.core.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.generator.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.iterable.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.promise.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.proxy.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.reflect.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.symbol.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2016.array.include.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2016.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.intl.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.object.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.string.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.intl.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.promise.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.regexp.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2020.bigint.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es5.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.esnext.intl.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../src/lib/runExclusive.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/minimal-polyfills/WeakMap.d.ts" + ], + "../src/test/index.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../src/test/legacyTests/index.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../src/test/legacyTests/test1.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test10.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test11.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test12.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/index.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test13.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test14.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test15.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test16.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/index.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test17.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/index.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test18.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/index.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test19.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test2.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test20.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test21.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test3.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test4.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test5.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test6.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test7.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test8.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/legacyTests/test9.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/mod.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/test/test1.ts", + "../src/test/test10.ts", + "../src/test/test11.ts", + "../src/test/test13.ts", + "../src/test/test14.ts", + "../src/test/test15.ts", + "../src/test/test16.ts", + "../src/test/test17.ts", + "../src/test/test18.ts", + "../src/test/test2.ts", + "../src/test/test3.ts", + "../src/test/test4.ts", + "../src/test/test5.ts", + "../src/test/test6.ts", + "../src/test/test7.ts", + "../src/test/test8.ts", + "../src/test/test9.ts" + ], + "../src/test/test1.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test10.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test11.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test12.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/index.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test13.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test14.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test15.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test16.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test17.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test18.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test2.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test3.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test4.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test5.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test6.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test7.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test8.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/test9.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/testMem1.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ], + "../src/test/testMem2.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../src/lib/runExclusive.ts" + ] + }, + "exportedModulesMap": { + "../node_modules/@types/comment-json/index.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/async_hooks.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/base.d.ts": [ + "../node_modules/@types/node/async_hooks.d.ts", + "../node_modules/@types/node/buffer.d.ts", + "../node_modules/@types/node/child_process.d.ts", + "../node_modules/@types/node/cluster.d.ts", + "../node_modules/@types/node/console.d.ts", + "../node_modules/@types/node/constants.d.ts", + "../node_modules/@types/node/crypto.d.ts", + "../node_modules/@types/node/dgram.d.ts", + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/domain.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/fs.d.ts", + "../node_modules/@types/node/globals.d.ts", + "../node_modules/@types/node/http.d.ts", + "../node_modules/@types/node/http2.d.ts", + "../node_modules/@types/node/https.d.ts", + "../node_modules/@types/node/inspector.d.ts", + "../node_modules/@types/node/module.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/os.d.ts", + "../node_modules/@types/node/path.d.ts", + "../node_modules/@types/node/perf_hooks.d.ts", + "../node_modules/@types/node/process.d.ts", + "../node_modules/@types/node/punycode.d.ts", + "../node_modules/@types/node/querystring.d.ts", + "../node_modules/@types/node/readline.d.ts", + "../node_modules/@types/node/repl.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/string_decoder.d.ts", + "../node_modules/@types/node/timers.d.ts", + "../node_modules/@types/node/tls.d.ts", + "../node_modules/@types/node/trace_events.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/tty.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/@types/node/v8.d.ts", + "../node_modules/@types/node/vm.d.ts", + "../node_modules/@types/node/worker_threads.d.ts", + "../node_modules/@types/node/zlib.d.ts" + ], + "../node_modules/@types/node/buffer.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/child_process.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/cluster.d.ts": [ + "../node_modules/@types/node/child_process.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/console.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/constants.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/crypto.d.ts": [ + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/dgram.d.ts": [ + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/dns.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/domain.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/events.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/fs.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/globals.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/http.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/http2.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/fs.d.ts", + "../node_modules/@types/node/http.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/tls.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/https.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/http.d.ts", + "../node_modules/@types/node/tls.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/inspector.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/module.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/net.d.ts": [ + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/os.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/path.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/perf_hooks.d.ts": [ + "../node_modules/@types/node/async_hooks.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/process.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/punycode.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/querystring.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/readline.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/repl.d.ts": [ + "../node_modules/@types/node/readline.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/@types/node/vm.d.ts" + ], + "../node_modules/@types/node/stream.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/string_decoder.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/timers.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/tls.d.ts": [ + "../node_modules/@types/node/crypto.d.ts", + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/trace_events.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.2/base.d.ts": [ + "../node_modules/@types/node/base.d.ts", + "../node_modules/@types/node/ts3.2/globals.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.2/globals.d.ts": [ + "../node_modules/@types/node/globals.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.2/util.d.ts": [ + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.7/assert.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.7/base.d.ts": [ + "../node_modules/@types/node/ts3.2/base.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/ts3.7/assert.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/ts3.7/index.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/ts3.7/base.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/tty.d.ts": [ + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/url.d.ts": [ + "../node_modules/@types/node/querystring.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/util.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts" + ], + "../node_modules/@types/node/v8.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/vm.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/worker_threads.d.ts": [ + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/@types/node/zlib.d.ts": [ + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/minimal-polyfills/WeakMap.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/ts-evt/dist/lib/Evt.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/EvtBase.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts" + ], + "../node_modules/ts-evt/dist/lib/EvtBase.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/EvtBaseProtected.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts" + ], + "../node_modules/ts-evt/dist/lib/EvtBaseProtected.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts" + ], + "../node_modules/ts-evt/dist/lib/Observable.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/Evt.d.ts" + ], + "../node_modules/ts-evt/dist/lib/defs.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/ts-evt/dist/lib/index.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/ts-evt/dist/lib/Evt.d.ts", + "../node_modules/ts-evt/dist/lib/Observable.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts" + ], + "../node_modules/ts-evt/node_modules/minimal-polyfills/dist/lib/Array.prototype.find.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.collection.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.core.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.generator.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.iterable.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.promise.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.proxy.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.reflect.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.symbol.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2016.array.include.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2016.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.intl.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.object.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.string.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.intl.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.promise.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2018.regexp.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es2020.bigint.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.es5.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../node_modules/typescript/lib/lib.esnext.intl.d.ts": [ + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/util.d.ts" + ], + "../src/test/legacyTests/test12.ts": [ + "../node_modules/ts-evt/dist/lib/index.d.ts" + ], + "../src/test/legacyTests/test16.ts": [ + "../node_modules/ts-evt/dist/lib/index.d.ts" + ], + "../src/test/legacyTests/test17.ts": [ + "../node_modules/ts-evt/dist/lib/index.d.ts" + ], + "../src/test/legacyTests/test18.ts": [ + "../node_modules/ts-evt/dist/lib/index.d.ts" + ], + "../src/test/mod.ts": [ + "../src/test/test1.ts", + "../src/test/test10.ts", + "../src/test/test11.ts", + "../src/test/test13.ts", + "../src/test/test14.ts", + "../src/test/test15.ts", + "../src/test/test16.ts", + "../src/test/test17.ts", + "../src/test/test18.ts", + "../src/test/test2.ts", + "../src/test/test3.ts", + "../src/test/test4.ts", + "../src/test/test5.ts", + "../src/test/test6.ts", + "../src/test/test7.ts", + "../src/test/test8.ts", + "../src/test/test9.ts" + ], + "../src/test/test12.ts": [ + "../node_modules/ts-evt/dist/lib/index.d.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../node_modules/@types/comment-json/index.d.ts", + "../node_modules/@types/node/async_hooks.d.ts", + "../node_modules/@types/node/base.d.ts", + "../node_modules/@types/node/buffer.d.ts", + "../node_modules/@types/node/child_process.d.ts", + "../node_modules/@types/node/cluster.d.ts", + "../node_modules/@types/node/console.d.ts", + "../node_modules/@types/node/constants.d.ts", + "../node_modules/@types/node/crypto.d.ts", + "../node_modules/@types/node/dgram.d.ts", + "../node_modules/@types/node/dns.d.ts", + "../node_modules/@types/node/domain.d.ts", + "../node_modules/@types/node/events.d.ts", + "../node_modules/@types/node/fs.d.ts", + "../node_modules/@types/node/globals.d.ts", + "../node_modules/@types/node/http.d.ts", + "../node_modules/@types/node/http2.d.ts", + "../node_modules/@types/node/https.d.ts", + "../node_modules/@types/node/inspector.d.ts", + "../node_modules/@types/node/module.d.ts", + "../node_modules/@types/node/net.d.ts", + "../node_modules/@types/node/os.d.ts", + "../node_modules/@types/node/path.d.ts", + "../node_modules/@types/node/perf_hooks.d.ts", + "../node_modules/@types/node/process.d.ts", + "../node_modules/@types/node/punycode.d.ts", + "../node_modules/@types/node/querystring.d.ts", + "../node_modules/@types/node/readline.d.ts", + "../node_modules/@types/node/repl.d.ts", + "../node_modules/@types/node/stream.d.ts", + "../node_modules/@types/node/string_decoder.d.ts", + "../node_modules/@types/node/timers.d.ts", + "../node_modules/@types/node/tls.d.ts", + "../node_modules/@types/node/trace_events.d.ts", + "../node_modules/@types/node/ts3.2/base.d.ts", + "../node_modules/@types/node/ts3.2/globals.d.ts", + "../node_modules/@types/node/ts3.2/util.d.ts", + "../node_modules/@types/node/ts3.7/assert.d.ts", + "../node_modules/@types/node/ts3.7/base.d.ts", + "../node_modules/@types/node/ts3.7/index.d.ts", + "../node_modules/@types/node/tty.d.ts", + "../node_modules/@types/node/url.d.ts", + "../node_modules/@types/node/util.d.ts", + "../node_modules/@types/node/v8.d.ts", + "../node_modules/@types/node/vm.d.ts", + "../node_modules/@types/node/worker_threads.d.ts", + "../node_modules/@types/node/zlib.d.ts", + "../node_modules/minimal-polyfills/WeakMap.d.ts", + "../node_modules/ts-evt/dist/lib/Evt.d.ts", + "../node_modules/ts-evt/dist/lib/EvtBase.d.ts", + "../node_modules/ts-evt/dist/lib/EvtBaseProtected.d.ts", + "../node_modules/ts-evt/dist/lib/Observable.d.ts", + "../node_modules/ts-evt/dist/lib/defs.d.ts", + "../node_modules/ts-evt/dist/lib/index.d.ts", + "../node_modules/ts-evt/node_modules/minimal-polyfills/dist/lib/Array.prototype.find.d.ts", + "../node_modules/typescript/lib/lib.es2015.collection.d.ts", + "../node_modules/typescript/lib/lib.es2015.core.d.ts", + "../node_modules/typescript/lib/lib.es2015.d.ts", + "../node_modules/typescript/lib/lib.es2015.generator.d.ts", + "../node_modules/typescript/lib/lib.es2015.iterable.d.ts", + "../node_modules/typescript/lib/lib.es2015.promise.d.ts", + "../node_modules/typescript/lib/lib.es2015.proxy.d.ts", + "../node_modules/typescript/lib/lib.es2015.reflect.d.ts", + "../node_modules/typescript/lib/lib.es2015.symbol.d.ts", + "../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts", + "../node_modules/typescript/lib/lib.es2016.array.include.d.ts", + "../node_modules/typescript/lib/lib.es2016.d.ts", + "../node_modules/typescript/lib/lib.es2017.d.ts", + "../node_modules/typescript/lib/lib.es2017.intl.d.ts", + "../node_modules/typescript/lib/lib.es2017.object.d.ts", + "../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts", + "../node_modules/typescript/lib/lib.es2017.string.d.ts", + "../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts", + "../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts", + "../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts", + "../node_modules/typescript/lib/lib.es2018.d.ts", + "../node_modules/typescript/lib/lib.es2018.intl.d.ts", + "../node_modules/typescript/lib/lib.es2018.promise.d.ts", + "../node_modules/typescript/lib/lib.es2018.regexp.d.ts", + "../node_modules/typescript/lib/lib.es2020.bigint.d.ts", + "../node_modules/typescript/lib/lib.es5.d.ts", + "../node_modules/typescript/lib/lib.esnext.intl.d.ts", + "../src/lib/runExclusive.ts", + "../src/test/index.ts", + "../src/test/legacyTests/index.ts", + "../src/test/legacyTests/test1.ts", + "../src/test/legacyTests/test10.ts", + "../src/test/legacyTests/test11.ts", + "../src/test/legacyTests/test12.ts", + "../src/test/legacyTests/test13.ts", + "../src/test/legacyTests/test14.ts", + "../src/test/legacyTests/test15.ts", + "../src/test/legacyTests/test16.ts", + "../src/test/legacyTests/test17.ts", + "../src/test/legacyTests/test18.ts", + "../src/test/legacyTests/test19.ts", + "../src/test/legacyTests/test2.ts", + "../src/test/legacyTests/test20.ts", + "../src/test/legacyTests/test21.ts", + "../src/test/legacyTests/test3.ts", + "../src/test/legacyTests/test4.ts", + "../src/test/legacyTests/test5.ts", + "../src/test/legacyTests/test6.ts", + "../src/test/legacyTests/test7.ts", + "../src/test/legacyTests/test8.ts", + "../src/test/legacyTests/test9.ts", + "../src/test/mod.ts", + "../src/test/test1.ts", + "../src/test/test10.ts", + "../src/test/test11.ts", + "../src/test/test12.ts", + "../src/test/test13.ts", + "../src/test/test14.ts", + "../src/test/test15.ts", + "../src/test/test16.ts", + "../src/test/test17.ts", + "../src/test/test18.ts", + "../src/test/test2.ts", + "../src/test/test3.ts", + "../src/test/test4.ts", + "../src/test/test5.ts", + "../src/test/test6.ts", + "../src/test/test7.ts", + "../src/test/test8.ts", + "../src/test/test9.ts", + "../src/test/testMem1.ts", + "../src/test/testMem2.ts" + ] + }, + "version": "3.9.7" +} \ No newline at end of file