mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Add typings for 'util.promisify' package
This commit is contained in:
36
types/util.promisify/index.d.ts
vendored
Normal file
36
types/util.promisify/index.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Type definitions for util.promisify 1.0
|
||||
// Project: https://github.com/ljharb/util.promisify#readme
|
||||
// Definitions by: Adam Voss <https://github.com/adamvoss>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/*~ Note that ES6 modules cannot directly export callable functions.
|
||||
*~ This file should be imported using the CommonJS-style:
|
||||
*~ import x = require('util.promisify');
|
||||
*~
|
||||
*~ Refer to the documentation to understand common
|
||||
*~ workarounds for this limitation of ES6 modules.
|
||||
*/
|
||||
export = promisify;
|
||||
|
||||
declare function promisify(f: (...args: any[]) => void): (...args: any[]) => Promise<any>;
|
||||
|
||||
declare namespace promisify {
|
||||
interface implementation {
|
||||
(fn: (...args: any[]) => void): (...args: any[]) => Promise<any>;
|
||||
custom: symbol;
|
||||
customPromisifyArgs: symbol | undefined;
|
||||
}
|
||||
|
||||
const custom: symbol;
|
||||
const customPromisifyArgs: symbol;
|
||||
function getPolyfill(): implementation;
|
||||
const implementation: implementation;
|
||||
function shim(): implementation;
|
||||
}
|
||||
|
||||
declare module "util" {
|
||||
let promisify: {
|
||||
(fn: (...args: any[]) => void): (...args: any[]) => Promise<any>;
|
||||
custom: symbol;
|
||||
};
|
||||
}
|
||||
22
types/util.promisify/tsconfig.json
Normal file
22
types/util.promisify/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",
|
||||
"util.promisify-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/util.promisify/tslint.json
Normal file
1
types/util.promisify/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
11
types/util.promisify/util.promisify-tests.ts
Normal file
11
types/util.promisify/util.promisify-tests.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/// <reference types="node/v0" />
|
||||
|
||||
import * as util from 'util';
|
||||
import * as fs from "fs";
|
||||
import promisify = require('util.promisify');
|
||||
|
||||
// tslint:disable-next-line ban-types
|
||||
let readFile: Function = promisify(fs.readFile);
|
||||
|
||||
promisify.shim();
|
||||
readFile = util.promisify(fs.readFile);
|
||||
Reference in New Issue
Block a user