p-fifo: initial definition (#39095)

This commit is contained in:
Junxiao Shi
2019-10-15 13:58:57 -07:00
committed by Andrew Branch
parent 39224d9428
commit cc3e615168
4 changed files with 55 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for p-fifo 1.0
// Project: https://github.com/alanshaw/p-fifo
// Definitions by: Junxiao Shi <https://github.com/yoursunny>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export = PFifo;
declare class PFifo<T> {
constructor();
push(chunk: T): Promise<void>;
shift(): Promise<T>;
isEmpty(): boolean;
}
+17
View File
@@ -0,0 +1,17 @@
import Fifo = require("p-fifo");
const fifo = new Fifo<string>();
(async () => {
// $ExpectType void
await fifo.push("a");
// $ExpectError
fifo.push(true);
// $ExpectType string
await fifo.shift();
})();
// $ExpectType boolean
fifo.isEmpty();
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }