diff --git a/src/cjs.ts b/src/cjs.ts deleted file mode 100644 index 3b65531..0000000 --- a/src/cjs.ts +++ /dev/null @@ -1,5 +0,0 @@ -// old common js export (see index.ts for module exports) - -import { Pulse } from './pulse'; -module.exports = Pulse; -module.exports.Pulse = Pulse; diff --git a/src/job/run.ts b/src/job/run.ts index 7e1a301..9fa9cb6 100644 --- a/src/job/run.ts +++ b/src/job/run.ts @@ -14,8 +14,6 @@ export const run: RunMethod = async function (this: Job) { const { pulse } = this; const definition = pulse._definitions[this.attrs.name]; - // @TODO: this lint issue should be looked into: https://eslint.org/docs/rules/no-async-promise-executor - // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve, reject) => { this.attrs.lastRunAt = new Date(); this.attrs.runCount = (this.attrs.runCount || 0) + 1; diff --git a/src/pulse/database.ts b/src/pulse/database.ts index 6b7d93b..65fb678 100644 --- a/src/pulse/database.ts +++ b/src/pulse/database.ts @@ -42,7 +42,7 @@ export const database: DatabaseMethod = async function (this: Pulse, url, collec if (cb) { cb(error, null); } else { - throw error; + throw new BaseError(error); } }); diff --git a/src/pulse/define.ts b/src/pulse/define.ts index 9fe4f09..f5ad31d 100644 --- a/src/pulse/define.ts +++ b/src/pulse/define.ts @@ -88,17 +88,17 @@ export type DefineMethod = ( export const define: DefineMethod = function (this: Pulse, name, processor, options?) { this._definitions[name] = { fn: processor, - concurrency: (options as DefineOptions)?.concurrency || this._defaultConcurrency, - lockLimit: (options as DefineOptions)?.lockLimit || this._defaultLockLimit, - priority: (options as DefineOptions)?.priority || JobPriority.normal, - lockLifetime: (options as DefineOptions)?.lockLifetime || this._defaultLockLifetime, + concurrency: options?.concurrency || this._defaultConcurrency, + lockLimit: options?.lockLimit || this._defaultLockLimit, + priority: options?.priority || JobPriority.normal, + lockLifetime: options?.lockLifetime || this._defaultLockLifetime, running: 0, locked: 0, - shouldSaveResult: (options as DefineOptions)?.shouldSaveResult || false, - attempts: (options as DefineOptions)?.attempts || 0, - backoff: (options as DefineOptions)?.attempts && { - type: (options as DefineOptions)?.backoff?.type || 'exponential', - delay: (options as DefineOptions)?.backoff?.delay || 1000, + shouldSaveResult: options?.shouldSaveResult || false, + attempts: options?.attempts || 0, + backoff: options?.attempts && { + type: options?.backoff?.type || 'exponential', + delay: options?.backoff?.delay || 1000, }, };