UNPKG

agenda

Version:

Light weight job scheduler for Node.js

27 lines (22 loc) 557 B
'use strict'; /** * Given a job, turn it into an object we can store in Mongo * @returns {Object} json object from Job */ module.exports = function() { const self = this; const attrs = self.attrs || {}; const result = {}; for (const prop in attrs) { if ({}.hasOwnProperty.call(attrs, prop)) { result[prop] = attrs[prop]; } } const dates = ['lastRunAt', 'lastFinishedAt', 'nextRunAt', 'failedAt', 'lockedAt']; dates.forEach(d => { if (result[d]) { result[d] = new Date(result[d]); } }); return result; };