-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dependencies update. Adding EditorConfig file and code formatting.
- Loading branch information
1 parent
42a4f5a
commit b4d4455
Showing
6 changed files
with
2,123 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.{js,txt,md,css,html,php,py,json,yml,sass,pug}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.{diff,md}] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,88 @@ | ||
const cron = require('cron').CronJob; | ||
const Cron = require('cron').CronJob; | ||
|
||
/** | ||
* BaseCron class for cron jobs. | ||
* | ||
* @class BaseCron | ||
*/ | ||
class BaseCron { | ||
|
||
/** | ||
* Creates an instance of BaseCron. | ||
* | ||
* @param {string} cronName | ||
* @param {string} cronTime | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
constructor(cronName, cronTime) { | ||
if (!cronName) { | ||
throw new Error('ERR_INVALID_ARG_VALUE'); | ||
} | ||
|
||
this._cronName = cronName; | ||
this._cronTime = cronTime; | ||
this._cronJob = new cron(this._cronTime, this.onTick.bind(this), this.onComplete.bind(this)); | ||
/** | ||
* Creates an instance of BaseCron. | ||
* | ||
* @param {string} cronName | ||
* @param {string} cronTime | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
constructor (cronName, cronTime) { | ||
if (!cronName) { | ||
throw new Error('ERR_INVALID_ARG_VALUE'); | ||
} | ||
|
||
/** | ||
* Starts the cron job. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
start() { | ||
this._cronJob.start(); | ||
} | ||
this._cronName = cronName; | ||
this._cronTime = cronTime; | ||
this._cronJob = new Cron(this._cronTime, this.onTick.bind(this), this.onComplete.bind(this)); | ||
} | ||
|
||
/** | ||
* Stops the cron job. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
stop() { | ||
this._cronJob.stop(); | ||
} | ||
/** | ||
* Starts the cron job. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
start () { | ||
this._cronJob.start(); | ||
} | ||
|
||
/** | ||
* Function onTick for the current cron job. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
async onTick() { | ||
throw new Error('ERR_METHOD_NOT_IMPLEMENTED'); | ||
} | ||
/** | ||
* Stops the cron job. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
stop () { | ||
this._cronJob.stop(); | ||
} | ||
|
||
/** | ||
* Function onComplete for the current cron job. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
async onComplete() { | ||
throw new Error('ERR_METHOD_NOT_IMPLEMENTED'); | ||
} | ||
/** | ||
* Function onTick for the current cron job. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
async onTick () { | ||
throw new Error('ERR_METHOD_NOT_IMPLEMENTED'); | ||
} | ||
|
||
/** | ||
* Returns an instance of cron npm module. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
getCronInstance() { | ||
return this._cronJob; | ||
} | ||
/** | ||
* Function onComplete for the current cron job. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
async onComplete () { | ||
throw new Error('ERR_METHOD_NOT_IMPLEMENTED'); | ||
} | ||
|
||
/** | ||
* Check if current cron job is running. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
isCronRunning() { | ||
return this._cronJob.running; | ||
} | ||
/** | ||
* Returns an instance of cron npm module. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
getCronInstance () { | ||
return this._cronJob; | ||
} | ||
|
||
}; | ||
/** | ||
* Check if current cron job is running. | ||
* | ||
* @public | ||
* @memberof BaseCron | ||
*/ | ||
isCronRunning () { | ||
return this._cronJob.running; | ||
} | ||
} | ||
|
||
module.exports = BaseCron; | ||
module.exports = BaseCron; |
Oops, something went wrong.