add @types/node-cron (#23062)

* add node-cron

* Update tslint.json

Remove lint rule
This commit is contained in:
maximelkin 2018-01-23 21:43:37 +03:00 committed by Andy
parent c6a22f77ba
commit f69b0ea7b6
4 changed files with 90 additions and 0 deletions

15
types/node-cron/index.d.ts vendored Normal file
View 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;
}

View 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');
}

View 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"
]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}