From cc3e6151688db11bf2a784f6d522d84ab6d62ac9 Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Tue, 15 Oct 2019 16:58:57 -0400 Subject: [PATCH] p-fifo: initial definition (#39095) --- types/p-fifo/index.d.ts | 14 ++++++++++++++ types/p-fifo/p-fifo-tests.ts | 17 +++++++++++++++++ types/p-fifo/tsconfig.json | 23 +++++++++++++++++++++++ types/p-fifo/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 types/p-fifo/index.d.ts create mode 100644 types/p-fifo/p-fifo-tests.ts create mode 100644 types/p-fifo/tsconfig.json create mode 100644 types/p-fifo/tslint.json diff --git a/types/p-fifo/index.d.ts b/types/p-fifo/index.d.ts new file mode 100644 index 0000000000..3344efe225 --- /dev/null +++ b/types/p-fifo/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for p-fifo 1.0 +// Project: https://github.com/alanshaw/p-fifo +// Definitions by: Junxiao Shi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export = PFifo; + +declare class PFifo { + constructor(); + push(chunk: T): Promise; + shift(): Promise; + isEmpty(): boolean; +} diff --git a/types/p-fifo/p-fifo-tests.ts b/types/p-fifo/p-fifo-tests.ts new file mode 100644 index 0000000000..9769280db4 --- /dev/null +++ b/types/p-fifo/p-fifo-tests.ts @@ -0,0 +1,17 @@ +import Fifo = require("p-fifo"); + +const fifo = new Fifo(); + +(async () => { + // $ExpectType void + await fifo.push("a"); + + // $ExpectError + fifo.push(true); + + // $ExpectType string + await fifo.shift(); +})(); + +// $ExpectType boolean +fifo.isEmpty(); diff --git a/types/p-fifo/tsconfig.json b/types/p-fifo/tsconfig.json new file mode 100644 index 0000000000..f2e88f4ae1 --- /dev/null +++ b/types/p-fifo/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", + "p-fifo-tests.ts" + ] +} diff --git a/types/p-fifo/tslint.json b/types/p-fifo/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/p-fifo/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }