diff --git a/types/stream-throttle/index.d.ts b/types/stream-throttle/index.d.ts new file mode 100644 index 0000000000..30ba038907 --- /dev/null +++ b/types/stream-throttle/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for stream-throttle 0.1 +// Project: https://github.com/tjgq/node-stream-throttle +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Transform } from 'stream'; + +export interface ThrottleOptions { + readonly rate: number; + readonly chunksize?: number; +} + +export class Throttle extends Transform { + constructor(options: ThrottleOptions); +} + +export class ThrottleGroup { + constructor(options: ThrottleOptions); + throttle(options: ThrottleOptions): Throttle; +} diff --git a/types/stream-throttle/stream-throttle-tests.ts b/types/stream-throttle/stream-throttle-tests.ts new file mode 100644 index 0000000000..bbd8f8ce86 --- /dev/null +++ b/types/stream-throttle/stream-throttle-tests.ts @@ -0,0 +1,7 @@ +import { Throttle, ThrottleGroup } from 'stream-throttle'; + +const throttle = new Throttle({rate: 1}); +const throttleGroup = new ThrottleGroup({rate: 1}); + +// $ExpectType Throttle +throttleGroup.throttle({rate: 1}); diff --git a/types/stream-throttle/tsconfig.json b/types/stream-throttle/tsconfig.json new file mode 100644 index 0000000000..b9e4185c58 --- /dev/null +++ b/types/stream-throttle/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "stream-throttle-tests.ts" + ] +} diff --git a/types/stream-throttle/tslint.json b/types/stream-throttle/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/stream-throttle/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}