diff --git a/types/long-timeout/index.d.ts b/types/long-timeout/index.d.ts new file mode 100644 index 0000000000..ae82ec84f1 --- /dev/null +++ b/types/long-timeout/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for long-timeout 0.1 +// Project: https://github.com/tellnes/long-timeout +// Definitions by: Matthias Kunnen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export type Listener = (...args: any[]) => void; + +export class Timeout { + after: number; + close: () => void; + listener: Listener; + ref: () => void; + start: () => void; + unref: () => void; + unreffed: boolean; + + constructor(listener: Listener, ms: number); +} + +export type Interval = Timeout; + +export function clearInterval(timer: Interval): void; + +export function clearTimeout(timer: Timeout): void; + +export function setInterval(listener: Listener, ms: number): Interval; + +export function setTimeout(listener: Listener, ms: number): Timeout; diff --git a/types/long-timeout/long-timeout-tests.ts b/types/long-timeout/long-timeout-tests.ts new file mode 100644 index 0000000000..4395722f2d --- /dev/null +++ b/types/long-timeout/long-timeout-tests.ts @@ -0,0 +1,15 @@ +import * as lt from 'long-timeout'; + +const interval = lt.setInterval(() => { + // Do things +}, 4000); + +interval.close(); + +lt.clearInterval(interval); + +const timeout = lt.setTimeout(() => { + // Do things +}, 50); + +lt.clearTimeout(timeout); diff --git a/types/long-timeout/tsconfig.json b/types/long-timeout/tsconfig.json new file mode 100644 index 0000000000..8773438f14 --- /dev/null +++ b/types/long-timeout/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "long-timeout-tests.ts" + ] +} diff --git a/types/long-timeout/tslint.json b/types/long-timeout/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/long-timeout/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }