From 2ee3f1ea551ba40c1a901ff98a17ae6ae9f2ea60 Mon Sep 17 00:00:00 2001 From: John Denver Date: Tue, 27 Sep 2022 14:18:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20circular=20and=20priority=20queue=20type?= =?UTF-8?q?s=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/interface.ts | 10 +++++++--- src/method/circular.ts | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/common/interface.ts b/src/common/interface.ts index 41f002f..3814261 100644 --- a/src/common/interface.ts +++ b/src/common/interface.ts @@ -19,13 +19,17 @@ export interface ConvertOptions { transformer?: Function; } -export class PriorityElement { +export interface PriorityElement { /** * Priority Indicates the weight of the queue. */ - public weight: number; + weight: number; /** * The actual content. */ - public value: T; + value: T; +} + +export interface CircularHandler { + close(): void; } diff --git a/src/method/circular.ts b/src/method/circular.ts index 29c71af..b461ece 100644 --- a/src/method/circular.ts +++ b/src/method/circular.ts @@ -1,3 +1,5 @@ +import { CircularHandler } from '../common'; + /** * Create a recurring scheduled task. * @@ -7,7 +9,7 @@ * * @publicApi */ -export function circular(callback: Function, interval: number, ...args: any[]) { +export function circular(callback: Function, interval: number, ...args: any[]): CircularHandler { let timer: NodeJS.Timeout = null; const close = () => {