node-schedule: Fix lint (#20968)

This commit is contained in:
Andy 2017-10-24 11:38:46 -07:00 committed by Sheetal Nandi
parent 824ad1a710
commit 474cdb32e7

View File

@ -7,211 +7,119 @@
import { EventEmitter } from 'events';
/**
* The callback executed by a Job
*/
/** The callback executed by a Job */
export type JobCallback = () => void;
/**
* Scheduler jobs.
*
* @class
*/
/** Scheduler jobs. */
export class Job extends EventEmitter {
/**
* This Job's name. read-only.
*/
name: string;
readonly name: string;
/**
* Use the function scheduleJob() to create new Job objects.
*
* @constructor
* @internal
* @param {string|JobCallback} name either an optional name for this Job or this Job's callback
* @param {JobCallback|Function} job either this Job's callback or an optional callback function
* @param {Function} callback optional callback that is executed right before the JobCallback
* @param name either an optional name for this Job or this Job's callback
* @param job either this Job's callback or an optional callback function
* @param callback optional callback that is executed right before the JobCallback
*/
constructor(name: string|JobCallback, job?: JobCallback|(() => void), callback?: () => void);
constructor(name: string|JobCallback, job?: JobCallback|(() => void), callback?: () => void);
/**
* Adds an Invocation to this job. For internal use.
* @internal
* @param {Invocation} invocation
* @return {boolean} whether the invocation could be added
* @return whether the invocation could be added
*/
trackInvocation(invocation: Invocation): boolean;
trackInvocation(invocation: Invocation): boolean;
/**
* removes an Invocation from this Job's tracking list. For internal use.
* @internal
* @param {Invocation} invocation
* @return boolean whether the invocation was successful. Removing an Invocation that doesn't exist, returns false.
*/
stopTrackingInvocation(invocation: Invocation): boolean;
stopTrackingInvocation(invocation: Invocation): boolean;
/**
* @internal
* @return {number} the number of currently running instances of this Job.
* @return the number of currently running instances of this Job.
*/
triggeredJobs(): number;
triggeredJobs(): number;
/**
* set the number of currently running Jobs.
* @internal
* @param {number} triggeredJobs
*/
setTriggeredJobs(triggeredJobs: number): void;
setTriggeredJobs(triggeredJobs: number): void;
/**
* cancel all pending Invocations of this Job.
* @param {boolean} reschedule whether to reschedule the canceled Invocations.
* @param reschedule whether to reschedule the canceled Invocations.
*/
cancel(reschedule?: boolean): boolean;
cancel(reschedule?: boolean): boolean;
/**
* cancel the next Invocation of this Job.
* @param {boolean} reschedule whether to reschedule the canceled Invocation.
* @return {boolean} whether cancelation was successful
* @param reschedule whether to reschedule the canceled Invocation.
* @return whether cancelation was successful
*/
cancelNext(reschedule?: boolean): boolean;
cancelNext(reschedule?: boolean): boolean;
/**
* Changes the scheduling information for this Job.
* @param {RecurrenceRule|string|number} spec
* @return {boolean} whether the reschedule was successful
* @return whether the reschedule was successful
*/
reschedule(spec: RecurrenceRule|string|number): boolean;
reschedule(spec: RecurrenceRule|string|number): boolean;
/**
* Returns the Date on which this Job will be run next.
* @return {Date}
*/
nextInvocation(): Date;
/** The Date on which this Job will be run next. */
nextInvocation(): Date;
/**
* @return Invocation[] a list of all pending Invocations
*/
pendingInvocations(): Invocation[];
/** A list of all pending Invocations */
pendingInvocations(): Invocation[];
/**
* run this Job immediately.
*/
invoke(): void;
invoke(): void;
/**
* schedule this Job to be run on the specified date.
* @param date {Date}
*/
runOnDate(date: Date): void;
/** schedule this Job to be run on the specified date. */
runOnDate(date: Date): void;
/**
* set scheduling information
* @param {Date|string|number} date
* @public
*/
schedule(date: Date|string|number): boolean;
/** set scheduling information */
schedule(date: Date|string|number): boolean;
}
/**
* Range.
*
* @class
*/
export class Range {
/**
* Constructor.
*
* @constructor
* @param {number} start The start.
* @param {number} end The end.
* @param {number} step The step.
*/
constructor(start?: number, end?: number, step?: number);
/**
* Return a {boolean} if the class contains the specified value.
*
* @param {number} value The value.
* @returns {boolean} {true} if the class contains the specified value, otherwise, {false}.
*/
/** Whether the class contains the specified value. */
contains(value: number): boolean;
}
export type Recurrence = number | Range | string;
export type RecurrenceSegment = Recurrence | Recurrence[];
/**
* Recurrence rules.
*/
export class RecurrenceRule {
/**
* Day of the month.
*
* @public
* @type {RecurrenceSegment}
*/
date: RecurrenceSegment;
date: RecurrenceSegment;
dayOfWeek: RecurrenceSegment;
hour: RecurrenceSegment;
minute: RecurrenceSegment;
month: RecurrenceSegment;
second: RecurrenceSegment;
year: RecurrenceSegment;
/**
* Day of the week.
*
* @public
* @type {RecurrenceSegment}
*/
dayOfWeek: RecurrenceSegment;
constructor(
year?: RecurrenceSegment,
month?: RecurrenceSegment,
date?: RecurrenceSegment,
dayOfWeek?: RecurrenceSegment,
hour?: RecurrenceSegment,
minute?: RecurrenceSegment,
second?: RecurrenceSegment
);
/**
* Hour.
*
* @public
* @type {RecurrenceSegment}
*/
hour: RecurrenceSegment;
/**
* Minute.
*
* @public
* @type {RecurrenceSegment}
*/
minute: RecurrenceSegment;
/**
* Month.
*
* @public
* @type {RecurrenceSegment}
*/
month: RecurrenceSegment;
/**
* Second.
*
* @public
* @type {RecurrenceSegment}
*/
second: RecurrenceSegment;
/**
* Year.
*
* @public
* @type {RecurrenceSegment}
*/
year: RecurrenceSegment;
constructor(
year?: RecurrenceSegment,
month?: RecurrenceSegment,
date?: RecurrenceSegment,
dayOfWeek?: RecurrenceSegment,
hour?: RecurrenceSegment,
minute?: RecurrenceSegment,
second?: RecurrenceSegment
);
nextInvocationDate(base: Date): Date;
nextInvocationDate(base: Date): Date;
}
/**
@ -220,23 +128,14 @@ export class RecurrenceRule {
export interface RecurrenceSpecDateRange {
/**
* Starting date in date range.
*
* @public
* @type {Date|string|number}
*/
start: Date | string | number;
/**
* Ending date in date range.
*
* @public
* @type {Date|string|number}
*/
end: Date | string | number;
/**
* Cron expression string.
*
* @public
* @type {string}
*/
rule: string;
}
@ -247,145 +146,55 @@ export interface RecurrenceSpecDateRange {
export interface RecurrenceSpecObjLit {
/**
* Day of the month.
*
* @public
* @type {RecurrenceSegment}
*/
date?: RecurrenceSegment;
/**
* Day of the week.
*
* @public
* @type {RecurrenceSegment}
*/
dayOfWeek?: RecurrenceSegment;
/**
* Hour.
*
* @public
* @type {RecurrenceSegment}
*/
hour?: RecurrenceSegment;
/**
* Minute.
*
* @public
* @type {RecurrenceSegment}
*/
minute?: RecurrenceSegment;
/**
* Month.
*
* @public
* @type {RecurrenceSegment}
*/
month?: RecurrenceSegment;
/**
* Second.
*
* @public
* @type {RecurrenceSegment}
*/
second?: RecurrenceSegment;
/**
* Year.
*
* @public
* @type {RecurrenceSegment}
*/
year?: RecurrenceSegment;
}
/**
* Invocation.
*
* @class
*/
export class Invocation {
/**
* Fire date.
*
* @public
* @type {Date}
*/
fireDate: Date;
/**
* Job.
*
* @public
* @type {Job}
*/
job: Job;
/**
* Recurrence rule.
*
* @public
* @type {RecurrenceRule}
*/
recurrenceRule: RecurrenceRule;
/**
* Timer identifier.
*
* @public
* @type {number}
*/
timerID: number;
/**
* Constructor.
*
* @constructor
* @param {Job} job The job.
* @param {Date} fireDate The fire date.
* @param {RecurrenceRule} recurrenceRule The recurrence rule.
*/
constructor(job: Job, fireDate: Date, recurrenceRule: RecurrenceRule);
}
/**
* Create a schedule job.
*
* @param {string} name name for the new Job
* @param {RecurrenceRule|RecurrenceSpecDateRange|RecurrenceSpecObjLit|Date|string} rule scheduling info
* @param {JobCallback} callback callback to be executed on each invocation
* @param name name for the new Job
* @param rule scheduling info
* @param callback callback to be executed on each invocation
*/
export function scheduleJob(name: string, rule: RecurrenceRule | RecurrenceSpecDateRange | RecurrenceSpecObjLit | Date | string, callback: JobCallback): Job;
/**
* Create a schedule job.
*
* @param {RecurrenceRule|RecurrenceSpecDateRange|RecurrenceSpecObjLit|Date|string} rule scheduling info
* @param {JobCallback} callback callback to be executed on each invocation
* @param rule scheduling info
* @param callback callback to be executed on each invocation
*/
export function scheduleJob(rule: RecurrenceRule | RecurrenceSpecDateRange | RecurrenceSpecObjLit | Date | string, callback: JobCallback): Job;
/**
* Changes the timing of a Job, canceling all pending invocations.
*
* @param {Job|string} job
* @param {RecurrenceRule|RecurrenceSpecDateRange|RecurrenceSpecObjLit|Date|string} spec The new timing for this Job.
* @return {Job} if the job could be rescheduled, {null} otherwise.
* @param spec The new timing for this Job.
* @return if the job could be rescheduled, {null} otherwise.
*/
export function rescheduleJob(job: Job | string, spec: RecurrenceRule | RecurrenceSpecDateRange | RecurrenceSpecObjLit | Date | string): Job;
/**
* Dictionary of all Jobs, accessible by name.
*/
/** Dictionary of all Jobs, accessible by name. */
export let scheduledJobs: {[jobName: string]: Job};
/**
* Cancels the job.
*
* @param {Job} job The job.
* @returns {boolean} {true} if the job has been cancelled with success, otherwise, {false}.
* @returns Whether the job has been cancelled with success.
*/
export function cancelJob(job: Job|string): boolean;