mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add @types/node-cron (#23062)
* add node-cron * Update tslint.json Remove lint rule
This commit is contained in:
parent
c6a22f77ba
commit
f69b0ea7b6
15
types/node-cron/index.d.ts
vendored
Normal file
15
types/node-cron/index.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// Type definitions for node-cron 1.2
|
||||
// Project: http://merencia.com/node-cron/
|
||||
// Definitions by: morsic <https://github.com/maximelkin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// immediateStart - default true
|
||||
export function schedule(a: string, func: () => void, immediateStart?: boolean): ScheduledTask;
|
||||
|
||||
export function validate(a: string): boolean;
|
||||
|
||||
export interface ScheduledTask {
|
||||
start: () => this;
|
||||
stop: () => this;
|
||||
destroy: () => void;
|
||||
}
|
||||
47
types/node-cron/node-cron-tests.ts
Normal file
47
types/node-cron/node-cron-tests.ts
Normal file
@ -0,0 +1,47 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import cron = require('node-cron');
|
||||
|
||||
// tslint:disable-next-line no-console
|
||||
const log = console.log;
|
||||
|
||||
cron.schedule('* * * * *', () => {
|
||||
log('running a task every minute');
|
||||
});
|
||||
|
||||
cron.schedule('1-5 * * * *', () => {
|
||||
log('running every minute to 1 from 5');
|
||||
});
|
||||
|
||||
// tslint:disable-next-line rule
|
||||
const task = cron.schedule('* * * * *', () => {
|
||||
log('immediately started');
|
||||
// because of manual call start method
|
||||
}, false);
|
||||
|
||||
task.start();
|
||||
|
||||
const task1 = cron.schedule('* * * * *', () => {
|
||||
log('will execute every minute until stopped');
|
||||
});
|
||||
|
||||
task1.start();
|
||||
|
||||
const task2 = cron.schedule('* * * * *', () => {
|
||||
log('will execute every minute until stopped');
|
||||
});
|
||||
|
||||
task2.stop();
|
||||
|
||||
const task3 = cron.schedule('* * * * *', () => {
|
||||
log('will execute every minute until stopped');
|
||||
});
|
||||
|
||||
task3.destroy();
|
||||
|
||||
const valid = cron.validate('59 * * * *');
|
||||
const invalid = cron.validate('60 * * * *');
|
||||
|
||||
if (valid && !invalid) {
|
||||
log('validator works');
|
||||
}
|
||||
25
types/node-cron/tsconfig.json
Normal file
25
types/node-cron/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedLocals": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noUnusedParameters": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"node-cron-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/node-cron/tslint.json
Normal file
3
types/node-cron/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user