cron-schedule
Advanced tools
Comparing version 3.0.6 to 4.0.0-next.1
@@ -1,3 +0,3 @@ | ||
import { Cron } from './cron'; | ||
import { Cron } from './cron.js'; | ||
/** Parses a cron expression into a Cron instance. */ | ||
export declare function parseCronExpression(cronExpression: string): Cron; |
@@ -1,5 +0,2 @@ | ||
export * from './schedulers/interval-based'; | ||
export * from './schedulers/timer-based'; | ||
export * from './cron-parser'; | ||
export * from './cron'; | ||
export * from './utils'; | ||
export * from './cron-parser.js'; | ||
export * from './cron.js'; |
@@ -1,2 +0,2 @@ | ||
import type { Cron } from '../cron'; | ||
import type { Cron } from '../cron.js'; | ||
/** | ||
@@ -3,0 +3,0 @@ * A cron scheduler that is based on a single interval. |
@@ -1,3 +0,3 @@ | ||
import type { Cron } from '../cron'; | ||
import { ITimerHandle } from '../utils'; | ||
import type { Cron } from '../cron.js'; | ||
import { ITimerHandle } from '../utils.js'; | ||
/** | ||
@@ -4,0 +4,0 @@ * A cron scheduler that is based on timers. |
102
package.json
{ | ||
"name": "cron-schedule", | ||
"description": "A zero-dependency cron parser and scheduler for Node.js, Deno and the browser.", | ||
"version": "3.0.6", | ||
"version": "4.0.0-next.1", | ||
"license": "MIT", | ||
@@ -29,15 +29,33 @@ "repository": { | ||
], | ||
"main": "dist/cron-schedule.cjs.min.js", | ||
"module": "dist/cron-schedule.min.mjs", | ||
"unpkg": "dist/cron-schedule.iife.min.js", | ||
"type": "module", | ||
"packageManager": "yarn@3.2.0", | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"files": [ | ||
"dist/**/*.js", | ||
"dist/**/*.js.map", | ||
"dist/**/*.d.ts" | ||
], | ||
"exports": { | ||
"require": "./dist/cron-schedule.cjs.min.js", | ||
"import": "./dist/cron-schedule.min.mjs" | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./schedulers/interval-based.js": { | ||
"type": "./dist/schedulerrs/interval-based.d.ts", | ||
"default": "./dist/schedulers/interval-based.js" | ||
}, | ||
"./schedulers/timer-based.js": { | ||
"type": "./dist/schedulers/timer-based.d.ts", | ||
"default": "./dist/schedulers/timer-based.js" | ||
} | ||
}, | ||
"sideEffects": false, | ||
"release": { | ||
"branches": [ | ||
"master", | ||
"main", | ||
{ | ||
"name": "next", | ||
"prelease": true | ||
"prerelease": true | ||
} | ||
@@ -62,58 +80,28 @@ ], | ||
}, | ||
"files": [ | ||
"dist/**/*.js", | ||
"dist/**/*.js.map", | ||
"dist/**/*.mjs", | ||
"dist/**/*.mjs.map", | ||
"dist/**/*.d.ts" | ||
], | ||
"types": "./dist/index.d.ts", | ||
"sideEffects": false, | ||
"scripts": { | ||
"build": "rimraf ./dist && tsc -p ./tsconfig.json --emitDeclarationOnly && node build.js", | ||
"build": "rimraf ./dist && tsc -p ./tsconfig.json", | ||
"tsc:check": "tsc --project ./tsconfig.json --noEmit", | ||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", | ||
"lint:fix": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\"", | ||
"test": "jest -c jest.config.js", | ||
"test:watch": "jest -c jest.config.js --watchAll", | ||
"prepack": "yarn build", | ||
"_postinstall": "husky install", | ||
"prepublishOnly": "pinst --disable", | ||
"postpublish": "pinst --enable" | ||
"test": "vitest", | ||
"test:run": "vitest run", | ||
"prepack": "yarn build" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "16.2.3", | ||
"@commitlint/config-conventional": "16.2.1", | ||
"@commitlint/prompt-cli": "16.2.3", | ||
"@semantic-release/changelog": "6.0.1", | ||
"@semantic-release/changelog": "6.0.3", | ||
"@semantic-release/git": "10.0.1", | ||
"@types/jest": "27.4.1", | ||
"@typescript-eslint/eslint-plugin": "5.21.0", | ||
"@typescript-eslint/parser": "5.21.0", | ||
"@typescript-eslint/typescript-estree": "5.21.0", | ||
"esbuild": "0.14.38", | ||
"eslint": "8.14.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"eslint-plugin-prettier": "4.0.0", | ||
"eslint-plugin-security": "1.5.0", | ||
"husky": "7.0.4", | ||
"jest": "27.5.1", | ||
"pinst": "3.0.0", | ||
"prettier": "2.6.2", | ||
"rimraf": "3.0.2", | ||
"semantic-release": "19.0.2", | ||
"ts-jest": "27.1.4", | ||
"tslib": "2.4.0", | ||
"typescript": "4.6.3" | ||
}, | ||
"resolutions": { | ||
"npm/chalk": "4.1.2" | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"packageManager": "yarn@3.2.0" | ||
"@typescript-eslint/eslint-plugin": "5.57.0", | ||
"@typescript-eslint/parser": "5.57.0", | ||
"@typescript-eslint/typescript-estree": "5.57.0", | ||
"eslint": "8.37.0", | ||
"eslint-config-prettier": "8.8.0", | ||
"eslint-plugin-import": "2.27.5", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"eslint-plugin-security": "1.7.1", | ||
"prettier": "2.8.7", | ||
"rimraf": "4.4.1", | ||
"semantic-release": "21.0.0", | ||
"typescript": "5.0.2", | ||
"vitest": "0.29.8" | ||
} | ||
} |
@@ -14,7 +14,7 @@ # cron-schedule ![CircleCI](https://circleci.com/gh/P4sca1/cron-schedule.svg?style=svg) | ||
* Schedule a function call based on a cron expression. | ||
* Supports Node.js, Deno and the browser (IIFE or ESM, ES6 required) | ||
* Supports Node.js, Deno and the browser (ESM only) | ||
* [Lightweight](https://bundlephobia.com/result?p=cron-schedule@latest) and tree-shakeable. | ||
## Installation and usage | ||
### Node.js (CommonJS) | ||
### Node.js | ||
Via npm: | ||
@@ -28,3 +28,3 @@ | ||
**We test our code against the following Node.js releases (`12.18`, `14.13`, `16.12`).** | ||
**We test our code against the following Node.js releases (`16.19`, `18.15`).** | ||
Other versions of node.js may also work, but this is not tested. | ||
@@ -40,22 +40,4 @@ | ||
## Browser (IIFE) | ||
### Browser via CDN | ||
```html | ||
<script src="https://unpkg.com/cron-schedule@:version"></script> | ||
``` | ||
After the script has been loaded, you can use the global `cronSchedule` object to access the API. | ||
##### Usage | ||
```html | ||
<script> | ||
const cron = cronSchedule.parseCronExpression('*/5 * * * *') | ||
console.log(cron.getNextDate(new Date(2020, 10, 20, 18, 32))) | ||
// 2020-11-20T17:35:00.000Z | ||
</script> | ||
``` | ||
**Requires ES6 (ES2015) browser support. Internet Explorer is not supported.** If you need to support older browsers, get _cron-schedule_ via npm or yarn and transpile it with your bundler. | ||
### Browser (ECMAScript module) | ||
```html | ||
<script type="module"> | ||
@@ -71,3 +53,3 @@ import { parseCronExpression } from 'https://cdn.skypack.dev/cron-schedule@:version' | ||
```ts | ||
import { parseCronExpression } from 'https://cdn.skypack.dev/cron-schedule@:version?dts' | ||
import { parseCronExpression } from 'npm:cron-schedule@:version' | ||
// TypeScript types are automatically shipped with the X-TypeScript-Types http header. | ||
@@ -80,5 +62,5 @@ const cron = parseCronExpression('*/5 * * * *') | ||
### Note on CDN usage | ||
The examples above use [unpkg](http://unpkg.com) for IIFE and [Skypack](https://www.skypack.dev) for ESM. | ||
The examples above use [Skypack](https://www.skypack.dev). | ||
The urls contain `:version` placeholder. Replace `:version` with the desired version. Semver ranges are supported. To always use the latest `2.x` version use `^2.0.0`. | ||
The urls contain `:version` placeholder. Replace `:version` with the desired version. Semver ranges are supported. To always use the latest `4.x` version use `^4.0.0`. | ||
See https://www.npmjs.com/package/cron-schedule for a list of available versions. | ||
@@ -88,3 +70,3 @@ | ||
```ts | ||
// Import method to parse a cron expression. In the browser with IIFE: cronSchedule.parseCronExpression | ||
// Import method to parse a cron expression. | ||
import { parseCronExpression } from 'cron-schedule' | ||
@@ -129,4 +111,4 @@ | ||
```ts | ||
// Import the scheduler. In the browser with IIFE: cronSchedule.TimerBasedCronScheduler | ||
import { TimerBasedCronScheduler as scheduler } from 'cron-schedule' | ||
// Import the scheduler. | ||
import { TimerBasedCronScheduler as scheduler } from 'cron-schedule/schedulers/timer-based.js' | ||
@@ -159,4 +141,4 @@ // Create a timeout, which fill fire the task on the next cron date. | ||
```ts | ||
// Import the scheduler. In the browser with IIFE: cronSchedule.IntervalBasedCronScheduler | ||
import { IntervalBasedCronScheduler } from 'cron-schedule' | ||
// Import the scheduler. | ||
import { IntervalBasedCronScheduler } from 'cron-schedule/schedulers/interval-based.js' | ||
@@ -163,0 +145,0 @@ // Instantiate a new instance of the scheduler with the given interval. In this example, the scheduler would check every 60 seconds. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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 v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15
21
892
Yes
80021
2
196
1