Socket
Socket
Sign inDemoInstall

uuid-cron

Package Overview
Dependencies
55
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.3 to 1.2.0

5

dist/index.d.ts
import { NumOfRandomsInTime } from './types';
export declare function init(humanCron: string, numOfRandomsInTime?: NumOfRandomsInTime): void;
export declare function uuidv4Cron(): Error;
export declare function uuidv4CronLimited(): string | Error;
export declare function getCronUUID(): string | Error;
export declare function stop(): void;
export declare function uuidv4Random(): any;
export declare function getUUID(): any;

26

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uuidv4Random = exports.stop = exports.uuidv4CronLimited = exports.uuidv4Cron = exports.init = void 0;
exports.getUUID = exports.stop = exports.getCronUUID = exports.init = void 0;
const tslib_1 = require("tslib");

@@ -22,2 +22,3 @@ const uuid_1 = require("uuid");

initialized = true;
initializedLimited = false;
job = new cron_1.CronJob(cronTime, () => {

@@ -29,2 +30,3 @@ uuidv4Value = (0, uuid_1.v4)();

initializedLimited = true;
initialized = false;
globalNumberOfUUIDS = numOfRandomsInTime;

@@ -39,16 +41,12 @@ randomUsers = (0, random_1.getRandomUUIDS)(numOfRandomsInTime);

exports.init = init;
function uuidv4Cron() {
if (!initialized) {
return (0, errorHandler_1.initError)();
function getCronUUID() {
if (initializedLimited) {
return randomUsers[Math.floor(Math.random() * globalNumberOfUUIDS)];
}
return uuidv4Value;
}
exports.uuidv4Cron = uuidv4Cron;
function uuidv4CronLimited() {
if (!initializedLimited) {
return (0, errorHandler_1.initError)();
if (initialized) {
return uuidv4Value;
}
return randomUsers[Math.floor(Math.random() * globalNumberOfUUIDS)];
return (0, errorHandler_1.initError)();
}
exports.uuidv4CronLimited = uuidv4CronLimited;
exports.getCronUUID = getCronUUID;
function stop() {

@@ -58,6 +56,6 @@ job.stop();

exports.stop = stop;
function uuidv4Random() {
function getUUID() {
return (0, uuid_1.v4)();
}
exports.uuidv4Random = uuidv4Random;
exports.getUUID = getUUID;
//# sourceMappingURL=index.js.map
{
"name": "uuid-cron",
"version": "1.1.3",
"version": "1.2.0",
"description": "uuid-cron",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -12,3 +12,3 @@ # uuid-cron

```typescript
import { init, uuidv4CronLimited, stop } from 'uuid-cron';
import { init, getCronUUID, stop } from 'uuid-cron';
// for the first param, read cron syntax here: https://www.npmjs.com/package/human-to-cron

@@ -18,5 +18,5 @@ init('each 20 seconds');

**3. uuidv4Cron() will return random uuid every 20 seconds**
**3. getCronUUID() will return random uuid every 20 seconds**
```typescript
const randomUUID = uuidv4Cron();
const randomUUID = getCronUUID();
```

@@ -30,9 +30,9 @@

### Limit the number of random uuids
use uuidv4CronLimited to control the number of uuids generated in each cron job
use getCronUUID to control the number of uuids generated in each cron job
```typescript
init('each 20 seconds', 30);
// each 20 second generate 30 random uuids and return one of them each time
const limitedRandomUUIDS = uuidv4CronLimited();
const limitedRandomUUIDS = getCronUUID();
```

@@ -1,2 +0,2 @@

import { init, uuidv4CronLimited, uuidv4Cron, stop } from '../src';
import { init, getCronUUID, stop } from '../src';
let uuidOriginal;

@@ -11,5 +11,5 @@ let uuidTarget;

init('each 2 seconds');
uuidOriginal = uuidv4Cron();
uuidOriginal = getCronUUID();
for (let i = 0 ; i < 30; i ++){
uuidTarget = uuidv4Cron()
uuidTarget = getCronUUID()
expect(uuidOriginal).toEqual(uuidTarget);

@@ -20,5 +20,5 @@ }

init('each 2 seconds', 1);
uuidOriginal = uuidv4CronLimited();
uuidOriginal = getCronUUID();
for (let i = 0 ; i < 30; i ++){
uuidTarget = uuidv4CronLimited()
uuidTarget = getCronUUID()
expect(uuidOriginal).toEqual(uuidTarget);

@@ -25,0 +25,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc