-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any TypeScript definitions for this? #3
Comments
Hm. I don’t see any. Do you? |
many times they are community provided, or stored in a separate module/repository. I would like to have some so maybe we can add a help wanted label and if anyone has created a few for use in their own projects they can link them here. |
Here is a start for the promise side: declare module 'concurrent-queue' {
interface LimitConfig {
concurrency?: number;
maxSize?: number;
softMaxSize?: number;
}
export default function cq(): cqImpl;
export interface cqImpl {
process(processor: (task: any) => Promise<any>): queue;
limit(limitConfig: LimitConfig): cqImpl;
}
export interface queue {
(item: any): Promise<any>;
}
} |
Thanks @VictorioBerra. If anyone else needs this, I got this down to: declare module 'concurrent-queue' {
interface LimitConfig {
concurrency?: number;
maxSize?: number;
softMaxSize?: number;
}
export default function cq(): Queue<any>;
export interface Queue<T> {
process<T>(processor: (task: any) => Promise<T>): Queue<T>;
limit(limitConfig: LimitConfig): Queue<T>;
(item: any): Promise<T>;
/** the number of queued items */
size: number;
pending: T[];
drained: (cb: () => void) => void;
processingEnded: (cb: () => void) => void;
}
} which better reflects the two fluent methods (it's just as valid to call |
@jasonpincin would you be interested in a PR to add these (to be completed) Typescript defs? |
@bentorkington Yes! Thank you! |
No description provided.
The text was updated successfully, but these errors were encountered: