Comparing version
{ | ||
"name": "uuid-cron", | ||
"version": "1.0.6", | ||
"description": "", | ||
"main": "src/index.js", | ||
"version": "1.1.0", | ||
"description": "uuid-cron", | ||
"main": "index.js", | ||
"repository": { | ||
@@ -11,13 +11,18 @@ "type": "git", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"lint": "eslint . --ext .js", | ||
"lint-fix": "eslint . --ext .js --fix", | ||
"start": "./src/index.js" | ||
"start": "npm run build && npm run serve", | ||
"serve": "node dist/index.js", | ||
"clean": "rimraf coverage build tmp", | ||
"build": "tsc -p tsconfig.release.json", | ||
"build:watch": "tsc -w -p tsconfig.release.json", | ||
"lint": "eslint . --ext .ts,.tsx", | ||
"lint-fix": "eslint . --ext .ts,.tsx --fix", | ||
"test": "jest --coverage", | ||
"test:watch": "jest --watch" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"dependencies": { | ||
"cron": "1.8.2", | ||
"express": "^4.17.1", | ||
"express": "4.17.1", | ||
"human-to-cron": "0.3.1", | ||
@@ -27,6 +32,12 @@ "uuid": "8.3.2" | ||
"devDependencies": { | ||
"@types/jest": "^27.0.2", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"eslint": "^8.0.1", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.25.2" | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-jest": "^25.2.1", | ||
"jest": "^27.2.5", | ||
"ts-jest": "^27.0.7" | ||
} | ||
} |
# uuid-cron | ||
Generate random uuids in a given time | ||
# Quickstart | ||
# Getting Started | ||
@@ -13,13 +13,12 @@ **1. Install** | ||
const { init, uuidv4CronLimited, stop } = require('uuid-cron'); | ||
// run cron job every 20 seconds with 30 random uuids each time. | ||
// for the first param, read for more details: https://www.npmjs.com/package/human-to-cron | ||
init('each 20 seconds', 30); | ||
// for the first param, read cron syntax here: https://www.npmjs.com/package/human-to-cron | ||
init('each 20 seconds'); | ||
``` | ||
**3. Get random uuid according to the init params** | ||
**3. uuidv4Cron() will return random uuid every 20 seconds** | ||
```javascript | ||
const randomUUID = uuidv4CronLimited(); | ||
const randomUUID = uuidv4Cron(); | ||
``` | ||
**4. stop the cron job on finish** | ||
**4. On finish, stop the cron job, otherwise it will continue infinitely** | ||
```javascript | ||
@@ -29,1 +28,10 @@ stop(); | ||
### Limit the number of random uuids | ||
use uuidv4CronLimited to control the number of uuids generated in each cron job | ||
```javascript | ||
init('each 20 seconds', 30); | ||
// each 20 second generate 30 random uuids and return one of them each time | ||
const limitedRandomUUIDS = uuidv4CronLimited(); | ||
``` | ||
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
13930
235.34%16
100%214
105.77%1
-50%36
28.57%9
200%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated