From 7457393b5bf27dbc9f385892136156500f9a07c4 Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 9 Dec 2020 19:34:04 +1300 Subject: [PATCH] Added jsdoc to bree job builder --- ghost/job-manager/lib/assemble-bree-job.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ghost/job-manager/lib/assemble-bree-job.js b/ghost/job-manager/lib/assemble-bree-job.js index 694b7acaeb..64792db5c1 100644 --- a/ghost/job-manager/lib/assemble-bree-job.js +++ b/ghost/job-manager/lib/assemble-bree-job.js @@ -1,6 +1,14 @@ const isCronExpression = require('./is-cron-expression'); -const assemble = (when, job, data, name) => { +/** + * Creates job Object compatible with bree job definition (https://github.com/breejs/bree#job-options) + * + * @param {String | Date} [at] - Date, cron or human readable schedule format + * @param {Function|String} job - function or path to a module defining a job + * @param {Object} [data] - data to be passed into the job + * @param {String} [name] - job name + */ +const assemble = (at, job, data, name) => { const breeJob = { name: name, // NOTE: both function and path syntaxes work with 'path' parameter @@ -15,17 +23,17 @@ const assemble = (when, job, data, name) => { }); } - if (when instanceof Date) { + if (at instanceof Date) { Object.assign(breeJob, { - date: when + date: at }); - } else if (when && isCronExpression(when)) { + } else if (at && isCronExpression(at)) { Object.assign(breeJob, { - cron: when + cron: at }); - } else if (when !== undefined) { + } else if (at !== undefined) { Object.assign(breeJob, { - interval: when + interval: at }); }