mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-29 00:51:29 +08:00
24
types/deasync/deasync-tests.ts
Normal file
24
types/deasync/deasync-tests.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as deasync from "deasync";
|
||||
|
||||
function asyncFunction(input: number, cb: (res: number) => void) {}
|
||||
function handle(res: number) {}
|
||||
|
||||
// base case
|
||||
asyncFunction(42, handle);
|
||||
|
||||
// deasync
|
||||
let wrapped = deasync(asyncFunction);
|
||||
handle(wrapped(42));
|
||||
|
||||
// deasync.loopWhile
|
||||
let done = false;
|
||||
asyncFunction(42, () => {
|
||||
done = true;
|
||||
});
|
||||
deasync.loopWhile(() => !done);
|
||||
|
||||
// deasync.runLoopOnce
|
||||
deasync.runLoopOnce();
|
||||
|
||||
// deasync.sleep
|
||||
deasync.sleep(100);
|
||||
14
types/deasync/index.d.ts
vendored
Normal file
14
types/deasync/index.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Type definitions for deasync 0.1
|
||||
// Project: https://github.com/abbr/deasync
|
||||
// Definitions by: Matt Rollins <https://github.com/Sicilica>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export = deasync;
|
||||
|
||||
declare function deasync(fn: (...args: any[]) => void): (...args: any[]) => any;
|
||||
declare namespace deasync {
|
||||
function loopWhile(pred: () => boolean): void;
|
||||
function runLoopOnce(): void;
|
||||
function sleep(ms: number): void;
|
||||
}
|
||||
22
types/deasync/tsconfig.json
Normal file
22
types/deasync/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"deasync-tests.ts"
|
||||
]
|
||||
}
|
||||
4
types/deasync/tslint.json
Normal file
4
types/deasync/tslint.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {}
|
||||
}
|
||||
Reference in New Issue
Block a user