uuid-cron
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "uuid-cron", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -13,3 +13,7 @@ const { v4: uuidv4 } = require('uuid'); | ||
let initialized = false; | ||
let initializedLimited = false; | ||
/** | ||
@@ -20,8 +24,9 @@ * Starting cron job according your configuration | ||
* @param numOfRandomsInTime - amount of random uuids for each cron job | ||
* if null, it returns the same uuid during the cron | ||
*/ | ||
function init(humanCron, numOfRandomsInTime) { | ||
initialized = true; | ||
const cronTime = humanToCron(humanCron); | ||
uuidv4Value = uuidv4(); | ||
if (!numOfRandomsInTime) { | ||
if (!numOfRandomsInTime || typeof numOfRandomsInTime != 'number') { | ||
initialized = true; | ||
job = new CronJob(cronTime, (() => { | ||
@@ -31,2 +36,3 @@ uuidv4Value = uuidv4(); | ||
} else { | ||
initializedLimited= true; | ||
numOfRandomsInTimeP = numOfRandomsInTime; | ||
@@ -49,3 +55,3 @@ randomUsers = computeJobWithLimitedRandoms(cronTime, numOfRandomsInTime); | ||
function uuidv4CronLimited() { | ||
if (!initialized) { | ||
if (!initializedLimited) { | ||
return initError(); | ||
@@ -52,0 +58,0 @@ } |
4154
104