From 09e9fdbdc5b65fd68701b46944c08a7ac657f524 Mon Sep 17 00:00:00 2001 From: Vicary A Date: Tue, 7 Feb 2023 18:10:44 +0800 Subject: [PATCH] chore: typing --- Executable.ts | 2 +- ExecutableWorker.ts | 2 +- Task.ts | 2 +- Workerpool.test.ts | 2 +- Workerpool.ts | 10 +++-- deno.json | 3 +- deno.lock | 104 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 deno.lock diff --git a/Executable.ts b/Executable.ts index 40db3ba..7bf4827 100644 --- a/Executable.ts +++ b/Executable.ts @@ -1,4 +1,4 @@ -import { Promisable } from "type-fest"; +import type { Promisable } from "type-fest"; /** * The Runner interface. diff --git a/ExecutableWorker.ts b/ExecutableWorker.ts index 09c574f..4d0191e 100644 --- a/ExecutableWorker.ts +++ b/ExecutableWorker.ts @@ -1,5 +1,5 @@ import { releaseProxy, Remote, UnproxyOrClone, wrap } from "comlink"; -import { Promisable } from "type-fest"; +import type { Promisable } from "type-fest"; import type { Executable } from "./Executable.ts"; /** diff --git a/Task.ts b/Task.ts index a409455..d5408f8 100644 --- a/Task.ts +++ b/Task.ts @@ -1,4 +1,4 @@ -import { JsonValue } from "type-fest"; +import type { JsonValue } from "type-fest"; export interface Task { /** diff --git a/Workerpool.test.ts b/Workerpool.test.ts index 5c92a6a..c87dda2 100644 --- a/Workerpool.test.ts +++ b/Workerpool.test.ts @@ -5,7 +5,7 @@ import { assertSpyCalls, spy, } from "https://deno.land/std@0.155.0/testing/mock.ts"; -import { Class, SetOptional } from "type-fest"; +import type { Class, SetOptional } from "type-fest"; import { Executable } from "./Executable.ts"; import { ExecutableWorker } from "./ExecutableWorker.ts"; import { Task } from "./Task.ts"; diff --git a/Workerpool.ts b/Workerpool.ts index 9dce154..ea1bcca 100644 --- a/Workerpool.ts +++ b/Workerpool.ts @@ -1,4 +1,4 @@ -import { Class, JsonValue, Promisable, SetOptional } from "type-fest"; +import type { Class, JsonValue, Promisable, SetOptional } from "type-fest"; import { Executable } from "./Executable.ts"; import { Runner, RunnerExecutionError } from "./Runner.ts"; import { Task } from "./Task.ts"; @@ -68,13 +68,15 @@ export type WorkerpoolOptions = { /** * Called when the state of the pool is changed. - * 1. **active:** Workerpool becomes active via .start() or .enqueue(). - * 2. **draining:** Workerpool is paused via .pause(). - * 3. **drained:** All active runners are disposed via task exhaustion or pausing. */ onStateChange?: (state: WorkerpoolState) => Promisable; }; +/** + * 1. **running:** Workerpool becomes active via .start() or .enqueue(). + * 2. **draining:** Workerpool is paused via .pause(). + * 3. **drained:** All active runners are disposed via task exhaustion or pausing. + */ export type WorkerpoolState = "running" | "draining" | "drained"; export class Workerpool { diff --git a/deno.json b/deno.json index 8e84fd3..a6a4d9b 100644 --- a/deno.json +++ b/deno.json @@ -1,7 +1,6 @@ { - "importMap": "./deno.json", "imports": { "comlink": "https://deno.land/x/comlink@4.3.1/mod.ts", - "type-fest": "https://deno.land/x/fest@v3.5.6/mod.ts" + "type-fest": "https://deno.land/x/fest@v3.5.7-alpha.2/mod.ts" } } diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..bdccdc3 --- /dev/null +++ b/deno.lock @@ -0,0 +1,104 @@ +{ + "version": "2", + "remote": { + "https://deno.land/std@0.155.0/fmt/colors.ts": "ff7dc9c9f33a72bd48bc24b21bbc1b4545d8494a431f17894dbc5fe92a938fc4", + "https://deno.land/std@0.155.0/testing/_diff.ts": "a23e7fc2b4d8daa3e158fa06856bedf5334ce2a2831e8bf9e509717f455adb2c", + "https://deno.land/std@0.155.0/testing/_format.ts": "cd11136e1797791045e639e9f0f4640d5b4166148796cad37e6ef75f7d7f3832", + "https://deno.land/std@0.155.0/testing/_test_suite.ts": "2d07073d5460a4e3ec50c55ae822cd9bd136926d7363091379947fef9c73c3e4", + "https://deno.land/std@0.155.0/testing/asserts.ts": "ac295f7fd22a7af107580e2475402a8c386cb1bf18bf837ae266ac0665786026", + "https://deno.land/std@0.155.0/testing/bdd.ts": "35060cefd9cc21b414f4d89453b3551a3d52ec50aeff25db432503c5485b2f72", + "https://deno.land/std@0.155.0/testing/mock.ts": "d7ad40139cda87476c4dc1efeffe406bbfb4a5f82b688e0b85bffe9e911526a2", + "https://deno.land/x/comlink@4.3.1/mod.ts": "50467f0d8eeb5afdb7ec54979fb4e0ba5665f2a964eb7b5cb7efe8ad9e0d0016", + "https://deno.land/x/comlink@4.3.1/src/comlink.ts": "447a5ad4cd1b484d09b4466abeaad6cba79890f088b0214ff1c4240ec8a48cd1", + "https://deno.land/x/comlink@4.3.1/src/protocol.ts": "d9f94213ff5b11d9670b823dc4f1b9ff00ff7fafe98749a522db5f605c6abd37", + "https://deno.land/x/fest@v3.5.7-alpha.2/index.d.ts": "843edafa5cc3c2f1b05be8b10ea073abe407395caa632a904cf65b5af7da955e", + "https://deno.land/x/fest@v3.5.7-alpha.2/mod.ts": "8dd20290582d5ba500ceb3e91f1cc69dcc23e096445a4db8c7ae85520cca82f1", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/async-return-type.d.ts": "2d3f23c577a913d0f396184f31998507e18c8712bc74303a433cf47f94fd7e07", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/asyncify.d.ts": "9790af9ac67eef3260f889ef3ecf0f4d98d6880d7150e787ca370f5b2285de06", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/basic.d.ts": "aa5fc23c017f724ef2ccf527d44ff131ac94c6e4625a8b158819aafb9fd8fd91", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/camel-case.d.ts": "abd36b105fa5228f11f190a17f8633f10a37d716dab1ec6759af343d837d8784", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/camel-cased-properties-deep.d.ts": "41df7a8304d8af7b8550f8d9efef6bc425eb129db1bfb7acd9e5016207753175", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/camel-cased-properties.d.ts": "a11b82b728e22212ef30e3adf89d5058da87cc5ae1fb55276540776a1ebd0b08", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/conditional-except.d.ts": "810f05718567dff185381bd64ea24431f4444b83fe1f75148cefcffd956d9c3f", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/conditional-keys.d.ts": "4d397c276bd0d41f8a5a0d67a674d5cf3f79b79b0f4df13a0fbefdf0e88f0519", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/conditional-pick-deep.d.ts": "4e30cb77bf52c6bc4a5669c181fdfc93afeaf457ce78abfd64036e899158e2f1", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/conditional-pick.d.ts": "786cc3fb03891009cb44365b9bea84ab4fca67c7edcf4e3dead1e7477fdbccd4", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/conditional-simplify.d.ts": "ef4c9ef3ec432ccbf6508f8aa12fbb8b7f4d535c8b484258a3888476de2c6c36", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/delimiter-case.d.ts": "f7836012ce61e04ac36e3becb930c8a1f098158dc14663aa9019a6bca7d28297", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/delimiter-cased-properties-deep.d.ts": "3fa379b4dc1495a49a2e890c5f66e7ae6c24f4aa0d85ef61e030c1a7764624ac", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/delimiter-cased-properties.d.ts": "53a483a4e7507732e62946eb38c5dc760b6c05433aad78b991bbb7a8d95ad33b", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/empty-object.d.ts": "86b484bcf6344a27a9ee19dd5cef1a5afbbd96aeb07708cc6d8b43d7dfa8466c", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/enforce-optional.d.ts": "c31a7bdae416090c583cf9e8712b303b1cb160421b8c796571dade824a1d6bc5", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/entries.d.ts": "5d4bcc970e12968c4c2cae9ceed1aa4bd95c56f5b6762bc5451f7469a9e1cffd", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/entry.d.ts": "37569cc8f21262ca62ec9d3aa8eb5740f96e1f325fad3d6aa00a19403bd27b96", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/exact.d.ts": "7f77f38e8ba3b6e5c60cacdc2bc2e8ea1d95d5b7e550e3643cc8a61de105ea18", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/except.d.ts": "d35052020ae726b093e9e06fd72252e1c2b66ae4dd0e3ead1bcffd1dac553ee9", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/fixed-length-array.d.ts": "31073e7d0e51f33b1456ff2ab7f06546c95e24e11c29d5b39a634bc51f86d914", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/get.d.ts": "f583279c37a704488715f471b46e4dfc12c1abe6afb5490420389456b145301e", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/global-this.d.ts": "9e5c7463fc0259a38938c9afbdeda92e802cff87560277fd3e385ad24663f214", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/has-optional-keys.d.ts": "3f3cf725b6433be4973f5c416bd5c0f4806d80143ef2ad7f1e5989d4ad1e079f", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/has-required-keys.d.ts": "57ec00a8b4656cd36eaeec2279708530d9e490d37664b6ba4cbb64df81999f56", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/includes.d.ts": "f7e96ea986e74dec1ac7b33a1a9ee0860c1c09a872d7f44678f00afae8ff5b3d", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/internal.d.ts": "6bb78abacc8c3fe29782d75b21e24d5aa2d8154146c6a5089341b0a764a85fda", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/invariant-of.d.ts": "e6c834f373990e5de61a78744152f2b7a599ee967cf04e84322a3e8ff027123a", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/is-equal.d.ts": "7873594f89f40867f1c033609db4052bb2e03a5d128f9b12c8ca657f83d293e4", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/iterable-element.d.ts": "a90339d50728b60f761127fe75192e632aa07055712a377acd8d20bb5d61e80c", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/join.d.ts": "d3752f9a8387c9c6938e7f68aba40fd8f9ade46bd50001e3c4f12b4abae0b6b4", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/jsonifiable.d.ts": "a561e5b8280b01e76df08f0c1481418722e57ed231535cd90fa3eb579bbbaf71", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/jsonify.d.ts": "1ce1f47d8a6d879a46450a261f2fe213de47ed0a00f7a8f85a3c82773075a8ed", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/kebab-case.d.ts": "8334c9afec985ebeea30b1dfdf16b6181d898fef65308f26bb09abad3dbb559b", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/kebab-cased-properties-deep.d.ts": "f003c0c24c53d6ff6787cb4bd1b09e0b8f88978c042100012423f94ffc6dbecb", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/kebab-cased-properties.d.ts": "715753f0b9386fd0bccf157a4c61e976b9b165c84c4ef647807f53bf82c2170d", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/last-array-element.d.ts": "08f95bee0619072d2c49854434af3e53d94e7e762fc082b49cea59e77db06905", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/literal-to-primitive.d.ts": "e79e530a8216ee171b4aca8fc7b99bd37f5e84555cba57dc3de4cd57580ff21a", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/literal-union.d.ts": "64d88b9816de9df025d191ad9bb578fe7f44ce17daba66f7062b0c92e855b186", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/merge-deep.d.ts": "fbbf209d52076b5d13d80a2bc01e392aed7e6e3a75c6493bf79fc625a4b25efb", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/merge-exclusive.d.ts": "f981ffdbd651f67db134479a5352dac96648ca195f981284e79dc0a1dbc53fd5", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/merge.d.ts": "d1702e7926335b7eb9b349a1f1f56e994a770dd6c7fa5781389e328b7efd4798", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/multidimensional-array.d.ts": "560712389c8fbfd649582cd8a44f5afea36303f1a168355163020da034f5c917", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/multidimensional-readonly-array.d.ts": "477f63faa5b69b491d797ad0a323d141c624ab76ef1c3a70449f4a7f7f457a9b", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/numeric.d.ts": "4f0781ec008bb24dc1923285d25d648ea48fb5a3c36d0786e2ee82eb00eff426", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/observable-like.d.ts": "4f24c2781b21b6cd65eede543669327d68a8cf0c6d9cf106a1146b164a7c8ef9", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/omit-index-signature.d.ts": "4502caaa3fff6c9766bfc145b1b586ef26d53e5f104271db046122b8eef57fd1", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/opaque.d.ts": "de2b56099545de410af72a7e430ead88894e43e4f959de29663d4d0ba464944d", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/optional-keys-of.d.ts": "1edc9192dfc277c60b92525cdfa1980e1bfd161ae77286c96777d10db36be73c", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/package-json.d.ts": "c418460b75552482e2a80251d243d08c7256db23175319b79896fc934eb41d4e", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/partial-deep.d.ts": "a7988f0df03cce36dc48ceb2537df3d095c8009a5c8317617ebde7d51c9328f1", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/partial-on-undefined-deep.d.ts": "6197f5d101e429be38ddc3bcb92b49e210bf5848b1cc337405b8d024ccdabf5b", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/pascal-case.d.ts": "3166b2a8fe882b930ee588d1d5b3af96e4eb8745dedbe8bd19025403c3329001", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/pascal-cased-properties-deep.d.ts": "dac9fc2ea5e45520b8b5f535d91b25291f48fd7c82a1fc8761e15ab3ee92e049", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/pascal-cased-properties.d.ts": "264e911099e2b1fa781035564337f9505be9b94ed66e6ec2a2e239de744cfe20", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/pick-index-signature.d.ts": "382f061a24f63ef8bfb1f7a748e1a2568ea62fb91ed1328901a6cf5ad129d61c", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/primitive.d.ts": "cd51ceafea7762ad639afb3ca5b68e1e4ffeaacaa402d7ef2cae17016e29e098", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/promisable.d.ts": "03ed68319c97cd4ce8f1c4ded110d9b40b8a283c3242b9fe934ccfa834e45572", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/readonly-deep.d.ts": "a1dcb07dcfc34b8a115bd91fe074584b69d841b3e98eadd10c02f1624fa834af", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/readonly-tuple.d.ts": "4ce53edb8fb1d2f8b2f6814084b773cdf5846f49bf5a426fbe4029327bda95bf", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/replace.d.ts": "0e0b8353d6d7f7cc3344adbabf3866e64f2f2813b23477254ba51f69e8fdf0eb", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/require-all-or-none.d.ts": "a24c4fe21d5b13a9ecbbb39b5e22f5d4c6fe5feebb074865ba2de273381a73ae", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/require-at-least-one.d.ts": "09587c0c4f8f4c24928f2c2908ac87879f7b09918b55fa0412e1093519bd795a", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/require-exactly-one.d.ts": "a1c85a61ff2b66291676ab84ae03c1b1ff7139ffde1942173f6aee8dc4ee357b", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/required-keys-of.d.ts": "75a7db3b7ddf0ca49651629bb665e0294fda8d19ba04fddc8a14d32bb35eb248", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/schema.d.ts": "abf140fdc3db44c2cac9415426544d8c2a89e73f13f7838376b2b6d36d74a582", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/screaming-snake-case.d.ts": "a81d647c291d9dd5a07f0300f538e415917c52577c6845221479eccac36319e9", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/set-non-nullable.d.ts": "1f0ee5ddb64540632c6f9a5b63e242b06e49dd6472f3f5bd7dfeb96d12543e15", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/set-optional.d.ts": "86471bdc467d40d83c18fc892c5073a59dd79b0436c96086f1d4885235391498", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/set-required.d.ts": "dff33e8c84be9c908bc1eb01c14dbb08b0166a1ffeefe4a352f8a189258ba89f", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/set-return-type.d.ts": "f8793ffae29c85e6fc17959f46c836cac5f4dcdfc278e5bcd97c85b8241fbae2", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/simplify.d.ts": "884eaf5bcae2539fd5e7219561315c02e6d5cb452df236b7d6a08e961ec11dad", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/snake-case.d.ts": "661a7dd92e7b7bd7fdd61b04180843e7498c82fae185119e359eb0671be56e94", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/snake-cased-properties-deep.d.ts": "7afbe2d420ff075602c3f715a6508e446bec49991b8e3f8dc527442ef3f8ccc8", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/snake-cased-properties.d.ts": "b21d736541d8fb5a4040e13709c8b1ff69dfd44d3df288f5a22331f0e1833c86", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/split-words.d.ts": "6f288f16b6c62f97c6d082818d6104bd57c7fde018df89a63bdaf307ed4f12b5", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/split.d.ts": "5a4d0b09de173c391d5d50064fc20166becc194248b1ce738e8a56af5196d28c", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/spread.d.ts": "47ca9fd4df908e0badfe1044b2912e2d823da1f8c17e434ced6d8fec1f16aa52", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/string-key-of.d.ts": "f351eaa598ba2046e3078e5480a7533be7051e4db9212bb40f4eeb84279aa24d", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/stringified.d.ts": "1848ebe5252ccb5ca1ca4ff52114516bdbbc7512589d6d0839beeea768bfb400", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/trim.d.ts": "a17e4cf0a5e2065005af78c2ee7829c6022ff84b84907f88fe7edd8af676ae81", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/tsconfig-json.d.ts": "288f78bb86d191e35b95b60396ba413f13768968c98e1904723b912348274f5a", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/tuple-to-union.d.ts": "1502a23e43fd7e9976a83195dc4eaf54acaff044687e0988a3bd4f19fc26b02b", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/typed-array.d.ts": "1b8357b3fef5be61b5de6d6a4805a534d68fe3e040c11f1944e27d4aec85936a", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/union-to-intersection.d.ts": "0b9bcc98884f81d8adda2c5d2ebb0361c7a53af6713e72138c4457e6016ff708", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/value-of.d.ts": "c3ee10cd9e7c623d10541162b3c2b40f3f0a313402b6b8a98a3fccf05195a1f7", + "https://deno.land/x/fest@v3.5.7-alpha.2/source/writable.d.ts": "0d1232b5a9247077f47b6ea6a6bf64236cb5182f4c081ea8a176d3fcaf03cffc" + } +}