SGrondin / bottleneck

Job scheduler and rate limiter, supports Clustering
MIT License
1.83k stars 79 forks source link

Typescript Bottleneck.Status definition should be a `const enum` #171

Open TjlHope opened 4 years ago

TjlHope commented 4 years ago

It's defined as

        enum Status {
            RECEIVED = "RECEIVED",
            QUEUED = "QUEUED",
            RUNNING = "RUNNING",
            EXECUTING = "EXECUTING",
            DONE = "DONE"
        }

But as there's no real matching typescript style enum in the generated js code, which means something like the following doesn't work:

if (limiter.jobStatus("id") === Bottleneck.Status.DONE)

The definition should use const enum so typescript converts it at compile time, rather than attempting to use a non-existent runtime js object.

I'm happy to open a trivial PR, but wasn't sure if you'd want a test case or similar. Thanks, Tom