From 9fbf2bbcd8b64789e3004a83e569a9fb4c0170aa Mon Sep 17 00:00:00 2001 From: Rand Scullard Date: Tue, 8 Nov 2016 08:35:23 -0500 Subject: [PATCH] node-schedule: Add support for object literal syntax. (#12445) --- node-schedule/index.d.ts | 79 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 5 deletions(-) diff --git a/node-schedule/index.d.ts b/node-schedule/index.d.ts index b4cf431e64..d21f46715d 100644 --- a/node-schedule/index.d.ts +++ b/node-schedule/index.d.ts @@ -214,6 +214,67 @@ export class RecurrenceRule { nextInvocationDate(base:Date):Date; } +/** + * Recurrence rule specification. + */ +export interface RecurrenceSpec { + /** + * 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. * @@ -266,11 +327,19 @@ export class Invocation { /** * Create a schedule job. * - * @param {string|RecurrenceRule|Date} name either an optional name for the new Job or scheduling information - * @param {RecurrenceRule|Date|string} rule either the scheduling info or the JobCallback - * @param {JobCallback} callback The callback to be executed on each invocation. + * @param {string} name name for the new Job + * @param {RecurrenceRule|RecurrenceSpec|Date|string} rule scheduling info + * @param {JobCallback} callback callback to be executed on each invocation */ - export function scheduleJob(name:string|RecurrenceRule|Date, rule: RecurrenceRule|Date|string|JobCallback, callback?: JobCallback): Job; + export function scheduleJob(name: string, rule: RecurrenceRule | RecurrenceSpec | Date | string, callback: JobCallback): Job; + +/** + * Create a schedule job. + * + * @param {RecurrenceRule|RecurrenceSpec|Date|string} rule scheduling info + * @param {JobCallback} callback callback to be executed on each invocation + */ + export function scheduleJob(rule: RecurrenceRule | RecurrenceSpec | Date | string, callback: JobCallback): Job; /** * Changes the timing of a Job, canceling all pending invocations. @@ -279,7 +348,7 @@ export class Invocation { * @param spec {JobCallback} the new timing for this Job * @return {Job} if the job could be rescheduled, {null} otherwise. */ - export function rescheduleJob(job:Job|string, spec:RecurrenceRule|Date|string):Job; + export function rescheduleJob(job: Job | string, spec: RecurrenceRule | RecurrenceSpec | Date | string): Job; /** * Dictionary of all Jobs, accessible by name.